Revamped the Nox Account Manager and Control Panel Menus.

The topics list template is now generated by loggedin.
Replaced some uses of {{if ne .CurrentUser.ID 0}} with {{if .CurrentUser.Loggedin}}
Fixed a bug in the profiles where the comment creation form was shown to guests.
Added the profile_comments_form_guest phrase.
This commit is contained in:
Azareal 2018-11-29 07:46:53 +10:00
parent 5009a8b04c
commit 266f17c23d
14 changed files with 75 additions and 108 deletions

View File

@ -54,6 +54,8 @@ var Template_topics_handle = func(pi TopicListPage, w io.Writer) error {
}
return Templates.ExecuteTemplate(w, mapping+".html", pi)
}
var Template_topics_guest_handle = Template_topics_handle
var Template_topics_member_handle = Template_topics_handle
// nolint
var Template_forum_handle = func(pi ForumPage, w io.Writer) error {
@ -270,7 +272,11 @@ func CompileTemplates() error {
topicsList = append(topicsList, &TopicsRow{1, "topic-title", "Topic Title", "The topic content.", 1, false, false, now, now, "Date", user3.ID, 1, "", "127.0.0.1", 1, 0, 1, "classname", "", &user2, "", 0, &user3, "General", "/forum/general.2"})
header2.Title = "Topic List"
topicListPage := TopicListPage{header, topicsList, forumList, Config.DefaultForum, TopicListSort{"lastupdated", false}, Paginator{[]int{1}, 1, 1}}
topicListTmpl, err := compile("topics", "common.TopicListPage", topicListPage)
/*topicListTmpl, err := compile("topics", "common.TopicListPage", topicListPage)
if err != nil {
return err
}*/
topicListTmpl, err := compileByLoggedin("topics", "common.TopicListPage", topicListPage)
if err != nil {
return err
}

View File

@ -43,8 +43,8 @@ func (con *CContext) PushText(body string, fragIndex int, fragOutIndex int) (ind
return con.LastBufIndex()
}
func (con *CContext) PushPhrase(body string, langIndex int) (index int) {
*con.OutBuf = append(*con.OutBuf, OutBufferFrame{body, "lang", con.TemplateName, langIndex, nil})
func (con *CContext) PushPhrase(langIndex int) (index int) {
*con.OutBuf = append(*con.OutBuf, OutBufferFrame{"", "lang", con.TemplateName, langIndex, nil})
return con.LastBufIndex()
}

View File

@ -325,8 +325,8 @@ func (c *CTemplateSet) compile(name string, content, expects string, expectsInt
for fid := 0; len(outBuf) > fid; fid++ {
frame := outBuf[fid]
c.detail(frame.Type + " frame")
if frame.Type == "text" {
c.detail("text frame:")
c.detail(frame)
oid := fid
c.detail("oid:", oid)
@ -354,13 +354,12 @@ func (c *CTemplateSet) compile(name string, content, expects string, expectsInt
}
writeTextFrame(frame.TemplateName, frame.Extra.(int)-skip)
} else if frame.Type == "varsub" || frame.Type == "cvarsub" {
c.detail(frame.Type + " frame")
fout += "w.Write(" + frame.Body + ")\n"
} else if frame.Type == "identifier" {
c.detailf(frame.Type+" frame:%+v\n", frame)
fout += frame.Body
} else if frame.Type == "lang" {
fout += "w.Write(plist[" + strconv.Itoa(frame.Extra.(int)) + "])\n"
} else {
c.detail(frame.Type + " frame")
fout += frame.Body
}
}
@ -721,8 +720,10 @@ func (c *CTemplateSet) compileSubSwitch(con CContext, node *parse.CommandNode) {
case *parse.IdentifierNode:
c.detail("Identifier Node:", node)
c.detail("Identifier Node Args:", node.Args)
out, outval, lit := c.compileIdentSwitch(con, node)
if lit {
out, outval, lit, noident := c.compileIdentSwitch(con, node)
if noident {
return
} else if lit {
con.Push("identifier", out)
return
}
@ -780,7 +781,7 @@ func (c *CTemplateSet) unknownNode(node parse.Node) {
func (c *CTemplateSet) compileIdentSwitchN(con CContext, node *parse.CommandNode) (out string) {
c.detail("in compileIdentSwitchN")
out, _, _ = c.compileIdentSwitch(con, node)
out, _, _, _ = c.compileIdentSwitch(con, node)
return out
}
@ -844,7 +845,7 @@ func (c *CTemplateSet) compareJoin(con CContext, pos int, node *parse.CommandNod
return pos, out
}
func (c *CTemplateSet) compileIdentSwitch(con CContext, node *parse.CommandNode) (out string, val reflect.Value, literal bool) {
func (c *CTemplateSet) compileIdentSwitch(con CContext, node *parse.CommandNode) (out string, val reflect.Value, literal bool, notident bool) {
c.dumpCall("compileIdentSwitch", con, node)
var litString = func(inner string, bytes bool) {
if !bytes {
@ -916,7 +917,8 @@ ArgLoop:
// ! Slightly crude but it does the job
leftParam := strings.Replace(leftOperand, "\"", "", -1)
c.langIndexToName = append(c.langIndexToName, leftParam)
litString("plist["+strconv.Itoa(len(c.langIndexToName)-1)+"]", true)
notident = true
con.PushPhrase(len(c.langIndexToName) - 1)
break ArgLoop
case "level":
// TODO: Implement level literals
@ -981,7 +983,7 @@ ArgLoop:
}
}
c.retCall("compileIdentSwitch", out, val, literal)
return out, val, literal
return out, val, literal, notident
}
func (c *CTemplateSet) compileReflectSwitch(con CContext, node *parse.CommandNode) (out string, outVal reflect.Value) {

View File

@ -49,7 +49,7 @@ type TopicUser struct {
ID int
Link string
Title string
Content string
Content string // TODO: Avoid converting this to bytes in templates, particularly if it's long
CreatedBy int
IsClosed bool
Sticky bool
@ -74,7 +74,7 @@ type TopicUser struct {
Avatar string
MicroAvatar string
ContentLines int
ContentHTML string
ContentHTML string // TODO: Avoid converting this to bytes in templates, particularly if it's long
Tag string
URL string
URLPrefix string

View File

@ -637,6 +637,7 @@
"profile_comments_report_aria":"Report Item",
"profile_comments_form_content":"Insert comment here",
"profile_comments_form_button":"Create Reply",
"profile_comments_form_guest":"You need to login to comment on this profile.",
"profile_owner_tag":"Profile Owner",
"ip_search_head":"IP Search",

View File

@ -1,29 +1,29 @@
<form id="avatar_form" action="/user/edit/avatar/submit/?session={{.CurrentUser.Session}}" method="post" enctype="multipart/form-data"></form>
<div class="coldyn_block">
<div id="dash_left" class="coldyn_item">
<div class="rowitem">
<span id="dash_username">
<form id="dash_username_form" action="/user/edit/username/submit/?session={{.CurrentUser.Session}}" method="post"></form>
<input form="dash_username_form" name="account-new-username" value="{{.CurrentUser.Name}}" />
<button form="dash_username_form" class="formbutton">{{lang "account_username_save"}}</button>
</span>
<img src="{{.CurrentUser.Avatar}}" height="128px" />
<span id="dash_avatar_buttons">
<input form="avatar_form" id="select_avatar" name="account-avatar" type="file" required style="display: none;" />
<label for="select_avatar" class="formbutton">{{lang "account_avatar_select"}}</label>
<button form="avatar_form" name="account-button" class="formbutton">{{lang "account_avatar_update_button"}}</button>
</span>
<div class="coldyn_block">
<div id="dash_left" class="coldyn_item">
<div class="rowitem">
<span id="dash_username">
<form id="dash_username_form" action="/user/edit/username/submit/?session={{.CurrentUser.Session}}" method="post"></form>
<input form="dash_username_form" name="account-new-username" value="{{.CurrentUser.Name}}" />
<button form="dash_username_form" class="formbutton">{{lang "account_username_save"}}</button>
</span>
<img src="{{.CurrentUser.Avatar}}" height="128px" />
<span id="dash_avatar_buttons">
<input form="avatar_form" id="select_avatar" name="account-avatar" type="file" required style="display: none;" />
<label for="select_avatar" class="formbutton">{{lang "account_avatar_select"}}</label>
<button form="avatar_form" name="account-button" class="formbutton">{{lang "account_avatar_update_button"}}</button>
</span>
</div>
</div>
<div id="dash_right" class="coldyn_item">
<div class="rowitem">{{if not .MFASetup}}<a href="/user/edit/mfa/setup/">{{lang "account_dash_2fa_setup"}}</a>{{else}}<a href="/user/edit/mfa/">{{lang "account_dash_2fa_manage"}}</a>{{end}} <span class="dash_security">{{lang "account_dash_security_notice"}}</span></div>
<div class="rowitem level_inprogress">
<div class="levelBit">
<a href="/user/levels/">{{level .CurrentUser.Level}}</a>
</div>
<div class="progressWrap" style="width: {{.Percentage}}%;">
<div>{{.CurrentScore}} / {{.NextScore}}</div>
</div>
</div>
<div id="dash_right" class="coldyn_item">
<div class="rowitem">{{if not .MFASetup}}<a href="/user/edit/mfa/setup/">{{lang "account_dash_2fa_setup"}}</a>{{else}}<a href="/user/edit/mfa/">{{lang "account_dash_2fa_manage"}}</a>{{end}} <span class="dash_security">{{lang "account_dash_security_notice"}}</span></div>
<div class="rowitem level_inprogress">
<div class="levelBit">
<a href="/user/levels/">{{level .CurrentUser.Level}}</a>
</div>
<div class="progressWrap" style="width: {{.Percentage}}%;">
<div>{{.CurrentScore}} / {{.NextScore}}</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -8,7 +8,7 @@
<div class="rowitem forum_title">
<h1 itemprop="name">{{.Title}}</h1>
</div>
{{if ne .CurrentUser.ID 0}}
{{if .CurrentUser.Loggedin}}
<div class="optbox">
{{if .CurrentUser.Perms.CreateTopic}}
<div class="pre_opt auto_hide"></div>
@ -22,7 +22,7 @@
<div style="clear: both;"></div>
{{end}}
</div>
{{if ne .CurrentUser.ID 0}}
{{if .CurrentUser.Loggedin}}
<div class="mod_floater auto_hide">
<form method="post">
<div class="mod_floater_head">
@ -110,7 +110,7 @@
</span>
</div>
</div>
</div>{{else}}<div class="rowitem passive rowmsg">{{lang "forum_no_topics"}}{{if .CurrentUser.Perms.CreateTopic}} <a href="/topics/create/{{.Forum.ID}}">{{lang "forum_start_one"}}</a>{{end}}</div>{{end}}
</div>{{else}}<div class="rowitem passive rowmsg">{{lang "forum_no_topics"}}{{if .CurrentUser.Loggedin}}{{if .CurrentUser.Perms.CreateTopic}} <a href="/topics/create/{{.Forum.ID}}">{{lang "forum_start_one"}}</a>{{end}}{{end}}</div>{{end}}
</div>
{{if gt .LastPage 1}}

View File

@ -8,11 +8,11 @@
{{range .ItemList}}<div class="rowitem {{if (.Desc) or (.LastTopic.Title)}}datarow {{end}}"itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<span class="forum_left shift_left">
<a href="{{.Link}}" itemprop="item">{{.Name}}</a>
<a href="{{.Link}}" itemprop="item">{{.Name}}</a><br />
{{if .Desc}}
<br /><span class="rowsmall" itemprop="description">{{.Desc}}</span>
<span class="rowsmall" itemprop="description">{{.Desc}}</span>
{{else}}
<br /><span class="rowsmall forum_nodesc">{{lang "forums_no_description"}}</span>
<span class="rowsmall forum_nodesc">{{lang "forums_no_description"}}</span>
{{end}}
</span>
<span class="forum_right shift_right">

View File

@ -24,7 +24,7 @@
<body>
{{if not .CurrentUser.IsSuperMod}}<style>.supermod_only { display: none !important; }</style>{{end}}
<div class="container">
<!--<div class="navrow">-->
{{/**<!--<div class="navrow">-->**/}}
<div class="left_of_nav">{{dock "leftOfNav" .Header }}</div>
<nav class="nav">
<div class="move_left">
@ -50,7 +50,7 @@
</div>
{{end}}
</div>
<!--</div>-->
{{/**<!--</div>-->**/}}
<div class="midRow">
<div class="midLeft"></div>
<div id="back" class="zone_{{.Header.Zone}}{{if .Header.Widgets.RightSidebar}} shrink_main{{end}}">

View File

@ -18,7 +18,7 @@
<div class="levelBit">
<a>{{level .ProfileOwner.Level}}</a>
</div>
<div class="progressWrap" style="width: 40%;">
<div class="progressWrap"{{if ne .CurrentScore 0}} style="width: 40%"{{end}}>
<div>{{.CurrentScore}} / {{.NextScore}}</div>
</div>
</div>
@ -87,6 +87,7 @@
</div>
<div id="profile_comments" class="colstack_item hash_hide">{{template "profile_comments_row.html" . }}</div>
{{if .CurrentUser.Loggedin}}
{{if not .CurrentUser.IsBanned}}
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/?session={{.CurrentUser.Session}}" method="post">
<input name="uid" value='{{.ProfileOwner.ID}}' type="hidden" />
@ -100,10 +101,16 @@
</div>
</form>
{{end}}
{{else}}
<div class="colstack_item" style="border-top: none;">
<div class="rowitem passive">{{lang "profile_comments_form_guest"}}</div>
</div>
{{end}}
</div>
</div>
{{if .CurrentUser.Loggedin}}
{{/** Quick subpage switcher **/}}
{{/** TODO: Stop inlining this **/}}
<script type="text/javascript">
@ -123,5 +130,6 @@ function handle_profile_hashbit() {
if(window.location.hash) handle_profile_hashbit()
window.addEventListener("hashchange", handle_profile_hashbit, false)
</script>
{{end}}
{{template "footer.html" . }}

View File

@ -3,7 +3,7 @@
<div class="rowblock rowhead topic_list_title_block{{if ne .CurrentUser.ID 0}} has_opt{{end}}">
<div class="rowitem topic_list_title"><h1 itemprop="name">{{lang "topics_head"}}</h1></div>
{{if ne .CurrentUser.ID 0}}
{{if .CurrentUser.Loggedin}}
<div class="optbox">
{{if .ForumList}}
<div class="opt filter_opt">
@ -29,7 +29,7 @@
{{end}}
</div>
{{if ne .CurrentUser.ID 0}}
{{if .CurrentUser.Loggedin}}
{{/** TODO: Hide these from unauthorised users? **/}}
<div class="mod_floater auto_hide">
<form method="post">
@ -116,7 +116,7 @@
<div class="rowitem rowmsg"><a href="" class="more_topics"></a></div>
</div>
<div id="topic_list" class="rowblock topic_list topic_list_{{.Sort.SortBy}}" aria-label="{{lang "topics_list_aria"}}">
{{range .TopicList}}{{template "topics_topic.html" . }}{{else}}<div class="rowitem passive rowmsg">{{lang "topics_no_topics"}}{{if .CurrentUser.Perms.CreateTopic}} <a href="/topics/create/">{{lang "topics_start_one"}}</a>{{end}}</div>{{end}}
{{range .TopicList}}{{template "topics_topic.html" . }}{{else}}<div class="rowitem passive rowmsg">{{lang "topics_no_topics"}}{{if .CurrentUser.Loggedin}}{{if .CurrentUser.Perms.CreateTopic}} <a href="/topics/create/">{{lang "topics_start_one"}}</a>{{end}}{{end}}</div>{{end}}
</div>
{{if gt .LastPage 1}}

View File

@ -6,35 +6,7 @@
#back {
padding: 0px;
}
.rowmenu {
margin-left: 16px;
}
.colstack_left {
width: 200px;
padding-top: 12px;
padding-right: 24px;
padding-bottom: 24px;
padding-left: 24px;
background-color: #3e3e3e;
}
.colstack_left .colstack_head {
font-size: 19px;
margin-bottom: 4px;
}
.colstack_left .colstack_head:not(:first-child) {
margin-top: 8px;
}
.colstack_left .colstack_head a {
color: rgb(210, 210, 210);
}
.rowmenu {
margin-bottom: 2px;
font-size: 17px;
}
.rowmenu a {
color: rgb(180, 180, 180);
}
{{template "acc_panel_common.css" }}
.colstack_right {
background-color: #333333;

View File

@ -10,38 +10,16 @@
.footer .widget, #poweredByHolder {
background-color: #393939;
}
.rowmenu {
margin-left: 16px;
}
.submenu a:before {
content: "-";
margin-right: 8px;
}
.colstack_left {
width: 200px;
padding-top: 12px;
padding-right: 24px;
padding-bottom: 24px;
padding-left: 24px;
background-color: #3e3e3e;
}
{{template "acc_panel_common.css" }}
.colstack_left .colstack_head {
font-size: 19px;
margin-bottom: 4px;
}
.colstack_left .colstack_head:not(:first-child) {
margin-top: 8px;
}
.colstack_left .colstack_head a {
color: rgb(210, 210, 210);
}
.rowmenu {
margin-bottom: 2px;
font-size: 17px;
}
.rowmenu a {
color: rgb(180, 180, 180);
padding-top: 10px;
padding-bottom: 10px;
}
.menu_stats {
margin-left: 4px;

View File

@ -1,6 +1,6 @@
{
"Name": "nox",
"FriendlyName": "Nox (Incomplete)",
"FriendlyName": "Nox (WIP)",
"Version": "0.0.1",
"Creator": "Azareal",
"URL": "github.com/Azareal/Gosora",