manifest-rails 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,464 @@
1
+ // jquery.pjax.js
2
+ // copyright chris wanstrath
3
+ // https://github.com/defunkt/jquery-pjax
4
+
5
+ (function($){
6
+
7
+ // When called on a link, fetches the href with ajax into the
8
+ // container specified as the first parameter or with the data-pjax
9
+ // attribute on the link itself.
10
+ //
11
+ // Tries to make sure the back button and ctrl+click work the way
12
+ // you'd expect.
13
+ //
14
+ // Accepts a jQuery ajax options object that may include these
15
+ // pjax specific options:
16
+ //
17
+ // container - Where to stick the response body. Usually a String selector.
18
+ // $(container).html(xhr.responseBody)
19
+ // push - Whether to pushState the URL. Defaults to true (of course).
20
+ // replace - Want to use replaceState instead? That's cool.
21
+ //
22
+ // For convenience the first parameter can be either the container or
23
+ // the options object.
24
+ //
25
+ // Returns the jQuery object
26
+ $.fn.pjax = function( container, options ) {
27
+ options = optionsFor(container, options)
28
+ return this.live('click', function(event){
29
+ return handleClick(event, options)
30
+ })
31
+ }
32
+
33
+ // Public: pjax on click handler
34
+ //
35
+ // Exported as $.pjax.click.
36
+ //
37
+ // event - "click" jQuery.Event
38
+ // options - pjax options
39
+ //
40
+ // Examples
41
+ //
42
+ // $('a').live('click', $.pjax.click)
43
+ // // is the same as
44
+ // $('a').pjax()
45
+ //
46
+ // $(document).on('click', 'a', function(event) {
47
+ // var container = $(this).closest('[data-pjax-container]')
48
+ // return $.pjax.click(event, container)
49
+ // })
50
+ //
51
+ // Returns false if pjax runs, otherwise nothing.
52
+ function handleClick(event, container, options) {
53
+ options = optionsFor(container, options)
54
+
55
+ var link = event.currentTarget
56
+
57
+ // Middle click, cmd click, and ctrl click should open
58
+ // links in a new tab as normal.
59
+ if ( event.which > 1 || event.metaKey )
60
+ return
61
+
62
+ // Ignore cross origin links
63
+ if ( location.protocol !== link.protocol || location.host !== link.host )
64
+ return
65
+
66
+ // Ignore anchors on the same page
67
+ if ( link.hash && link.href.replace(link.hash, '') ===
68
+ location.href.replace(location.hash, '') )
69
+ return
70
+
71
+ var defaults = {
72
+ url: link.href,
73
+ container: $(link).attr('data-pjax'),
74
+ target: link,
75
+ clickedElement: $(link), // DEPRECATED: use target
76
+ fragment: null
77
+ }
78
+
79
+ $.pjax($.extend({}, defaults, options))
80
+
81
+ event.preventDefault()
82
+ return false
83
+ }
84
+
85
+ // Internal: Strips _pjax=true param from url
86
+ //
87
+ // url - String
88
+ //
89
+ // Returns String.
90
+ function stripPjaxParam(url) {
91
+ return url
92
+ .replace(/\?_pjax=true&?/, '?')
93
+ .replace(/_pjax=true&?/, '')
94
+ .replace(/\?$/, '')
95
+ }
96
+
97
+ // Internal: Parse URL components and returns a Locationish object.
98
+ //
99
+ // url - String URL
100
+ //
101
+ // Returns HTMLAnchorElement that acts like Location.
102
+ function parseURL(url) {
103
+ var a = document.createElement('a')
104
+ a.href = url
105
+ return a
106
+ }
107
+
108
+
109
+ // Loads a URL with ajax, puts the response body inside a container,
110
+ // then pushState()'s the loaded URL.
111
+ //
112
+ // Works just like $.ajax in that it accepts a jQuery ajax
113
+ // settings object (with keys like url, type, data, etc).
114
+ //
115
+ // Accepts these extra keys:
116
+ //
117
+ // container - Where to stick the response body.
118
+ // $(container).html(xhr.responseBody)
119
+ // push - Whether to pushState the URL. Defaults to true (of course).
120
+ // replace - Want to use replaceState instead? That's cool.
121
+ //
122
+ // Use it just like $.ajax:
123
+ //
124
+ // var xhr = $.pjax({ url: this.href, container: '#main' })
125
+ // console.log( xhr.readyState )
126
+ //
127
+ // Returns whatever $.ajax returns.
128
+ var pjax = $.pjax = function( options ) {
129
+ options = $.extend(true, {}, $.ajaxSettings, pjax.defaults, options)
130
+
131
+ if ($.isFunction(options.url)) {
132
+ options.url = options.url()
133
+ }
134
+
135
+ var target = options.target
136
+
137
+ // DEPRECATED: use options.target
138
+ if (!target && options.clickedElement) target = options.clickedElement[0]
139
+
140
+ var url = options.url
141
+ var hash = parseURL(url).hash
142
+
143
+ // DEPRECATED: Save references to original event callbacks. However,
144
+ // listening for custom pjax:* events is prefered.
145
+ var oldBeforeSend = options.beforeSend,
146
+ oldComplete = options.complete,
147
+ oldSuccess = options.success,
148
+ oldError = options.error
149
+
150
+ var context = options.context = findContainerFor(options.container)
151
+
152
+ function fire(type, args) {
153
+ var event = $.Event(type, { relatedTarget: target })
154
+ context.trigger(event, args)
155
+ return !event.isDefaultPrevented()
156
+ }
157
+
158
+ var timeoutTimer
159
+
160
+ options.beforeSend = function(xhr, settings) {
161
+ url = stripPjaxParam(settings.url)
162
+
163
+ if (settings.timeout > 0) {
164
+ timeoutTimer = setTimeout(function() {
165
+ if (fire('pjax:timeout', [xhr, options]))
166
+ xhr.abort('timeout')
167
+ }, settings.timeout)
168
+
169
+ // Clear timeout setting so jquerys internal timeout isn't invoked
170
+ settings.timeout = 0
171
+ }
172
+
173
+ xhr.setRequestHeader('X-PJAX', 'true')
174
+
175
+ var result
176
+
177
+ // DEPRECATED: Invoke original `beforeSend` handler
178
+ if (oldBeforeSend) {
179
+ result = oldBeforeSend.apply(this, arguments)
180
+ if (result === false) return false
181
+ }
182
+
183
+ if (!fire('pjax:beforeSend', [xhr, settings])) return false
184
+
185
+ fire('pjax:start', [xhr, options])
186
+ // start.pjax is deprecated
187
+ fire('start.pjax', [xhr, options])
188
+ }
189
+
190
+ options.complete = function(xhr, textStatus) {
191
+ if (timeoutTimer)
192
+ clearTimeout(timeoutTimer)
193
+
194
+ // DEPRECATED: Invoke original `complete` handler
195
+ if (oldComplete) oldComplete.apply(this, arguments)
196
+
197
+ fire('pjax:complete', [xhr, textStatus, options])
198
+
199
+ fire('pjax:end', [xhr, options])
200
+ // end.pjax is deprecated
201
+ fire('end.pjax', [xhr, options])
202
+ }
203
+
204
+ options.error = function(xhr, textStatus, errorThrown) {
205
+ var respUrl = xhr.getResponseHeader('X-PJAX-URL')
206
+ if (respUrl) url = stripPjaxParam(respUrl)
207
+
208
+ // DEPRECATED: Invoke original `error` handler
209
+ if (oldError) oldError.apply(this, arguments)
210
+
211
+ var allowed = fire('pjax:error', [xhr, textStatus, errorThrown, options])
212
+ if (textStatus !== 'abort' && allowed)
213
+ window.location = url
214
+ }
215
+
216
+ options.success = function(data, status, xhr) {
217
+ var respUrl = xhr.getResponseHeader('X-PJAX-URL')
218
+ if (respUrl) url = stripPjaxParam(respUrl)
219
+
220
+ var title, oldTitle = document.title
221
+
222
+ if ( options.fragment ) {
223
+ // If they specified a fragment, look for it in the response
224
+ // and pull it out.
225
+ var html = $('<html>').html(data)
226
+ var $fragment = html.find(options.fragment)
227
+ if ( $fragment.length ) {
228
+ this.html($fragment.contents())
229
+
230
+ // If there's a <title> tag in the response, use it as
231
+ // the page's title. Otherwise, look for data-title and title attributes.
232
+ title = html.find('title').text() || $fragment.attr('title') || $fragment.data('title')
233
+ } else {
234
+ return window.location = url
235
+ }
236
+ } else {
237
+ // If we got no data or an entire web page, go directly
238
+ // to the page and let normal error handling happen.
239
+ if ( !$.trim(data) || /<html/i.test(data) )
240
+ return window.location = url
241
+
242
+ this.html(data)
243
+
244
+ // If there's a <title> tag in the response, use it as
245
+ // the page's title.
246
+ title = this.find('title').remove().text()
247
+ }
248
+
249
+ if ( title ) document.title = $.trim(title)
250
+
251
+ var state = {
252
+ url: url,
253
+ pjax: this.selector,
254
+ fragment: options.fragment,
255
+ timeout: options.timeout
256
+ }
257
+
258
+ if ( options.replace ) {
259
+ pjax.active = true
260
+ window.history.replaceState(state, document.title, url)
261
+ } else if ( options.push ) {
262
+ // this extra replaceState before first push ensures good back
263
+ // button behavior
264
+ if ( !pjax.active ) {
265
+ window.history.replaceState($.extend({}, state, {url:null}), oldTitle)
266
+ pjax.active = true
267
+ }
268
+
269
+ window.history.pushState(state, document.title, url)
270
+ }
271
+
272
+ // Google Analytics support
273
+ if ( (options.replace || options.push) && window._gaq )
274
+ _gaq.push(['_trackPageview'])
275
+
276
+ // If the URL has a hash in it, make sure the browser
277
+ // knows to navigate to the hash.
278
+ if ( hash !== '' ) {
279
+ window.location.href = hash
280
+ }
281
+
282
+ // DEPRECATED: Invoke original `success` handler
283
+ if (oldSuccess) oldSuccess.apply(this, arguments)
284
+
285
+ fire('pjax:success', [data, status, xhr, options])
286
+ }
287
+
288
+
289
+ // Cancel the current request if we're already pjaxing
290
+ var xhr = pjax.xhr
291
+ if ( xhr && xhr.readyState < 4) {
292
+ xhr.onreadystatechange = $.noop
293
+ xhr.abort()
294
+ }
295
+
296
+ pjax.options = options
297
+ pjax.xhr = $.ajax(options)
298
+ $(document).trigger('pjax', [pjax.xhr, options])
299
+
300
+ return pjax.xhr
301
+ }
302
+
303
+
304
+ // Internal: Build options Object for arguments.
305
+ //
306
+ // For convenience the first parameter can be either the container or
307
+ // the options object.
308
+ //
309
+ // Examples
310
+ //
311
+ // optionsFor('#container')
312
+ // // => {container: '#container'}
313
+ //
314
+ // optionsFor('#container', {push: true})
315
+ // // => {container: '#container', push: true}
316
+ //
317
+ // optionsFor({container: '#container', push: true})
318
+ // // => {container: '#container', push: true}
319
+ //
320
+ // Returns options Object.
321
+ function optionsFor(container, options) {
322
+ // Both container and options
323
+ if ( container && options )
324
+ options.container = container
325
+
326
+ // First argument is options Object
327
+ else if ( $.isPlainObject(container) )
328
+ options = container
329
+
330
+ // Only container
331
+ else
332
+ options = {container: container}
333
+
334
+ // Find and validate container
335
+ if (options.container)
336
+ options.container = findContainerFor(options.container)
337
+
338
+ return options
339
+ }
340
+
341
+ // Internal: Find container element for a variety of inputs.
342
+ //
343
+ // Because we can't persist elements using the history API, we must be
344
+ // able to find a String selector that will consistently find the Element.
345
+ //
346
+ // container - A selector String, jQuery object, or DOM Element.
347
+ //
348
+ // Returns a jQuery object whose context is `document` and has a selector.
349
+ function findContainerFor(container) {
350
+ container = $(container)
351
+
352
+ if ( !container.length ) {
353
+ throw "no pjax container for " + container.selector
354
+ } else if ( container.selector !== '' && container.context === document ) {
355
+ return container
356
+ } else if ( container.attr('id') ) {
357
+ return $('#' + container.attr('id'))
358
+ } else {
359
+ throw "cant get selector for pjax container!"
360
+ }
361
+ }
362
+
363
+
364
+ pjax.defaults = {
365
+ timeout: 650,
366
+ push: true,
367
+ replace: false,
368
+ // We want the browser to maintain two separate internal caches: one for
369
+ // pjax'd partial page loads and one for normal page loads. Without
370
+ // adding this secret parameter, some browsers will often confuse the two.
371
+ data: { _pjax: true },
372
+ type: 'GET',
373
+ dataType: 'html'
374
+ }
375
+
376
+ // Export $.pjax.click
377
+ pjax.click = handleClick
378
+
379
+
380
+ // Used to detect initial (useless) popstate.
381
+ // If history.state exists, assume browser isn't going to fire initial popstate.
382
+ var popped = ('state' in window.history), initialURL = location.href
383
+
384
+
385
+ // popstate handler takes care of the back and forward buttons
386
+ //
387
+ // You probably shouldn't use pjax on pages with other pushState
388
+ // stuff yet.
389
+ $(window).bind('popstate', function(event){
390
+ // Ignore inital popstate that some browsers fire on page load
391
+ var initialPop = !popped && location.href == initialURL
392
+ popped = true
393
+ if ( initialPop ) return
394
+
395
+ var state = event.state
396
+
397
+ if ( state && state.pjax ) {
398
+ var container = state.pjax
399
+ if ( $(container+'').length )
400
+ $.pjax({
401
+ url: state.url || location.href,
402
+ fragment: state.fragment,
403
+ container: container,
404
+ push: false,
405
+ timeout: state.timeout
406
+ })
407
+ else
408
+ window.location = location.href
409
+ }
410
+ })
411
+
412
+
413
+ // Add the state property to jQuery's event object so we can use it in
414
+ // $(window).bind('popstate')
415
+ if ( $.inArray('state', $.event.props) < 0 )
416
+ $.event.props.push('state')
417
+
418
+
419
+ // Is pjax supported by this browser?
420
+ $.support.pjax =
421
+ window.history && window.history.pushState && window.history.replaceState
422
+ // pushState isn't reliable on iOS until 5.
423
+ && !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/)
424
+
425
+
426
+ // Fall back to normalcy for older browsers.
427
+ if ( !$.support.pjax ) {
428
+ $.pjax = function( options ) {
429
+ var url = $.isFunction(options.url) ? options.url() : options.url,
430
+ method = options.type ? options.type.toUpperCase() : 'GET'
431
+
432
+ var form = $('<form>', {
433
+ method: method === 'GET' ? 'GET' : 'POST',
434
+ action: url,
435
+ style: 'display:none'
436
+ })
437
+
438
+ if (method !== 'GET' && method !== 'POST') {
439
+ form.append($('<input>', {
440
+ type: 'hidden',
441
+ name: '_method',
442
+ value: method.toLowerCase()
443
+ }))
444
+ }
445
+
446
+ var data = options.data
447
+ if (typeof data === 'string') {
448
+ $.each(data.split('&'), function(index, value) {
449
+ var pair = value.split('=')
450
+ form.append($('<input>', {type: 'hidden', name: pair[0], value: pair[1]}))
451
+ })
452
+ } else if (typeof data === 'object') {
453
+ for (key in data)
454
+ form.append($('<input>', {type: 'hidden', name: key, value: data[key]}))
455
+ }
456
+
457
+ $(document.body).append(form)
458
+ form.submit()
459
+ }
460
+ $.pjax.click = $.noop
461
+ $.fn.pjax = function() { return this }
462
+ }
463
+
464
+ })(jQuery);
@@ -1,6 +1,7 @@
1
1
  //= require jquery
