Compare commits
No commits in common. "8b70447e2aafd73d3428e52b6e32a8019ddec51b" and "5d2b097cbd7e9150d625f1e5e2a12186e8f6ccb3" have entirely different histories.
8b70447e2a
...
5d2b097cbd
@ -1,11 +0,0 @@
|
||||
# Contributing
|
||||
|
||||
Contributions are welcome, and they are greatly appreciated! Every
|
||||
little bit helps, and credit will always be given.
|
||||
|
||||
Types of contributions:
|
||||
|
||||
- **Report bugs**: If you think you've found a bug please submit a bug report with some information as operating system, details about your local setup and detailed steps to reproduce the bug.
|
||||
- **Fix bugs**: Look through the GitHub issues for bugs. Anything tagged with "bug"
|
||||
is open to whoever wants to implement it.
|
||||
- **Implement features**: Take in account that features always involves PR and code review.
|
3
Makefile
3
Makefile
@ -9,6 +9,3 @@ build:
|
||||
|
||||
clean:
|
||||
rm -f bin/wikingo
|
||||
|
||||
changelog:
|
||||
git log --oneline --decorate --pretty=format:'* %s' >> CHANGELOG.md
|
||||
|
24
TODO.md
24
TODO.md
@ -6,8 +6,10 @@
|
||||
- [x] Flag that sets the debug mode
|
||||
- [x] Flag to show the version
|
||||
- [x] Page versioning in a really basic way
|
||||
- [x] Version listing
|
||||
- [ ] Flag to select store
|
||||
- [ ] Config file (to select store and some other future options)
|
||||
- [x] Makefile helper
|
||||
- [ ] Reload if files changes [idea](https://medium.com/@olebedev/live-code-reloading-for-golang-web-projects-in-19-lines-8b2e8777b1ea#.gok9azrg4)
|
||||
- [ ] CI (gofmt, golint, more)?
|
||||
|
||||
## Bootstrap
|
||||
@ -16,23 +18,5 @@
|
||||
- [x] Sample Model
|
||||
- [x] Store interface (gorm, file...)
|
||||
- [x] Open db store
|
||||
- [x] Templates
|
||||
|
||||
## Must
|
||||
> Must have things (as tasks)
|
||||
- [ ] List history (in every detail page, a link to the history should be included)
|
||||
- [ ] Deal with static content (images, attachments...)
|
||||
- [ ] If you're about to save not the latest version, button: save -> restore
|
||||
- [ ] Delete any page or version
|
||||
- [ ] Not allow to create a kind of forbidden-words list (edit, list, version...)
|
||||
- [ ] Redirect page/ -> page
|
||||
|
||||
## Enhacements
|
||||
> Things that would be awesome to have, but not necessary for now
|
||||
- [ ] Config file (to select store and some other future options)
|
||||
- [ ] Flag to select store
|
||||
- [ ] Open file store
|
||||
- [ ] Reload if files changes [idea](https://medium.com/@olebedev/live-code-reloading-for-golang-web-projects-in-19-lines-8b2e8777b1ea#.gok9azrg4)
|
||||
- [ ] Add a `make release` Makefile command
|
||||
- [idea](https://github.com/miekg/dns/blob/master/Makefile.fuzz)
|
||||
- [idea](https://github.com/miekg/dns/blob/master/Makefile.release)
|
||||
- [x] Templates
|
||||
|
@ -8,5 +8,4 @@ type Store interface {
|
||||
GetPage(string) (Page, error)
|
||||
GetPageVersion(string, string) (Page, error)
|
||||
GetAllPages() ([]Page, error)
|
||||
GetPageHistory(name string) ([]Page, error)
|
||||
}
|
||||
|
@ -65,16 +65,7 @@ func (s *StoreGorm) GetPageVersion(name string, version string) (Page, error) {
|
||||
|
||||
func (s *StoreGorm) GetAllPages() ([]Page, error) {
|
||||
var pages []Page
|
||||
tx := s.db.Select("*, max(Version)").Group("Name").Find(&pages)
|
||||
if tx.Error != nil {
|
||||
return []Page{}, tx.Error
|
||||
}
|
||||
return pages, nil
|
||||
}
|
||||
|
||||
func (s *StoreGorm) GetPageHistory(name string) ([]Page, error) {
|
||||
var pages []Page
|
||||
tx := s.db.Debug().Where("Name = ?", name).Order("Version desc").Find(&pages)
|
||||
tx := s.db.Find(&pages)
|
||||
if tx.Error != nil {
|
||||
return []Page{}, tx.Error
|
||||
}
|
||||
|
@ -100,20 +100,6 @@ func WikiPagePostEdit(c echo.Context) error {
|
||||
return c.Redirect(http.StatusMovedPermanently, "/"+page.Name)
|
||||
}
|
||||
|
||||
func WikiPageHistory(c echo.Context) error {
|
||||
page_id := c.Param("page")
|
||||
pages, err := store.GetPageHistory(page_id)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
Debug.Printf("res: %T\n", pages)
|
||||
// Debug.Println(pages)
|
||||
return c.Render(http.StatusOK, "list.html", map[string]interface{}{
|
||||
"title": page_id,
|
||||
"pages": pages,
|
||||
})
|
||||
}
|
||||
|
||||
func WikiList(c echo.Context) error {
|
||||
pages, err := store.GetAllPages()
|
||||
if err != nil {
|
||||
|
@ -68,7 +68,6 @@ func Serve() {
|
||||
e.GET("/:page", WikiPage)
|
||||
e.GET("/:page/:version", WikiPage)
|
||||
e.GET("/:page/edit", WikiPageEdit)
|
||||
e.GET("/:page/history", WikiPageHistory)
|
||||
e.GET("/:page/:version/edit", WikiPageEdit)
|
||||
e.POST("/:page/edit", WikiPagePostEdit)
|
||||
e.POST("/:page/:version/edit", WikiPagePostEdit)
|
||||
|
@ -3,14 +3,10 @@
|
||||
{{end}}
|
||||
|
||||
{{define "body"}}
|
||||
{{ if .title }}
|
||||
<h1>{{ .title }}</h1>
|
||||
{{ else }}
|
||||
<h1>List</h1>
|
||||
{{ end }}
|
||||
<ul>
|
||||
{{ range .pages }}
|
||||
<li><a href="/{{ .Name }}/{{ .Version }}">{{ .Name }}, v{{ .Version }}</a>.- {{ .Body }}</li>
|
||||
<li><a href="{{ .Name }}/{{ .Version }}">{{ .Name }}, v{{ .Version }}</a>.- {{ .Body }}</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{end}}
|
||||
|
@ -7,9 +7,6 @@
|
||||
{{ .html | safeHTML }}
|
||||
<hr />
|
||||
<a href="/{{ .page.Name }}/{{ .page.Version }}/edit">Edit</a>
|
||||
{{ if gt .page.Version 1 }}
|
||||
<a href="/{{ .page.Name }}/history">History</a>
|
||||
{{ end }}
|
||||
<p style="float: right">Last modified: {{ .page.UpdatedAt }}</p>
|
||||
<p style="float: right">*{{ .page.Version }}*</p>
|
||||
{{end}}
|
||||
|
Loading…
Reference in New Issue
Block a user