summaryrefslogtreecommitdiff
path: root/views/data.jade
blob: 78d8b76e3b7a17485dfd2177ea0ed5cad0afeccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
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
        block href
    tr
      td rel
      td 
        if isUrl(link.rel)
          a(href=link.rel) #{link.rel}
        else
          | #{link.rel}
    tr
      td name
      td #{name}
    tr
      td prompt
      td #{prompt}
    if link.render == 'image'
      tr
        td
        td: img(src=link.href, alt=link.name, title=name)

block meta
  - var href=collection.href
  table
    tr
      td version
      td #{collection.version}
    tr
      td href
      td: block href

  form(action='http://redbot.org/?')
    p
      input(type='text', name='uri', value=url, type='hidden')
      input(type='text', name='req_hdr', value='Accept: application/vnd.collection+json', type='hidden')
      input(type='text', type='submit', value='Check with redbot.org')


  if collection.links.length > 0
    h2 Collection Links
    each link, i in collection.links
      - var title = link.prompt || link.name
      - title = title ? ': ' + title : ''
      h3 Collection Link ##{i}#{title}
      block link

// TODO: If the collection has prev/next links, add buttons to
// automaticaly navigate those.
// TODO: Add ability to show the raw part of the collection.
block items
  if collection.items.length == 0
    p Collection has no items.
  else
    // p The feed has #{collection.items.length} items.
    each item, i in collection.items
      // a(id='item-#{i+1}'): h2: a(href='#item-#{i+1}') Item ##{i+1}
      h2 Item ##{i+1}

      - var href=item.href
      p href: 
        block href

      if item.links.length > 0
        h3 Item Links
        each link, i in item.links
          h4 Item Link ##{i}
          block link

      h3 Data
      dl(class='dl-horizontal')
        each data in item.data
          dt #{data.name}
          dd #{data.value}

block queries
  if collection.queries.length == 0
    p Collection has no queries.
  else
    each query in collection.queries
      - var name = query.prompt || query.name || 'Unnamed query'
      h2= name

      div(class='row')
        div(class='span12')
          form(action='/render', class='well form-horizontal')
            input(type='hidden', name='url', value=query.href)
            fieldset
              each data in query.data
                - var value = params[data.name] || data.value
                div(class='control-group')
                  label(class='control-label', for=data.name) #{data.name}
                  div(class='controls')
                    input(type='text', name='param-' + data.name, value=value, class='input-xlarge')

            div(class='control-group')
              div(class='controls')
                input(type='submit') Execute
                // button(class='execute-query') Execute

block headers
  // a(id='headers'): h1: a(href='#headers') Headers
  pre
    table
      each value, key in headers
        tr
          td #{key}:
          td #{value}

block formatted_body
  // a(id='formatted-body'): h1: a(href='#formatted-body') Formatted body
  pre= formattedBody

block raw_body
  // a(id='body'): h1: a(href='#body') Raw body
  pre= rawBody

block navbar
  div(class='navbar navbar-fixed-top')
    div(class='navbar-inner')
      div(class='container')
        a(class='btn btn-navbar', data-toggle='collapse', data-target='.nav-collapse')
          span(class='icon-bar')
          span(class='icon-bar')
          span(class='icon-bar')
          span(class='icon-bar')
          span(class='icon-bar')
          span(class='icon-bar')
        a(class='brand', href='/') Collection+JSON Explorer
        div(class='nav-collapse')
          ul(class='nav')
            li(class='active'): a(href='#meta') Meta
            li: a(href='#items') Items
            li: a(href='#queries') Queries
            li: a(href='#headers') Headers
            li: a(href='#formatted-body') Formatted Body
            li: a(href='#raw-body') Raw Body


block content
  if typeof err != 'undefined'
    section(id='error')
      div(class='page-error')
        h1 Error
    p Error rendering #{url}

    p= err
  else
    section(id='meta')
      div(class='page-header')
        h1 Meta
      block meta
    section(id='items')
      div(class='page-header')
        h1 Items 
          if collection.items.length > 1
            small #{collection.items.length} items
      block items
    section(id='queries')
      div(class='page-header')
        h1 Queries
      block queries
    section(id='headers')
      div(class='page-header')
        h1 Headers
      block headers
    section(id='formatted-body')
      div(class='page-header')
        h1 Formatted Body
      block formatted_body
    section(id='raw-body')
      div(class='page-header')
        h1 Raw Body
      block raw_body