client/pools: inherit option to show underscores as spaces

This commit is contained in:
Shyam Sunder 2020-06-23 12:36:26 -04:00
parent 029c112011
commit d420609f97
10 changed files with 14 additions and 15 deletions

View file

@ -1,5 +1,5 @@
<div class='content-wrapper' id='pool'> <div class='content-wrapper' id='pool'>
<h1><%- ctx.pool.names[0] %></h1> <h1><%- ctx.getPrettyName(ctx.pool.names[0]) %></h1>
<nav class='buttons'><!-- <nav class='buttons'><!--
--><ul><!-- --><ul><!--
--><li data-name='summary'><a href='<%- ctx.formatClientLink('pool', ctx.pool.id) %>'>Summary</a></li><!-- --><li data-name='summary'><a href='<%- ctx.formatClientLink('pool', ctx.pool.id) %>'>Summary</a></li><!--

View file

@ -93,7 +93,7 @@
--><% if (ctx.canListPosts) { %><!-- --><% if (ctx.canListPosts) { %><!--
--><a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeColons(tag.names[0])}) %>' class='<%= ctx.makeCssName(tag.category, 'tag') %>'><!-- --><a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeColons(tag.names[0])}) %>' class='<%= ctx.makeCssName(tag.category, 'tag') %>'><!--
--><% } %><!-- --><% } %><!--
--><%- ctx.getPrettyTagName(tag.names[0]) %>&#32;<!-- --><%- ctx.getPrettyName(tag.names[0]) %>&#32;<!--
--><% if (ctx.canListPosts) { %><!-- --><% if (ctx.canListPosts) { %><!--
--></a><!-- --></a><!--
--><% } %><!-- --><% } %><!--

View file

@ -66,8 +66,8 @@
<li> <li>
<%= ctx.makeCheckbox({ <%= ctx.makeCheckbox({
text: 'Display underscores as spaces in tags', text: 'Display underscores as spaces',
name: 'tag-underscores-as-spaces', name: 'underscores-as-spaces',
checked: ctx.browsingSettings.tagUnderscoresAsSpaces, checked: ctx.browsingSettings.tagUnderscoresAsSpaces,
}) %> }) %>
<p class='hint'>Display all underscores as if they were spaces. This is only a visual change, which means that you'll still have to use underscores when searching or editing tags.</p> <p class='hint'>Display all underscores as if they were spaces. This is only a visual change, which means that you'll still have to use underscores when searching or editing tags.</p>

View file

@ -1,5 +1,5 @@
<div class='content-wrapper' id='tag'> <div class='content-wrapper' id='tag'>
<h1><%- ctx.getPrettyTagName(ctx.tag.names[0]) %></h1> <h1><%- ctx.getPrettyName(ctx.tag.names[0]) %></h1>
<nav class='buttons'><!-- <nav class='buttons'><!--
--><ul><!-- --><ul><!--
--><li data-name='summary'><a href='<%- ctx.formatClientLink('tag', ctx.tag.names[0]) %>'>Summary</a></li><!-- --><li data-name='summary'><a href='<%- ctx.formatClientLink('tag', ctx.tag.names[0]) %>'>Summary</a></li><!--

View file

@ -30,7 +30,7 @@ class PostReadonlySidebarControl extends events.EventTarget {
canViewTags: api.hasPrivilege("tags:view"), canViewTags: api.hasPrivilege("tags:view"),
escapeColons: uri.escapeColons, escapeColons: uri.escapeColons,
extractRootDomain: uri.extractRootDomain, extractRootDomain: uri.extractRootDomain,
getPrettyTagName: misc.getPrettyTagName, getPrettyName: misc.getPrettyName,
}) })
); );

View file

@ -204,7 +204,7 @@ function dataURItoBlob(dataURI) {
return new Blob([data], { type: mimeString }); return new Blob([data], { type: mimeString });
} }
function getPrettyTagName(tag) { function getPrettyName(tag) {
if (settings.get().tagUnderscoresAsSpaces) { if (settings.get().tagUnderscoresAsSpaces) {
return tag.replace(/_/g, " "); return tag.replace(/_/g, " ");
} }
@ -228,5 +228,5 @@ module.exports = {
decamelize: decamelize, decamelize: decamelize,
escapeSearchTerm: escapeSearchTerm, escapeSearchTerm: escapeSearchTerm,
dataURItoBlob: dataURItoBlob, dataURItoBlob: dataURItoBlob,
getPrettyTagName: getPrettyTagName, getPrettyName: getPrettyName,
}; };

View file

@ -210,7 +210,7 @@ function makePostLink(id, includeHash) {
function makeTagLink(name, includeHash, includeCount, tag) { function makeTagLink(name, includeHash, includeCount, tag) {
const category = tag ? tag.category : "unknown"; const category = tag ? tag.category : "unknown";
let text = misc.getPrettyTagName(name); let text = misc.getPrettyName(name);
if (includeHash === true) { if (includeHash === true) {
text = "#" + text; text = "#" + text;
} }
@ -235,7 +235,7 @@ function makeTagLink(name, includeHash, includeCount, tag) {
function makePoolLink(id, includeHash, includeCount, pool, name) { function makePoolLink(id, includeHash, includeCount, pool, name) {
const category = pool ? pool.category : "unknown"; const category = pool ? pool.category : "unknown";
let text = name ? name : pool.names[0]; let text = misc.getPrettyName(name ? name : pool.names[0]);
if (includeHash === true) { if (includeHash === true) {
text = "#" + text; text = "#" + text;
} }

View file

@ -18,7 +18,7 @@ class PoolView extends events.EventTarget {
this._ctx = ctx; this._ctx = ctx;
ctx.pool.addEventListener("change", (e) => this._evtChange(e)); ctx.pool.addEventListener("change", (e) => this._evtChange(e));
ctx.section = ctx.section || "summary"; ctx.section = ctx.section || "summary";
ctx.getPrettyPoolName = misc.getPrettyPoolName; ctx.getPrettyName = misc.getPrettyName;
this._hostNode = document.getElementById("content-holder"); this._hostNode = document.getElementById("content-holder");
this._install(); this._install();

View file

@ -42,9 +42,8 @@ class SettingsView extends events.EventTarget {
tagSuggestions: this._find("tag-suggestions").checked, tagSuggestions: this._find("tag-suggestions").checked,
autoplayVideos: this._find("autoplay-videos").checked, autoplayVideos: this._find("autoplay-videos").checked,
postsPerPage: this._find("posts-per-page").value, postsPerPage: this._find("posts-per-page").value,
tagUnderscoresAsSpaces: this._find( tagUnderscoresAsSpaces: this._find("underscores-as-spaces")
"tag-underscores-as-spaces" .checked,
).checked,
}, },
}) })
); );

View file

@ -18,7 +18,7 @@ class TagView extends events.EventTarget {
this._ctx = ctx; this._ctx = ctx;
ctx.tag.addEventListener("change", (e) => this._evtChange(e)); ctx.tag.addEventListener("change", (e) => this._evtChange(e));
ctx.section = ctx.section || "summary"; ctx.section = ctx.section || "summary";
ctx.getPrettyTagName = misc.getPrettyTagName; ctx.getPrettyName = misc.getPrettyName;
this._hostNode = document.getElementById("content-holder"); this._hostNode = document.getElementById("content-holder");
this._install(); this._install();