diff --git a/common/template_init.go b/common/template_init.go index 88630195..a2952ee3 100644 --- a/common/template_init.go +++ b/common/template_init.go @@ -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 } diff --git a/common/templates/context.go b/common/templates/context.go index 7ac03819..2e9e66a7 100644 --- a/common/templates/context.go +++ b/common/templates/context.go @@ -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() } diff --git a/common/templates/templates.go b/common/templates/templates.go index 50b0e8e4..232cb165 100644 --- a/common/templates/templates.go +++ b/common/templates/templates.go @@ -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) { diff --git a/common/topic.go b/common/topic.go index 6275c5e2..1bebc2f0 100644 --- a/common/topic.go +++ b/common/topic.go @@ -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 diff --git a/langs/english.json b/langs/english.json index 886ebf2e..48f7ba0b 100644 --- a/langs/english.json +++ b/langs/english.json @@ -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", diff --git a/templates/account_own_edit.html b/templates/account_own_edit.html index 4c7b3074..4fcc663e 100644 --- a/templates/account_own_edit.html +++ b/templates/account_own_edit.html @@ -1,29 +1,29 @@
-