diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-06-30 01:18:33 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-06-30 01:18:33 +0200 |
commit | 4af799c68089d2a56f69fc67c4c0cd9c82d176b8 (patch) | |
tree | 3aa05e2caae87e5c8e0b46901577fd19039565ec /views | |
parent | cc70ec9cb09172167e7ed334b2ab1def391c6d59 (diff) | |
download | collection-json-explorer-4af799c68089d2a56f69fc67c4c0cd9c82d176b8.tar.gz collection-json-explorer-4af799c68089d2a56f69fc67c4c0cd9c82d176b8.tar.bz2 collection-json-explorer-4af799c68089d2a56f69fc67c4c0cd9c82d176b8.tar.xz collection-json-explorer-4af799c68089d2a56f69fc67c4c0cd9c82d176b8.zip |
o Prettier and better error handling.
Diffstat (limited to 'views')
-rw-r--r-- | views/data.jade | 101 | ||||
-rw-r--r-- | views/index.jade | 12 |
2 files changed, 73 insertions, 40 deletions
diff --git a/views/data.jade b/views/data.jade index 15189e9..0bd5afd 100644 --- a/views/data.jade +++ b/views/data.jade @@ -1,12 +1,23 @@ extends layout +block href + if typeof href != 'string' + | <no href> + else + span + a(href=href) #{href} + | + a(href=urlgenerator.render(href)) Explore + block link - var name = typeof link.name == 'string' ? link.name : '<no name attribute>' - var prompt = typeof link.prompt == 'string' ? link.prompt : '<no prompt attribute>' + - var href = link.href table tr td href - td: a(href=link.href, name=link.name) #{link.href} + td + block href tr td rel td @@ -25,14 +36,18 @@ block link td td: img(src=link.href, alt=link.name, title=name) -block content - h1 Collection+JSON Explorer +block err + p Error rendering #{url} + + p= err + +block data p Viewing #{url} form(action="/render") p label URL: - input(name="url", value=url) + input(name="url", size=100, value=url) input(type="submit", value="Render") form(action="http://redbot.org/?") @@ -52,47 +67,53 @@ block content li a(href="#body") Raw body - a(id="meta") - h1 - a(href="#meta") Meta + a(id="meta"): h1: a(href="#meta") Meta - table - tr - td Version - td #{doc.version} - tr - td URI - td - if typeof doc.uri == 'string' - a(href=doc.uri) #{doc.uri} - else - span No URI + - var href=doc.href + table + tr + td version + td #{doc.version} + tr + td href + td: block href - h2 Collection Links + h2 Collection Links + if doc.links.length == 0 + p Collection has no links. + else each link, i in doc.links - h3 Collection Link ##{i} + - var title = link.prompt || link.name + - title = title ? ": " + title : "" + h3 Collection Link ##{i}#{title} block link a(id="items"): h1: a(href="#items") Items - each item, i in doc.items - a(id="item-#{i+1}") - h2: a(href="#item-#{i+1}") Item ##{i+1} + if doc.items.length == 0 + p Collection has to items. + else + p The feed has #{doc.items.length} items. + each item, i in doc.items + a(id="item-#{i+1}"): h2: a(href="#item-#{i+1}") Item ##{i+1} - if typeof item.href == 'string' - | href - a(href=item.href) #{item.href} + - var href=item.href + p href: + block href - h2 Item Links - each link, i in item.links - h3 Item Link ##{i} - block link + h3 Item Links + if item.links.length == 0 + p Item has no links. + else + each link, i in item.links + h4 Item Link ##{i} + block link - h3 Data - table - each data in item.data - tr - td #{data.name} - td #{data.value} + h3 Data + table + each data in item.data + tr + td #{data.name} + td #{data.value} a(id="headers"): h1: a(href="#headers") Headers pre @@ -107,3 +128,11 @@ block content a(id="body"): h1: a(href="#body") Raw body pre= raw + +block content + h1 Collection+JSON Explorer + + if typeof err == 'undefined' + block data + else + block err diff --git a/views/index.jade b/views/index.jade index 5625546..cd12e4a 100644 --- a/views/index.jade +++ b/views/index.jade @@ -3,19 +3,23 @@ extends layout block content h1 Collection+JSON Explorer + div This is a simple/dumb explorer for the + a(href='http://amundsen.com/media-types/collection/') Collection+JSON Hypermedia + | . + h2 Explore your own collection form(action='/render') p label URL: - input(name='url', value='http://p2k12.bitraf.no/checkins-trygvis.php') + input(name='url', size='100', value='http://example-collection-json-db.herokuapp.com/') input(type='submit', value='Render') h2 Examples - - p Taken from: - a(href='http://amundsen.com/media-types/collection/examples/') Mike Amundsen's examples + p Taken from: + a(href='http://amundsen.com/media-types/collection/examples/') Mike Amundsen's examples ul + - var examples = examples || [] each example in examples li - var u='http://' + host + '/render?url=' + encodeURIComponent('http://' + host + '/examples/from-spec/' + example + '.collection+json') |