2
2
  //= require jquery_ujs
3
3
  //= require tinymce-jquery
4
+ //= require_tree .
4
5
 
5
6
  $(function() {
6
7
  $('.tinymce').tinymce({});
@@ -14,4 +15,10 @@ $(function() {
14
15
  $('#content_block_content').attr('aria-hidden', 'false');
15
16
  }
16
17
  })
18
+
19
+ $(".nav-select").change(function() {
20
+ window.location = $(this).find("option:selected").val();
21
+ });
22
+
23
+ $('a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])').pjax('.app-content', { timeout: 10000 });
17
24
  })
@@ -1,3 +1,7 @@
1
+ form {
2
+ margin-bottom: $base;
3
+ }
4
+
1
5
  label {
2
6
  display: block;
3
7
  margin-bottom: $base / 4;
@@ -5,8 +9,10 @@ label {
5
9
 
6
10
  input[type='text'],
7
11
  input[type='password'],
12
+ input[type='email'],
8
13
  textarea {
9
14
  width: $base * 14;
15
+ max-width: 100%;
10
16
  font-size: inherit;
11
17
  border: 1px solid #ccc;
12
18
  height: $base;
@@ -0,0 +1,37 @@
1
+ @media screen and (max-width: 640px) {
2
+ h1 {
3
+ display: inline-block;
4
+ margin-left: $base / 2;
5
+ margin-right: $base;
6
+ padding: 0;
7
+ border: none;
8
+ font-size: 100%;
9
+ line-height: $base;
10
+ text-align: left;
11
+ }
12
+
13
+ h2, h3 {
14
+ font-size: 100%;
15
+ }
16
+
17
+ .app-nav {
18
+ width: 100%;
19
+ height: $base;
20
+ padding: $base / 2;
21
+ @include box-shadow(0 2px 2px rgba(0,0,0,0.1));
22
+
23
+ nav { display: none; }
24
+
25
+ .nav-select {
26
+ position: absolute;
27
+ bottom: $base / 2;
28
+ right: $base * 2;
29
+ display: inline-block;
30
+ }
31
+ }
32
+
33
+ .app-content {
34
+ margin: 0;
35
+ margin-top: $base;
36
+ }
37
+ }
@@ -1,3 +1,5 @@
1
+ table { margin-bottom: $base; }
2
+
1
3
  thead {
2
4
  border: 1px solid darken(#36c, 13.5);
3
5
  border-bottom: none;
@@ -9,6 +9,8 @@ body {
9
9
  font: 100%/1.4285 'PT Sans';
10
10
  }
11
11
 
12
+ h1, h2, h3 { @include text-shadow(0 1px 0 white); }
13
+
12
14
  h1, h2 {
13
15
  margin-bottom: $base;
14
16
  font: 200% 'Oswald';
@@ -21,8 +23,16 @@ h1 {
21
23
  font: 200% 'Oswald';
22
24
  text-align: center;
23
25
  text-transform: uppercase;
26
+
27
+ a {
28
+ color: inherit;
29
+ text-decoration: none;
30
+ }
31
+ }
24
32
 
25
- /* &:after { content: ':'; } */
33
+ h3 {
34
+ font-size: 150%;
35
+ margin-bottom: 16px;
26
36
  }
27
37
 
28
38
  p {
@@ -59,9 +69,16 @@ strong, label { font-weight: bold; }
59
69
  }
60
70
  }
61
71
 
72
+ .app-nav .nav-select { display: none; }
73
+
62
74
  .app-content {
63
75
  margin-left: $base * 10;
64
76
  padding: $base * 2 $base;
77
+
78
+ ul {
79
+ margin-left: 1em;
80
+ list-style: disc;
81
+ }
65
82
  }
66
83
 
67
84
  .model-actions {
@@ -70,3 +87,4 @@ strong, label { font-weight: bold; }
70
87
 
71
88
  @import 'forms';
72
89
  @import 'tables';
90
+ @import 'response';
@@ -2,6 +2,8 @@
2
2
  class Manifest::ContentBlocksController < Manifest::ManifestController
3
3
  before_filter :authorize_admin, except: [:index, :edit, :update]
4
4
 
5
+ layout :set_layout
6
+
5
7
  def index
6
8
  @content_blocks = ContentBlock.all
7
9
  end
@@ -31,4 +31,12 @@ class Manifest::ManifestController < ApplicationController
31
31
  expire_page "/#{p.slug}.html"
32
32
  end
33
33
  end
34
+
35
+ def set_layout
36
+ if request.headers['X-PJAX']
37
+ false
38
+ else
39
+ 'manifest/manifest'
40
+ end
41
+ end
34
42
  end
@@ -2,6 +2,8 @@
2
2
  class Manifest::PagesController < Manifest::ManifestController
3
3
  before_filter :authorize_admin, except: [:index, :show]
4
4
 
5
+ layout :set_layout
6
+
5
7
  def index
6
8
  @pages = Page.all
7
9
  end
@@ -8,29 +8,46 @@
8
8
  <%= javascript_include_tag 'manifest/main' %>
9
9
  <%= csrf_meta_tags %>
10
10
 
11
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
12
+
11
13
  <!-- Google Web Fonts -->
12
14
  <link href='http://fonts.googleapis.com/css?family=Oswald|PT+Sans:400,700' rel='stylesheet' type='text/css'>
13
15
  </head>
14
16
  <body>
15
17
  <div class='app-nav'>
16
- <h1><%= Manifest.configuration.app_name %></h1>
18
+ <h1><%= link_to Manifest.configuration.app_name, manifest_path %></h1>
17
19
 
18
- <nav>
20
+ <nav class='list'>
19
21
  <ul>
20
- <li><%= link_to 'Pages', manifest_pages_path %></li>
21
- <li><%= link_to 'Content Blocks', manifest_content_blocks_path %></li>
22
+ <li><%= link_to 'Pages', manifest_pages_path, class: 'in-app-nav' %></li>
23
+ <li><%= link_to 'Content Blocks', manifest_content_blocks_path, class: 'in-app-nav' %></li>
22
24
 
23
25
  <% Manifest.configuration.data_types.each do |d| %>
24
- <li><%= link_to d[:nav_name], eval("#{d[:route]}") %></li>
26
+ <li><%= link_to d[:nav_name], eval("#{d[:route]}"), class: 'in-app-nav' %></li>
25
27
  <% end %>
26
28
 
27
- <li><%= link_to 'Visit Site', '/', target: '_blank' %></li>
28
- <li><%= link_to 'Log Out', manifest_logout_path %></li>
29
+ <li><%= link_to 'Visit Site', '/', target: '_blank', :"data-skip-pjax" => true %></li>
30
+ <li><%= link_to 'Log Out', manifest_logout_path, :"data-skip-pjax" => true %></li>
29
31
  </ul>
30
32
  </nav>
33
+
34
+ <select class='nav-select'>
35
+ <option value='' selected='selected'>Select</option>
36
+
37
+ <option value='<%= manifest_pages_path %>'>Pages</option>
38
+ <option value='<%= manifest_content_blocks_path %>'>Content Blocks</option>
39
+
40
+ <% Manifest.configuration.data_types.each do |d| %>
41
+ <option value='<%= eval("#{d[:route]}") %>'><%= d[:nav_name] %></option>
42
+ <% end %>
43
+
44
+ <option value='/'>Visit Site</option>
45
+ <option value='<%= manifest_logout_path %>'>Log Out</option>
46
+ </select>
31
47
  </div><!-- app-nav -->
32
48
 
33
49
  <div class='app-content'>
50
+ <div class='loader' style='display:none'>hi</div>
34
51
  <%= yield %>
35
52
  </div><!-- app-content -->
36
53
  </body>
@@ -8,6 +8,8 @@
8
8
  <%= stylesheet_link_tag 'manifest/main' %>
9
9
  <%= csrf_meta_tags %>
10
10
 
11
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
12
+
11
13
  <!-- Google Webfonts -->
12
14
  <link href='http://fonts.googleapis.com/css?family=Oswald|PT+Sans:400,700' rel='stylesheet' type='text/css'>
13
15
  </head>
@@ -36,3 +36,4 @@
36
36
  <% end %>
37
37
  <%= f.submit %>
38
38
  <% end %>
39
+
@@ -1,3 +1,5 @@
1
1
  <h2>Content Blocks: Edit &ldquo;<%= @content_block.title %>&rdquo;</h2>
2
2
 
3
3
  <%= render 'form' %>
4
+
5
+ <%= link_to 'Delete Content Block', [:manifest, @content_block], method: :delete, confirm: "Are you sure you want to delete content block #{@content_block.title}?" %>
@@ -11,12 +11,12 @@
11
11
 
12
12
  <tbody>
13
13
  <% @content_blocks.each do |c| %>
14
- <tr>
14
+ <%= content_tag_for(:tr, c) do %>
15
15
  <td><%= link_to c.title, edit_manifest_content_block_path(c) %></td>
16
16
  <td><%= link_to c.page.title, manifest_page_path(c.page) %></td>
17
17
  <td><%= c.created_at.to_s(:short) %></td>
18
18
  <td><%= c.updated_at.to_s(:short) %></td>
19
- </tr>
19
+ <% end %>
20
20
  <% end %>
21
21
  </tbody>
22
22
  </table>
@@ -1,3 +1,5 @@
1
1
  <h2>Pages: Edit &ldquo;<%= @page.title %>&rdquo;</h2>
2
2
 
3
3
  <%= render 'form' %>
4
+
5
+ <%= link_to 'Delete Page', manifest_page_path(@page), method: :delete, confirm: "Are you sure you want to delete page \"#{@page.title}\"?" %>
@@ -12,11 +12,11 @@
12
12
 
13
13
  <tbody>
14
14
  <% @page.content_blocks.each do |c| %>
15
- <tr>
15
+ <%= content_tag_for(:tr, c) do %>
16
16
  <td><%= link_to c.title, edit_manifest_content_block_path(c) %></td>
17
17
  <td><%= c.created_at.to_s(:short) %></td>
18
18
  <td><%= c.updated_at.to_s(:short) %></td>
19
- </tr>
19
+ <% end %>
20
20
  <% end %>
21
21
  </tbody>
22
22
  </table>
@@ -3,7 +3,7 @@
3
3
  <%= form_tag manifest_sessions_path, action: :create do %>
4
4
  <div class='field'>
5
5
  <%= label_tag :email %>
6
- <%= text_field_tag :email, params[:email] %>
6
+ <%= email_field_tag :email, params[:email] %>
7
7
  </div>
8
8
 
9
9
  <div class='field'>
@@ -1,5 +1,5 @@
1
1
  class Manifest::<%= ActiveSupport::Inflector.pluralize(name) %>Controller < Manifest::ManifestController
2
- layout 'manifest/manifest'
2
+ layout :set_layout
3
3
 
4
4
  # Add more actions to me!
5
5
 
@@ -19,7 +19,7 @@ class Manifest::<%= ActiveSupport::Inflector.pluralize(name) %>Controller < Mani
19
19
  @<%= name.underscore %> = <%= name %>.new(params[:<%= name.underscore %>])
20
20
 
21
21
  if @<%= name.underscore %>.save
22
- redirect_to manifest_<%= name.underscore %>_path(@<%= name.underscore %>)
22
+ redirect_to manifest_<%= plural_name.underscore %>_path(@<%= name.underscore %>)
23
23
  else
24
24
  render 'new'
25
25
  end
@@ -1,3 +1,5 @@
1
1
  <h2><%= ActiveSupport::Inflector.pluralize(name) %>: Edit</h2>
2
2
 
3
3
  <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Delete <%= name %>', [:manifest, @<%= name.underscore %>], method: :delete, confirm: "Are you sure you want to delete this <%= name.underscore %>?" %>
@@ -1,4 +1,24 @@
1
- <h2><%= ActiveSupport::Inflector.pluralize(name) %></h2>
1
+ <h2><%= table_name %></h2>
2
+
3
+ <%% if @<%= table_name %>.count > 0 %>
4
+ <table>
5
+ <thead>
6
+ <% attributes.each do |attribute| -%>
7
+ <th><%= attribute.name.humanize %></th>
8
+ <% end -%>
9
+ </thead>
10
+
11
+ <tbody>
12
+ <%% @<%= table_name %>.each do |<%= table_name[0] %>| %>
13
+ <%%= content_tag_for(:tr, <%= table_name[0] %>) do %>
14
+ <% attributes.each do |attribute| -%>
15
+ <td><%%= <%= table_name[0] %>.<%= attribute.name %> %></td>
16
+ <% end -%>
17
+ <%% end %>
18
+ <%% end %>
19
+ </tbody>
20
+ </table>
21
+ <%% end %>
2
22
 
3
23
  <div class='model-actions'>
4
24
  <%%= link_to 'New <%= name %>', new_manifest_<%= name.underscore %>_path %>
@@ -34,5 +34,21 @@ class Manifest::InstallGenerator < ActiveRecord::Generators::Base
34
34
  def create_public_layout
35
35
  create_file 'app/views/layouts/public.html.erb'
36
36
  end
37
+
38
+ def require_manifest_in_application_rb
39
+ application_file = "#{Rails.root}/config/application.rb"
40
+
41
+ File.open(application_file, 'r') do |f|
42
+ sentinel = /Bundler.require/
43
+ inject_into_file application_file, "require 'manifest'\n\n", before: sentinel
44
+ end
45
+ end
46
+
47
+ def inject_assets_for_precompiling_in_application_rb
48
+ line = " config.assets.precompile += ['manifest/main.css', 'manifest/sessions.css', 'manifest/main.js']\n"
49
+ application_file = "#{Rails.root}/config/application.rb"
50
+ sentinel = /^ {2}end\nend/
51
+ inject_into_file application_file, line, before: sentinel
52
+ end
37
53
  end
38
54
 
@@ -1,3 +1,3 @@
1
1
  module Manifest
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manifest-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-07 00:00:00.000000000 Z
12
+ date: 2012-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70330392459720 !ruby/object:Gem::Requirement
16
+ requirement: &70249382834960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70330392459720
24
+ version_requirements: *70249382834960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: friendly_id
27
- requirement: &70330392458920 !ruby/object:Gem::Requirement
27
+ requirement: &70249382832000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70330392458920
35
+ version_requirements: *70249382832000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sass-rails
38
- requirement: &70330392458240 !ruby/object:Gem::Requirement
38
+ requirement: &70249382826500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.2.3
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70330392458240
46
+ version_requirements: *70249382826500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: compass-rails
49
- requirement: &70330392457720 !ruby/object:Gem::Requirement
49
+ requirement: &70249382819940 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70330392457720
57
+ version_requirements: *70249382819940
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bcrypt-ruby
60
- requirement: &70330392457100 !ruby/object:Gem::Requirement
60
+ requirement: &70249382817700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 3.0.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70330392457100
68
+ version_requirements: *70249382817700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tinymce-rails
71
- requirement: &70330392456560 !ruby/object:Gem::Requirement
71
+ requirement: &70249382814620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70330392456560
79
+ version_requirements: *70249382814620
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sqlite3
82
- requirement: &70330392456040 !ruby/object:Gem::Requirement
82
+ requirement: &70249382809060 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70330392456040
90
+ version_requirements: *70249382809060
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec-rails
93
- requirement: &70330392455540 !ruby/object:Gem::Requirement
93
+ requirement: &70249382807680 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70330392455540
101
+ version_requirements: *70249382807680
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: factory_girl_rails
104
- requirement: &70330392455060 !ruby/object:Gem::Requirement
104
+ requirement: &70249382806580 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70330392455060
112
+ version_requirements: *70249382806580
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: yard
115
- requirement: &70330392454580 !ruby/object:Gem::Requirement
115
+ requirement: &70249382805560 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,18 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70330392454580
123
+ version_requirements: *70249382805560
124
+ - !ruby/object:Gem::Dependency
125
+ name: rake
126
+ requirement: &70249382803560 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *70249382803560
124
135
  description: Manifest allows for the creation of simple content management with support
125
136
  for easy custom data types. It attempts to preserve the Rails way of working where
126
137
  possible.
@@ -130,8 +141,10 @@ executables: []
130
141
  extensions: []
131
142
  extra_rdoc_files: []
132
143
  files:
144
+ - app/assets/javascripts/manifest/jquery.pjax.js
133
145
  - app/assets/javascripts/manifest/main.js
134
146
  - app/assets/stylesheets/manifest/_forms.css.scss
147
+ - app/assets/stylesheets/manifest/_response.css.scss
135
148
  - app/assets/stylesheets/manifest/_tables.css.scss
136
149
  - app/assets/stylesheets/manifest/main.css.scss
137
150
  - app/assets/stylesheets/manifest/sessions.css.scss
@@ -201,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
214
  version: '0'
202
215
  segments:
203
216
  - 0
204
- hash: 1014662028778785223
217
+ hash: -4299190707462071805
205
218
  required_rubygems_version: !ruby/object:Gem::Requirement
206
219
  none: false
207
220
  requirements:
@@ -210,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
223
  version: '0'
211
224
  segments:
212
225
  - 0
213
- hash: 1014662028778785223
226
+ hash: -4299190707462071805
214
227
  requirements: []
215
228
  rubyforge_project:
216
229
  rubygems_version: 1.8.17