Gisle Aune
7 years ago
18 changed files with 453 additions and 43 deletions
-
1controllers/listcontroller.go
-
171controllers/pagecontroller.go
-
2controllers/usercontroller.go
-
14model/category.go
-
25model/header.go
-
40model/page.go
-
2model/page_test.go
-
12model/tag.go
-
28view/funcs.go
-
11view/renderer.go
-
32view/templates/index.tmpl
-
12view/templates/page/create.tmpl
-
37view/templates/page/delete.tmpl
-
50view/templates/page/edit.tmpl
-
44view/templates/page/view.tmpl
-
3view/templates/user/login.tmpl
-
10viewmodel/base.go
-
2viewmodel/pageview.go
@ -0,0 +1,28 @@ |
|||||
|
package view |
||||
|
|
||||
|
import ( |
||||
|
"html/template" |
||||
|
"strings" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
func formatDate(date time.Time) string { |
||||
|
return date.Format("Jan _2, 2006") |
||||
|
} |
||||
|
|
||||
|
func formatDateLong(date time.Time) string { |
||||
|
return date.Format("Jan _2, 2006 15:04 MST") |
||||
|
} |
||||
|
|
||||
|
func formatUserID(userid string) string { |
||||
|
split := strings.SplitN(userid, ":", 2) |
||||
|
return split[len(split)-1] |
||||
|
} |
||||
|
|
||||
|
var funcMap = template.FuncMap{ |
||||
|
"formatDate": formatDate, |
||||
|
"formatDateLong": formatDateLong, |
||||
|
"formatUserID": formatUserID, |
||||
|
|
||||
|
"tolower": strings.ToLower, |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
{{ define "content" }} |
||||
|
<article class="narrow"> |
||||
|
<h1 class="danger">Delete Page</h1> |
||||
|
<form action="/page/delete/{{$.Page.ID}}", method="POST"> |
||||
|
<p class="danger"> |
||||
|
This is an irreversible action, so make sure that this is the correct page! |
||||
|
</p> |
||||
|
<ul> |
||||
|
<li><b>ID:</b> {{$.Page.ID}}</li> |
||||
|
<li><b>Name:</b> {{$.Page.Name}}</li> |
||||
|
<li><b>Category:</b> {{$.Page.Category}}</li> |
||||
|
<li><b>Published:</b> {{$.Page.PublishDate | formatDateLong}}</li> |
||||
|
</ul> |
||||
|
<input type="hidden" name="aft" value="{{$.User.SessionID}}" /> |
||||
|
|
||||
|
<button type="submit">Delete Page</button> |
||||
|
</article> |
||||
|
{{ end }} |
||||
|
|
||||
|
{{ define "menu" }} |
||||
|
<a href="/"><h1>Page</h1></a> |
||||
|
|
||||
|
{{ if eq $.User.ID $.Page.Author}} |
||||
|
<ul> |
||||
|
<li><a href="/page/edit/{{$.Page.ID}}"><div class="mg-icon">E</div><div class="mg-label">Edit</div></a></li> |
||||
|
<li class="selected"><a href="/page/delete/{{$.Page.ID}}"><div class="mg-icon">X</div><div class="mg-label">Delete</div></a></li> |
||||
|
</ul> |
||||
|
{{ end }} |
||||
|
|
||||
|
<ul> |
||||
|
<li><a href="/page/{{$.Page.ID}}"><div class="mg-icon"><</div><div class="mg-label">Back</div></a></li> |
||||
|
</ul> |
||||
|
{{ end }} |
||||
|
|
||||
|
{{ define "head" }} |
||||
|
<link rel="stylesheet" href="/ui/css/form.css" /> |
||||
|
{{ end }} |
@ -0,0 +1,50 @@ |
|||||
|
{{ define "content" }} |
||||
|
<article> |
||||
|
<h1>{{$.Operation}}</h1> |
||||
|
<form action="/page/edit/{{$.Page.ID}}", method="POST"> |
||||
|
<p class="danger">{{$.Error}}</p> |
||||
|
<input class="big" placeholder="Page Name" name="name" type="text" value="{{$.Page.Name}}" /> |
||||
|
<textarea class="tall" placeholder="Content" name="source">{{$.Page.Source}}</textarea> |
||||
|
<input placeholder="IC Date" name="fictionalDate" type="text" value="{{if $.Page.FictionalDate.IsZero}}{{else}}{{$.Page.FictionalDate}}{{end}}" /> |
||||
|
<div class="group"> |
||||
|
{{ range $.Categories }} |
||||
|
<div class="radio-wrapper"> |
||||
|
<input name="category" type="radio" name="category" value="{{.Key}}" {{if eq $.Page.Category .Key}}checked{{end}}><b> {{.Key}}</b>: {{.Info}}</input> |
||||
|
</div> |
||||
|
{{ end }} |
||||
|
</div> |
||||
|
<textarea name="tags" placeholder="Tags, e.g. 'Location: Miner's Respite'. One per line, topmost is primary tag">{{$.TagInput}}</textarea> |
||||
|
<div class="group"> |
||||
|
<div class="radio-wrapper"> |
||||
|
<input type="checkbox" name="dated" value="true" {{if $.Page.Dated}}checked{{end}}><b> Dated</b>: The IC date is shown on the page list. It will still be used for sorting if this option is disabled.</input> |
||||
|
</div> |
||||
|
<div class="radio-wrapper"> |
||||
|
<input type="checkbox" name="unlisted" value="true" {{if $.Page.Unlisted}}checked{{end}}><b> Unlisted</b>: This page will not show up on page lists, but anyone with a link can view it.</input> |
||||
|
</div> |
||||
|
<div class="radio-wrapper"> |
||||
|
<input type="checkbox" name="specific" value="true" {{if $.Page.Specific}}checked{{end}}><b> Specific</b>: This page will only show up on page lists when one of its tags is searched for.</input> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<!-- Future option --> |
||||
|
<input type="hidden" name="type" value="Markdown" /> |
||||
|
<input type="hidden" name="published" value="True" /> |
||||
|
|
||||
|
<button type="submit">{{$.Operation}}</button> |
||||
|
|
||||
|
</form> |
||||
|
</article> |
||||
|
{{ end }} |
||||
|
|
||||
|
{{ define "menu" }} |
||||
|
<a href="/"><h1>Aite RP</h1></a> |
||||
|
|
||||
|
<ul> |
||||
|
<li><a href="/"><div class="mg-icon"><</div><div class="mg-label">Back</div></a></li> |
||||
|
</ul> |
||||
|
{{ end }} |
||||
|
|
||||
|
{{ define "head" }} |
||||
|
<link rel="stylesheet" href="/ui/css/form.css" /> |
||||
|
<script type="text/javascript" src="/ui/js/form-page.js"></script> |
||||
|
{{ end }} |
@ -0,0 +1,44 @@ |
|||||
|
{{ define "content" }} |
||||
|
<article class="narrow"> |
||||
|
{{$.Page.Content}} |
||||
|
</article> |
||||
|
{{ end }} |
||||
|
|
||||
|
{{ define "menu" }} |
||||
|
<a href="/page/{{$.Page.ID}}"><h1>Page</h1></a> |
||||
|
{{ if $.Page.Dated}} |
||||
|
<div class="page-property">{{$.Page.FictionalDate | formatDate}}</div> |
||||
|
{{ else }} |
||||
|
<div class="page-property">{{$.Page.PublishDate | formatDate}}</div> |
||||
|
{{ end }} |
||||
|
|
||||
|
<ul> |
||||
|
{{ range $.Page.Tags }} |
||||
|
<li><a href="/{{.Hook}}"><div class="mg-icon">{{.Icon}}</div><div class="mg-label {{.CSSCLass}}">{{.Name}}</div></a></li> |
||||
|
{{ end }} |
||||
|
</ul> |
||||
|
|
||||
|
{{ if eq $.User.ID $.Page.Author}} |
||||
|
<ul> |
||||
|
<li><a href="/page/edit/{{$.Page.ID}}"><div class="mg-icon">E</div><div class="mg-label">Edit</div></a></li> |
||||
|
<li><a href="/page/delete/{{$.Page.ID}}"><div class="mg-icon">X</div><div class="mg-label">Delete</div></a></li> |
||||
|
</ul> |
||||
|
{{ end }} |
||||
|
|
||||
|
<ul> |
||||
|
<li><a href="/"><div class="mg-icon"><</div><div class="mg-label">Back</div></a></li> |
||||
|
</ul> |
||||
|
|
||||
|
{{ if $.User.LoggedIn }} |
||||
|
<ul> |
||||
|
<li><a href="/user/logout"><div class="mg-icon">A</div><div class="mg-label">Logout</div></a></li> |
||||
|
</ul> |
||||
|
{{ else }} |
||||
|
<ul> |
||||
|
<li><a href="/user/login"><div class="mg-icon">A</div><div class="mg-label">Login</div></a></li> |
||||
|
</ul> |
||||
|
{{ end }} |
||||
|
{{ end }} |
||||
|
|
||||
|
{{ define "head" }} |
||||
|
{{ end }} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue