topiary-io / topiary

a modern content management system
Other
2 stars 0 forks source link

Expose only necessary files to the admin, instead of everything from the Hugo site root #13

Open doesntgolf opened 8 years ago

doesntgolf commented 8 years ago

Instead of exposing everything from the Hugo base directory to the admin, we should selectively grab only what's needed.

To expand on what Zach started with #8, on startup we should use Viper to read the config to check for archetypedir, contentdir, datadir, layoutdir, publishdir, and staticdir. (The default values for each of these are listed on the Hugo configuration page.) We can then control the interface for editing each of the site input sections, rather than just exposing a big textarea editor for every file.

Eventually this will probably also tie in with different admin user roles.

doesntgolf commented 8 years ago

Got this started with c5a141a. Editing content files is now handled separately from other files. The frontmatter fields are exposed as separate fields from the content body. Currently would not recommend saving a content file via the admin though ;)

doesntgolf commented 8 years ago

Another step closer on this. You can now update content files with the front matter separated into its own fields (and it actually saves!), and all other files can still be updated with the old textarea and save button. The bulk of the logic has been moved out of admin.go; most of the content file logic is now in content.go, and all other files are using static.go.

Note that currently when you save front matter fields that have multiple values, they get messed up. I think this can mostly be handled on the template (we'll also need to add the ability to add new text inputs for multi-value fields on the template eventually) and saveHandler, but it should be fairly straightforward.

The next steps will be to continue moving generic dir listing logic to custom content dir logic. We should read the sections, then display those in the sidebar nav under Content, instead of the hardcoded Posts and Pages. Then on the section listing pages, instead of just having a list of filenames, we should display the title and date from each file's front matter (once this is done, we should be a lot closer to a generic API that can be shared for Go and Mithril templating). After this, we'll want to create custom display logic for layouts, static, data, .git, and the config (although most of these can share most of their logic, except for config and .git).

There's a lot of repeated functionality that can probably be combined to cut down on a lot of cruft, but it should probably wait until this issue is mostly complete.

EDIT: I've also added funcs for creating new files, but I haven't explored how to use them on templates yet.