0

The point is to create a simple CMS with Padrino in which front-end content is object driven, i.e. aside from domain models of the app, there is a "Page" model and a "Content"/"Snippet" and maybe "Category" model.

Looking at https://github.com/padrino/padrino-web I get how it can be done, although in my current use case it would make more sense to leave code completely out of the admin text fields. The people who'll update content aren't savvy of html, haml, markup, etc, and so it would be good to have different layouts for different instances of a "Page" model, which in turn would have plain text snippets which are hardcoded just in place in the different templates, while being editable in admin.

Does this make sense, and is it possible?

bcsantos
  • 2,635
  • 5
  • 21
  • 22

1 Answers1

0

Yes, it makes sense and is possible. I have been using similar approach for ages in my CMS based on Padrino.

I've done it with using Markdown renderer for user content and slim template engine for layout content.

The approach comes to the following simple things (method names are here for example):

# if no controller got the request, try finding some content in the sitemap
get '/:request_uri', :request_uri => /.*/ do
  page = Page.get(params[:request_uri]) or not_found
  html_content = render_markdown(page.content)
  layout = Layout.get(page.layout_id)
  render_layout(layout, html_content)
end
ujifgc
  • 2,215
  • 2
  • 19
  • 21
  • this is encouraging, thanks. would you mind sharing the Page and Layout model definitions so as to get a better grasp on things? – bcsantos Jul 31 '14 at 14:22
  • It's an example off the top of my head. There's nothing to share. – ujifgc Jul 31 '14 at 21:42