langf now works in transpiled templates, albeit a little inefficiently.
Removed the quick_topic.add_poll_option phrase. Added the quick_topic.add_poll_option_first phrase. Changed the topic.reply_add_poll_option phrase. Added the topic.reply_add_poll_option_first phrase.
This commit is contained in:
parent
89c8f4e775
commit
89ca5ee823
|
@ -179,6 +179,7 @@ type TopicCAttachItem struct {
|
||||||
}
|
}
|
||||||
type TopicCPollInput struct {
|
type TopicCPollInput struct {
|
||||||
Index int
|
Index int
|
||||||
|
Place string
|
||||||
}
|
}
|
||||||
|
|
||||||
type TopicPage struct {
|
type TopicPage struct {
|
||||||
|
|
|
@ -49,6 +49,11 @@ func (con *CContext) PushPhrase(langIndex int) (index int) {
|
||||||
return con.LastBufIndex()
|
return con.LastBufIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (con *CContext) PushPhrasef(langIndex int, args string) (index int) {
|
||||||
|
*con.OutBuf = append(*con.OutBuf, OutBufferFrame{args, "langf", con.TemplateName, langIndex, nil})
|
||||||
|
return con.LastBufIndex()
|
||||||
|
}
|
||||||
|
|
||||||
func (con *CContext) StartLoop(body string) (index int) {
|
func (con *CContext) StartLoop(body string) (index int) {
|
||||||
con.LoopDepth++
|
con.LoopDepth++
|
||||||
return con.Push("startloop", body)
|
return con.Push("startloop", body)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
"text/template/parse"
|
"text/template/parse"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -106,7 +107,7 @@ func NewCTemplateSet(in string) *CTemplateSet {
|
||||||
"hasWidgets": true,
|
"hasWidgets": true,
|
||||||
"elapsed": true,
|
"elapsed": true,
|
||||||
"lang": true,
|
"lang": true,
|
||||||
//"langf":true,
|
"langf":true,
|
||||||
"level": true,
|
"level": true,
|
||||||
"bunit": true,
|
"bunit": true,
|
||||||
"abstime": true,
|
"abstime": true,
|
||||||
|
@ -1109,7 +1110,56 @@ ArgLoop:
|
||||||
notident = true
|
notident = true
|
||||||
con.PushPhrase(len(c.langIndexToName) - 1)
|
con.PushPhrase(len(c.langIndexToName) - 1)
|
||||||
break ArgLoop
|
break ArgLoop
|
||||||
// TODO: Implement langf
|
case "langf":
|
||||||
|
// TODO: Implement string literals properly
|
||||||
|
leftOperand := node.Args[pos+1].String()
|
||||||
|
if len(leftOperand) == 0 {
|
||||||
|
panic("The left operand for the language string cannot be left blank")
|
||||||
|
}
|
||||||
|
if leftOperand[0] != '"' {
|
||||||
|
panic("Phrase names cannot be dynamic")
|
||||||
|
}
|
||||||
|
|
||||||
|
var olist []string
|
||||||
|
for i := pos+2; i < len(node.Args); i++ {
|
||||||
|
op := node.Args[i].String()
|
||||||
|
if op != "" {
|
||||||
|
if op[0] == '.' || op[0] == '$' {
|
||||||
|
panic("langf args cannot be dynamic")
|
||||||
|
}
|
||||||
|
if op[0] != '"' && !unicode.IsDigit(rune(op[0])) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
olist = append(olist,op)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(olist) == 0 {
|
||||||
|
panic("You must provide parameters for langf")
|
||||||
|
}
|
||||||
|
|
||||||
|
var ob = ","
|
||||||
|
for _, op := range olist {
|
||||||
|
allNum := true
|
||||||
|
for _, o := range op {
|
||||||
|
if !unicode.IsDigit(o) {
|
||||||
|
allNum = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if allNum {
|
||||||
|
ob += strings.Replace(op,"\"","\\\"",-1) + ","
|
||||||
|
} else {
|
||||||
|
ob += ob + ","
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ob != "" {
|
||||||
|
ob = ob[:len(ob)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement string literals properly
|
||||||
|
// ! Slightly crude but it does the job
|
||||||
|
litString("phrases.GetTmplPhrasef("+leftOperand+ob+")", false)
|
||||||
|
c.importMap[langPkg] = langPkg
|
||||||
|
break ArgLoop
|
||||||
case "level":
|
case "level":
|
||||||
// TODO: Implement level literals
|
// TODO: Implement level literals
|
||||||
leftOperand := node.Args[pos+1].String()
|
leftOperand := node.Args[pos+1].String()
|
||||||
|
|
|
@ -546,7 +546,7 @@
|
||||||
"quick_topic.avatar_alt":"Your Avatar",
|
"quick_topic.avatar_alt":"Your Avatar",
|
||||||
"quick_topic.whatsup":"What's up?",
|
"quick_topic.whatsup":"What's up?",
|
||||||
"quick_topic.content_placeholder":"Insert post here",
|
"quick_topic.content_placeholder":"Insert post here",
|
||||||
"quick_topic.add_poll_option":"Poll option",
|
"quick_topic.add_poll_option_first":"Poll option #0",
|
||||||
"quick_topic.create_topic_button":"Create Topic",
|
"quick_topic.create_topic_button":"Create Topic",
|
||||||
"quick_topic.create_topic_button_short":"New Topic",
|
"quick_topic.create_topic_button_short":"New Topic",
|
||||||
"quick_topic.add_poll_button":"Add Poll",
|
"quick_topic.add_poll_button":"Add Poll",
|
||||||
|
@ -653,7 +653,8 @@
|
||||||
"topic.reply_aria":"The quick reply form",
|
"topic.reply_aria":"The quick reply form",
|
||||||
"topic.reply_content":"Insert reply here",
|
"topic.reply_content":"Insert reply here",
|
||||||
"topic.reply_content_alt":"What do you think?",
|
"topic.reply_content_alt":"What do you think?",
|
||||||
"topic.reply_add_poll_option":"Poll option",
|
"topic.reply_add_poll_option":"Poll option #%d",
|
||||||
|
"topic.reply_add_poll_option_first":"Poll option #0",
|
||||||
"topic.reply_button":"Create Reply",
|
"topic.reply_button":"Create Reply",
|
||||||
"topic.reply_add_poll_button":"Add Poll",
|
"topic.reply_add_poll_button":"Add Poll",
|
||||||
"topic.reply_add_file_button":"Add File",
|
"topic.reply_add_file_button":"Add File",
|
||||||
|
|
|
@ -286,6 +286,7 @@
|
||||||
if(dataPollInput != (pollInputIndex-1)) return;
|
if(dataPollInput != (pollInputIndex-1)) return;
|
||||||
$(".poll_content_row .formitem").append(Template_topic_c_poll_input({
|
$(".poll_content_row .formitem").append(Template_topic_c_poll_input({
|
||||||
Index: pollInputIndex,
|
Index: pollInputIndex,
|
||||||
|
Place: phraseBox["topic"]["topic.reply_add_poll_option"].replace("%d",pollInputIndex),
|
||||||
}));
|
}));
|
||||||
pollInputIndex++;
|
pollInputIndex++;
|
||||||
console.log("new pollInputIndex: ", pollInputIndex);
|
console.log("new pollInputIndex: ", pollInputIndex);
|
||||||
|
|
|
@ -82,10 +82,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="formrow poll_content_row auto_hide">
|
<div class="formrow poll_content_row auto_hide">
|
||||||
<div class="formitem">
|
<div class="formitem">
|
||||||
<div class="pollinput" data-pollinput="0">
|
<div class="pollinput" data-pollinput=0>
|
||||||
<input type="checkbox" disabled />
|
<input type="checkbox" disabled />
|
||||||
<label class="pollinputlabel"></label>
|
<label class="pollinputlabel"></label>
|
||||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "topic.reply_add_poll_option"}}" />
|
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "topic.reply_add_poll_option_first"}}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="rowblock topic_reply_container">
|
<div class="rowblock topic_reply_container">
|
||||||
<div class="userinfo" aria-label="{{lang "topic.your_information"}}">
|
<div class="userinfo" aria-label="{{lang "topic.your_information"}}">
|
||||||
<div class="avatar_item" style="background-image: url({{.CurrentUser.Avatar}}), url(/static/white-dot.jpg);background-position: 0px -10px;"> </div>
|
<div class="avatar_item" style="background-image:url({{.CurrentUser.Avatar}}), url(/static/white-dot.jpg);background-position:0px -10px;"> </div>
|
||||||
<div class="user_meta">
|
<div class="user_meta">
|
||||||
<a href="{{.CurrentUser.Link}}" class="the_name" rel="author">{{.CurrentUser.Name}}</a>
|
<a href="{{.CurrentUser.Link}}" class="the_name" rel="author">{{.CurrentUser.Name}}</a>
|
||||||
{{if .CurrentUser.Tag}}<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">{{.CurrentUser.Tag}}</div><div class="tag_post"></div></div>{{else}}<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">{{level .CurrentUser.Level}}</div><div class="tag_post"></div></div>{{end}}
|
{{if .CurrentUser.Tag}}<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">{{.CurrentUser.Tag}}</div><div class="tag_post"></div></div>{{else}}<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">{{level .CurrentUser.Level}}</div><div class="tag_post"></div></div>{{end}}
|
||||||
|
@ -17,10 +17,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="formrow poll_content_row auto_hide">
|
<div class="formrow poll_content_row auto_hide">
|
||||||
<div class="formitem">
|
<div class="formitem">
|
||||||
<div class="pollinput" data-pollinput="0">
|
<div class="pollinput" data-pollinput=0>
|
||||||
<input type="checkbox" disabled />
|
<input type="checkbox" disabled />
|
||||||
<label class="pollinputlabel"></label>
|
<label class="pollinputlabel"></label>
|
||||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "topic.reply_add_poll_option"}}" />
|
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "topic.reply_add_poll_option_first"}}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class='pollinput' data-pollinput='{{.Index}}'>
|
<div class='pollinput' data-pollinput={{.Index}}>
|
||||||
<input type='checkbox' disabled />
|
<input type='checkbox' disabled />
|
||||||
<label class='pollinputlabel'></label>
|
<label class='pollinputlabel'></label>
|
||||||
<input form='quick_post_form' name='pollinputitem[{{.Index}}]' class='pollinputinput' type='text' placeholder='{{lang "topic.reply_add_poll_option"}}' />
|
<input form='quick_post_form' name='pollinputitem[{{.Index}}]' class='pollinputinput' type='text' placeholder='{{.Place}}' />
|
||||||
</div>
|
</div>
|
|
@ -1,26 +1,26 @@
|
||||||
<input form="quick_post_form" id="has_poll_input" name="has_poll" value="0" type="hidden" />
|
<input form="quick_post_form" id="has_poll_input" name="has_poll" value="0" type="hidden" />
|
||||||
<div class="formrow topic_content_row">
|
<div class="formrow topic_content_row">
|
||||||
<div class="formitem">
|
<div class="formitem">
|
||||||
<textarea form="quick_post_form" id="input_content" name="topic-content" placeholder="{{lang "quick_topic.content_placeholder"}}" required></textarea>
|
<textarea form="quick_post_form" id="input_content" name="topic-content" placeholder="{{lang "quick_topic.content_placeholder"}}" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow poll_content_row auto_hide">
|
||||||
|
<div class="formitem">
|
||||||
|
<div class="pollinput" data-pollinput=0>
|
||||||
|
<input type="checkbox" disabled />
|
||||||
|
<label class="pollinputlabel"></label>
|
||||||
|
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "quick_topic.add_poll_option_first"}}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="formrow poll_content_row auto_hide">
|
</div>
|
||||||
<div class="formitem">
|
</div>
|
||||||
<div class="pollinput" data-pollinput="0">
|
<div class="formrow quick_button_row">
|
||||||
<input type="checkbox" disabled />
|
<div class="formitem">
|
||||||
<label class="pollinputlabel"></label>
|
<button form="quick_post_form" class="formbutton">{{lang "quick_topic.create_topic_button"}}</button>
|
||||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "quick_topic.add_poll_option"}}" />
|
<button form="quick_post_form" class="formbutton" id="add_poll_button">{{lang "quick_topic.add_poll_button"}}</button>
|
||||||
</div>
|
{{if .CurrentUser.Perms.UploadFiles}}
|
||||||
</div>
|
<input name="upload_files" form="quick_post_form" id="upload_files" multiple type="file" class="auto_hide" />
|
||||||
</div>
|
<label for="upload_files" class="formbutton add_file_button">{{lang "quick_topic.add_file_button"}}</label>
|
||||||
<div class="formrow quick_button_row">
|
<div id="upload_file_dock"></div>{{end}}
|
||||||
<div class="formitem">
|
<button class="formbutton close_form">{{lang "quick_topic.cancel_button"}}</button>
|
||||||
<button form="quick_post_form" class="formbutton">{{lang "quick_topic.create_topic_button"}}</button>
|
</div>
|
||||||
<button form="quick_post_form" class="formbutton" id="add_poll_button">{{lang "quick_topic.add_poll_button"}}</button>
|
</div>
|
||||||
{{if .CurrentUser.Perms.UploadFiles}}
|
|
||||||
<input name="upload_files" form="quick_post_form" id="upload_files" multiple type="file" class="auto_hide" />
|
|
||||||
<label for="upload_files" class="formbutton add_file_button">{{lang "quick_topic.add_file_button"}}</label>
|
|
||||||
<div id="upload_file_dock"></div>{{end}}
|
|
||||||
<button class="formbutton close_form">{{lang "quick_topic.cancel_button"}}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
Loading…
Reference in New Issue