-
-
Save jamiehodge/2370908 to your computer and use it in GitHub Desktop.
ul | |
- for keyword in keywords | |
li | |
a rel='item' href=url("/#{keyword.id}", false) = keyword.name | |
nav | |
ul | |
- if keywords.next_page | |
li | |
a rel='next' href=url("/?page=#{keywords.next_page}", false) Next Page | |
- if keywords.prev_page | |
li | |
a rel='prev' href=url("/?page=#{keywords.prev_page}", false) Previous Page | |
aside | |
form.search action=url('/', false) method='get' | |
fieldset | |
legend Search Keywords | |
p | |
label for='search' Search | |
input type='search' name='search' placeholder='search' required=true results=5 autosave=url('/') | |
p | |
input type='submit' value='Search' | |
form.create action=url('/', false) method='post' | |
fieldset | |
legend Create Keyword | |
p | |
label for='name' Name | |
input type='text' name='name' placeholder='name' required=true | |
p | |
input type='submit' value='Create' | |
article | |
header | |
h1 | |
a rel='self' href=url("/#{keyword.id}", false) = keyword.name | |
p | |
time datetime=keyword.updated_at.xmlschema = keyword.updated_at.strftime "%Y/%m/%d, %H:%M %Z" | |
nav | |
ul | |
li | |
a rel='collection' href=url("/", false) Index | |
dl | |
dt name | |
dd = keyword.name | |
aside | |
form.update action=url("/#{keyword.id}", false) method='post' | |
fieldset | |
legend Edit Keyword | |
input type='hidden' name='_method' value='patch' | |
p | |
label for='name' Name | |
input type='text' name='name' value=keyword.name placeholder='name' required=true | |
p | |
input type='submit' value='Update' | |
form.delete action=url("/#{keyword.id}", false) method='post' | |
fieldset | |
legend Delete Keyword | |
input type='hidden' name='_method' value='delete' | |
p | |
input type='submit' value='Delete' | |
After going through @mamund's demos, I really had a desire to reduce the number of necessary elements, especially in the HTML example. I'm working on a project where I'm considering mediating the db and public-facing app with an api app, but it seems ludicrous to have the API emit JSON and then translate that to HTML in the public-facing app. It would seem ideal to have a lean, semantic HTML that can also be styled into something presentable. This would mean that the public-facing app could treat the API like Rails cells, assembling them into a portal/dashboard. That's the idea in any case. Thoughts?
I'm generally a fan of using XHTML as a media type for APIs. Seems sound.
In a real view, I'd tweak the way you generate some of the links by moving some stuff into presenters/helpers, but yeah, this all looks fine to me.
I think it looks great. I'll be attempting to add an XHTML or HTML5 (haven't done the research yet into why one is chosen over the other) media type to an API once the Collection+JSON is done. I'll revisit this gist at that time with a specific, practical goal in mind. Thanks for sharing, @jamiehodge!
Seems like a pretty reasonable start. Any specific feedback you were looking for, or a sanity check?