Revamped the IP Search Page for Nox.

Revamped the Word Filter Manager for Nox.
Revamped the Setting Manager for Nox and Cosora.
Upped the number of items in the User Manager.
Upped the number of items in the Group Manager.
Upped the number of items in the Page Manager.
Swap a fmt.Println for a DebugLog in hold.ScanItem.
EQCSS.js should ignore panel.css in Cosora now.
Added the lang template function for stylesheet templates to reduce the amount of boilerplate.
Localised a couple of spots in the Nox Theme which got overlooked.
Tweaked the grid CSS for Nox.
The Control Panel Dashboard items now change colour in Nox like in the other themes.
Use Site.Host instead of req.Host for www redirects for security reasons.
Removed a superfluous function call in WriterIntercept.WriteHeader.
Tweaked several bits and pieces of CSS like the padding on a few items in the Forum Editor.

Added the topic_list.moderate phrase.
Added the panel_word_filters_to phrase.
This commit is contained in:
Azareal 2018-12-06 21:09:10 +10:00
parent 14884ebb14
commit a20078d83b
21 changed files with 156 additions and 53 deletions

View File

@ -9,8 +9,8 @@ import (
"strconv"
"strings"
"github.com/Azareal/Gosora/query_gen"
"github.com/Azareal/Gosora/common/phrases"
"github.com/Azareal/Gosora/query_gen"
)
type MenuItemList []MenuItem
@ -375,7 +375,7 @@ func (hold *MenuListHolder) ScanItem(menuTmpls map[string]MenuTmpl, mitem MenuIt
_, hasInnerVar := skipUntilIfExists(renderItem, 0, '{')
if hasInnerVar {
fmt.Println("inner var: ", string(renderItem))
DebugLog("inner var: ", string(renderItem))
dotAt, hasDot := skipUntilIfExists(renderItem, 0, '.')
endFence, hasEndFence := skipUntilIfExists(renderItem, dotAt, '}')
if !hasDot || !hasEndFence || (endFence-dotAt) <= 1 {

View File

@ -32,6 +32,7 @@ type Theme struct {
Disabled bool
HideFromThemes bool
BgAvatars bool // For profiles, at the moment
GridLists bool // User Manager
ForkOf string
Tag string
URL string
@ -77,6 +78,24 @@ type ThemeMapTmplToDock struct {
// TODO: It might be unsafe to call the template parsing functions with fsnotify, do something more concurrent
func (theme *Theme) LoadStaticFiles() error {
theme.ResourceTemplates = template.New("")
fmap := make(map[string]interface{})
fmap["lang"] = func(phraseNameInt interface{}, tmplInt interface{}) interface{} {
phraseName, ok := phraseNameInt.(string)
if !ok {
panic("phraseNameInt is not a string")
}
tmpl, ok := tmplInt.(CSSData)
if !ok {
panic("tmplInt is not a CSSData")
}
phrase, ok := tmpl.Phrases[phraseName]
if !ok {
// TODO: XSS? Only server admins should have access to theme files anyway, but think about it
return "{lang." + phraseName + "}"
}
return phrase
}
theme.ResourceTemplates.Funcs(fmap)
template.Must(theme.ResourceTemplates.ParseGlob("./themes/" + theme.Name + "/public/*.css"))
// It should be safe for us to load the files for all the themes in memory, as-long as the admin hasn't setup a ridiculous number of themes
@ -106,6 +125,7 @@ func (theme *Theme) AddThemeStaticFiles() error {
var b bytes.Buffer
var pieces = strings.Split(path, "/")
var filename = pieces[len(pieces)-1]
// TODO: Prepare resource templates for each loaded langpack?
err = theme.ResourceTemplates.ExecuteTemplate(&b, filename, CSSData{Phrases: phraseMap})
if err != nil {
return err

View File

@ -543,9 +543,10 @@ func NewWriterIntercept(w http.ResponseWriter) *WriterIntercept {
return &WriterIntercept{w}
}
var wiMaxAge = "max-age=" + strconv.Itoa(int(common.Day))
func (writ *WriterIntercept) WriteHeader(code int) {
if code == 200 {
writ.ResponseWriter.Header().Set("Cache-Control", "max-age=" + strconv.Itoa(int(common.Day)))
writ.ResponseWriter.Header().Set("Cache-Control", wiMaxAge)
writ.ResponseWriter.Header().Set("Vary", "Accept-Encoding")
}
writ.ResponseWriter.WriteHeader(code)
@ -644,7 +645,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if common.Site.EnableSsl {
s = "s"
}
dest := "http"+s+"://" + req.Host + req.URL.Path
dest := "http"+s+"://" + common.Site.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
dest += "?" + req.URL.RawQuery
}

View File

@ -505,6 +505,7 @@
"topic_list.create_topic_tooltip":"Create Topic",
"topic_list.create_topic_aria":"Create a topic",
"topic_list.moderate":"Moderate",
"topic_list.moderate_tooltip":"Moderate",
"topic_list.moderate_aria":"Moderate Posts",
"topic_list.what_to_do":"What do you want to do with these {0} topics?",
@ -765,6 +766,7 @@
"panel_group_extended_permissions":"Extended Permissions",
"panel_word_filters_head":"Word Filters",
"panel_word_filters_to":"...to...",
"panel_word_filters_edit_button_aria":"Edit Word Filter",
"panel_word_filters_update_button":"Update",
"panel_word_filters_delete_button_aria":"Delete Word Filter",

View File

@ -61,7 +61,7 @@ License: MIT
for (i = 0; i < link.length; i++) {
// Test if the link is not read yet, and has rel=stylesheet
if (link[i].getAttribute('data-eqcss-read') === null && link[i].rel === 'stylesheet') {
if (link[i].getAttribute('data-eqcss-read') === null && link[i].rel === 'stylesheet' && link[i].getAttribute("href").endsWith("main.css")) {
// retrieve the file content with AJAX and process it
if (link[i].href) {
(function() {

View File

@ -325,9 +325,10 @@ func NewWriterIntercept(w http.ResponseWriter) *WriterIntercept {
return &WriterIntercept{w}
}
var wiMaxAge = "max-age=" + strconv.Itoa(int(common.Day))
func (writ *WriterIntercept) WriteHeader(code int) {
if code == 200 {
writ.ResponseWriter.Header().Set("Cache-Control", "max-age=" + strconv.Itoa(int(common.Day)))
writ.ResponseWriter.Header().Set("Cache-Control", wiMaxAge)
writ.ResponseWriter.Header().Set("Vary", "Accept-Encoding")
}
writ.ResponseWriter.WriteHeader(code)
@ -426,7 +427,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if common.Site.EnableSsl {
s = "s"
}
dest := "http"+s+"://" + req.Host + req.URL.Path
dest := "http"+s+"://" + common.Site.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
dest += "?" + req.URL.RawQuery
}

View File

@ -16,7 +16,7 @@ func Groups(w http.ResponseWriter, r *http.Request, user common.User) common.Rou
}
page, _ := strconv.Atoi(r.FormValue("page"))
perPage := 9
perPage := 15
offset, page, lastPage := common.PageOffset(basePage.Stats.Groups, page, perPage)
// Skip the 'Unknown' group

View File

@ -20,9 +20,10 @@ func Pages(w http.ResponseWriter, r *http.Request, user common.User) common.Rout
basePage.AddNotice("panel_page_deleted")
}
// TODO: Test the pagination here
pageCount := common.Pages.GlobalCount()
page, _ := strconv.Atoi(r.FormValue("page"))
perPage := 10
perPage := 15
offset, page, lastPage := common.PageOffset(pageCount, page, perPage)
cPages, err := common.Pages.GetOffset(offset, perPage)

View File

@ -19,6 +19,7 @@ func Settings(w http.ResponseWriter, r *http.Request, user common.User) common.R
return common.NoPermissions(w, r, user)
}
// TODO: What if the list gets too long? How should we structure this?
settings, err := basePage.Settings.BypassGetAll()
if err != nil {
return common.InternalError(err, w, r)

View File

@ -15,7 +15,7 @@ func Users(w http.ResponseWriter, r *http.Request, user common.User) common.Rout
}
page, _ := strconv.Atoi(r.FormValue("page"))
perPage := 10
perPage := 15
offset, page, lastPage := common.PageOffset(basePage.Stats.Users, page, perPage)
users, err := common.Users.GetOffset(offset, perPage)

View File

@ -18,6 +18,7 @@ func WordFilters(w http.ResponseWriter, r *http.Request, user common.User) commo
return common.NoPermissions(w, r, user)
}
// TODO: What if this list gets too long?
filterList, err := common.WordFilters.GetAll()
if err != nil {
return common.InternalError(err, w, r)

View File

@ -13,7 +13,7 @@
</div>
</div>
{{if .IP}}
<div class="rowblock rowlist bgavatars">
<div class="rowblock rowlist bgavatars micro_grid">
{{range .ItemList}}<div class="rowitem" style="background-image: url('{{.Avatar}}');">
<img src="{{.Avatar}}" class="bgsub" alt="{{.Name}}'s Avatar" />
<a class="rowTitle" href="{{.Link}}">{{.Name}}</a>

View File

@ -5,10 +5,10 @@
<div class="colstack_item colstack_head">
<div class="rowitem"><h1>{{lang "panel_settings_head"}}</h1></div>
</div>
<div id="panel_settings" class="colstack_item rowlist">
<div id="panel_settings" class="colstack_item rowlist bgavatars micro_grid">
{{range .Something}}
<div class="rowitem panel_compactrow editable_parent">
<a href="/panel/settings/edit/{{.Name}}" class="editable_block panel_upshift">{{.FriendlyName}}</a>
<a href="/panel/settings/edit/{{.Name}}" class="editable_block panel_upshift" title="{{.FriendlyName}}">{{.FriendlyName}}</a>
<a class="panel_compacttext to_right">{{.Content}}</a>
</div>
{{end}}

View File

@ -6,7 +6,7 @@
<div class="colstack_item colstack_head">
<div class="rowitem"><h1>{{lang "panel_word_filters_head"}}</h1></div>
</div>
<div id="panel_word_filters" class="colstack_item rowlist">
<div id="panel_word_filters" class="colstack_item rowlist micro_grid">
{{range .Something}}
<div class="rowitem panel_compactrow editable_parent">
<a data-field="find" data-type="text" href="/panel/settings/word-filters/edit/{{.ID}}" class="editable_block panel_upshift edit_fields filter_find">{{.Find}}</a>

View File

@ -25,9 +25,9 @@
margin-bottom: 8px;
margin-left: 16px;
padding-bottom: 12px;
padding-top: 12px;
padding-top: 12px;
padding-left: 8px;
border-bottom: 1px solid var(--element-border-color);
border-bottom: 1px solid var(--element-border-color);
border-left: none;
border-right: none;
border-top: none;
@ -186,6 +186,19 @@
#panel_setting .formlabel {
display: none;
}
#panel_settings .panel_upshift {
border-bottom: 1px solid var(--element-border-color);
padding-bottom: 12px;
}
#panel_settings.rowlist.bgavatars .rowitem > a, #panel_settings.rowlist.bgavatars .rowitem > span {
margin-left: 0px;
margin-right: 0px;
}
#panel_settings .to_right {
float: none;
margin-top: auto;
padding-top: 14px;
}
#panel_page_list textarea, #panel_page_edit textarea {
margin-top: 8px;
}

View File

@ -2,6 +2,7 @@
width: 200px;
padding-bottom: 6px;
background-color: rgb(62, 62, 62);
/*border-left: 4px solid rgb(82, 82, 82);*/
}
.colstack_left .colstack_head {
/*font-size: 19px;*/
@ -27,7 +28,7 @@
}
.rowmenu {
margin-left: 16px;
margin-left: 18px;
margin-bottom: 2px;
font-size: 17px;
}

View File

@ -350,7 +350,7 @@ h2 {
width: 100%;
}
.topic_list_title_block .pre_opt:before {
content: "{{index .Phrases "topics_click_topics_to_select"}}";
content: "{{lang "topics_click_topics_to_select" . }}";
font-size: 17px;
margin-right: 20px;
}
@ -360,10 +360,10 @@ h2 {
white-space: nowrap;
}
.topic_list_title_block .create_topic_opt a:before {
content: "Create Topic";
content: "{{lang "quick_topic.create_topic_button" . }}";
}
.topic_list_title_block .mod_opt a:before {
content: "Moderate";
content: "{{lang "topic_list.moderate" . }}";
}
.filter_opt {
@ -621,7 +621,7 @@ button, .formbutton, .panel_right_button:not(.has_inner_button) {
margin-top: 6px;
}
.topic_view_count:after {
content: "{{index .Phrases "topic.view_count_suffix"}}";
content: "{{lang "topic.view_count_suffix" . }}";
}
.topic_name_input {
width: 100%;
@ -772,50 +772,58 @@ input[type=checkbox]:checked + label .sel {
}
.add_like:before, .remove_like:before {
content: "{{index .Phrases "topic.plus_one"}}";
content: "{{lang "topic.plus_one" . }}";
}
.button_container .open_edit:after, .edit_item:after {
content: "{{index .Phrases "topic.edit_button_text"}}";
content: "{{lang "topic.edit_button_text" . }}";
}
.delete_item:after {
content: "{{index .Phrases "topic.delete_button_text"}}";
content: "{{lang "topic.delete_button_text" . }}";
}
.ip_item_button:after {
content: "{{index .Phrases "topic.ip_button_text"}}";
content: "{{lang "topic.ip_button_text" . }}";
}
.lock_item:after {
content: "{{index .Phrases "topic.lock_button_text"}}";
content: "{{lang "topic.lock_button_text" . }}";
}
.unlock_item:after {
content: "{{index .Phrases "topic.unlock_button_text"}}";
content: "{{lang "topic.unlock_button_text" . }}";
}
.pin_item:after {
content: "{{index .Phrases "topic.pin_button_text"}}";
content: "{{lang "topic.pin_button_text" . }}";
}
.unpin_item:after {
content: "{{index .Phrases "topic.unpin_button_text"}}";
content: "{{lang "topic.unpin_button_text" . }}";
}
.report_item:after {
content: "{{index .Phrases "topic.report_button_text"}}";
content: "{{lang "topic.report_button_text" . }}";
}
.like_count:after {
content: "{{index .Phrases "topic.like_count_suffix"}}";
content: "{{lang "topic.like_count_suffix" . }}";
}
.topic_reply_container {
display: flex;
}
.rowlist.bgavatars {
.rowlist.bgavatars, .micro_grid {
display: grid;
grid-gap: 16px;
grid-row-gap: 0px;
/*grid-gap: 16px;
grid-row-gap: 8px;*/
grid-gap: 24px;
grid-row-gap: 16px;
grid-template-columns: repeat(3, 1fr);
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.rowlist.bgavatars .rowitem {
.rowlist.bgavatars.micro_grid, .micro_grid {
grid-gap: 16px;
grid-row-gap: 4px;
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}
.rowlist.bgavatars .rowitem, .micro_grid .rowitem {
display: flex;
flex-direction: column;
width: 180px;
/*width: 180px;*/
background-image: none !important;
margin-bottom: 10px;
padding: 16px;

View File

@ -51,12 +51,21 @@
grid-gap: 8px;
grid-template-columns: repeat(3, 1fr);
}
.rowlist.bgavatars, .micro_grid {
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.grid_item {
border-radius: 3px;
color: rgb(190,190,190);
background-color: #444444;
background-color: rgb(68,68,68);
padding: 12px;
}
.stat_green {
background-color: rgb(68,88,68);
}
.stat_red {
background-color: rgb(88,68,68);
}
.to_right, .panel_buttons, .panel_floater {
margin-left: auto;
@ -68,10 +77,6 @@
padding-left: 6px;
padding-right: 6px;
}
.colstack_right input {
padding-left: 6px;
padding-right: 6px;
}
button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .profile_url {
background: rgb(100,100,200);
@ -79,7 +84,10 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p
#panel_users .panel_tag:not(.panel_right_button) {
background: rgb(50,150,50);
}
.panel_right_button:not(.has_inner_button), #panel_users .panel_tag:not(.panel_right_button), #panel_users .profile_url {
.panel_right_button:not(.has_inner_button),
.panel_right_button button,
#panel_users .panel_tag:not(.panel_right_button),
#panel_users .profile_url {
margin-left: 2px;
padding: 5px;
padding-left: 6px;
@ -92,10 +100,10 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p
border-radius: 3px;
}
.edit_button:after {
content: "{{index .Phrases "panel_edit_button_text"}}";
content: "{{lang "panel_edit_button_text" . }}";
}
.delete_button:after {
content: "{{index .Phrases "panel_delete_button_text"}}";
content: "{{lang "panel_delete_button_text" . }}";
}
/*#themeSelector select {
background: rgb(90,90,90);
@ -129,6 +137,42 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p
height: 80px;
}
.micro_grid .to_right, .micro_grid .panel_buttons {
margin-left: 0px;
}
#panel_settings .panel_upshift {
margin-bottom: 12px;
}
#panel_settings .to_right {
white-space: nowrap;
margin-top: auto;
padding-top: 10px;
background-color: #555555;
border-radius: 5px;
padding-left: 5px;
padding: 12px;
}
#panel_settings.rowlist.bgavatars.micro_grid, .micro_grid {
grid-gap: 24px;
grid-row-gap: 16px;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
#panel_word_filters {
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
#panel_word_filters .filters_find {
margin-bottom: 1px;
}
#panel_word_filters .itemSeparator:before {
content: "{{lang "panel_word_filters_to" . }}";
font-size: 17px;
margin-bottom: 1px;
}
#panel_word_filters .panel_buttons {
margin-top: 14px;
}
#panel_users .rowitem .to_right {
order: 0;
margin-right: auto;
@ -143,31 +187,31 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p
}
.perm_preset_no_access:before {
content: "{{index .Phrases "panel_perms_no_access" }}";
content: "{{lang "panel_perms_no_access" . }}";
/*color: hsl(0,100%,20%);*/
}
/*.perm_preset_read_only:before, .perm_preset_can_post:before {
color: hsl(120,100%,20%);
}*/
.perm_preset_read_only:before {
content: "{{index .Phrases "panel_perms_read_only" }}";
content: "{{lang "panel_perms_read_only" . }}";
}
.perm_preset_can_post:before {
content: "{{index .Phrases "panel_perms_can_post" }}";
content: "{{lang "panel_perms_can_post" . }}";
}
.perm_preset_can_moderate:before {
content: "{{index .Phrases "panel_perms_can_moderate" }}";
content: "{{lang "panel_perms_can_moderate" . }}";
/*color: hsl(240,100%,20%);*/
}
.perm_preset_quasi_mod:before {
content: "{{index .Phrases "panel_perms_quasi_mod" }}";
content: "{{lang "panel_perms_quasi_mod" . }}";
}
.perm_preset_custom:before {
content: "{{index .Phrases "panel_perms_custom" }}";
content: "{{lang "panel_perms_custom" . }}";
/*color: hsl(0,0%,20%);*/
}
.perm_preset_default:before {
content: "{{index .Phrases "panel_perms_default" }}";
content: "{{lang "panel_perms_default" . }}";
}
.panel_submitrow {
@ -183,12 +227,15 @@ button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .p
margin-right: auto;
}
.has_inner_button button {
/*.has_inner_button button {
margin-right: 8px;
}
}*/
#forum_quick_perms .formitem, #forum_quick_perms .panel_floater {
display: flex;
}
#forum_quick_perms .edit_fields {
margin-left: 4px;
}
.panel_plugin_meta {
display: flex;

View File

@ -6,6 +6,7 @@
"URL": "github.com/Azareal/Gosora",
"Tag": "WIP",
"Docks":["topMenu","rightSidebar","footer"],
"GridLists":true,
"MapTmplToDock": {
"rightOfNav": {
"File": "./templates/userDock.html"

View File

@ -66,6 +66,9 @@
margin-bottom: 5px;
}
#panel_settings .panel_compactrow {
padding-left: 10px;
}
#panel_word_filters .itemSeparator:before {
content: " || ";
padding-left: 2px;

View File

@ -145,6 +145,9 @@
padding-bottom: 3px;
}
#panel_settings .panel_compactrow {
padding-left: 10px;
}
#panel_word_filters .itemSeparator:before {
content: " || ";
padding-left: 2px;