storytime 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/Gemfile.lock +238 -185
  4. data/README.md +21 -21
  5. data/app/assets/javascripts/storytime/application.js +5 -3
  6. data/app/assets/javascripts/storytime/base.js.coffee +5 -4
  7. data/app/assets/javascripts/storytime/media.js.coffee +7 -2
  8. data/app/assets/javascripts/storytime/{users.js.coffee → memberships.js.coffee} +3 -4
  9. data/app/assets/javascripts/storytime/navigations.js.coffee +7 -0
  10. data/app/assets/javascripts/storytime/wysiwyg.js.coffee +23 -11
  11. data/app/assets/stylesheets/storytime/application.scss +2 -1
  12. data/app/assets/stylesheets/storytime/dashboard_overrides.scss +4 -0
  13. data/app/assets/stylesheets/storytime/media.scss +2 -0
  14. data/app/assets/stylesheets/storytime/navigation.scss +7 -0
  15. data/app/assets/stylesheets/storytime/posts.scss +70 -61
  16. data/app/controllers/storytime/application_controller.rb +8 -7
  17. data/app/controllers/storytime/blogs_controller.rb +10 -5
  18. data/app/controllers/storytime/dashboard/blogs_controller.rb +0 -1
  19. data/app/controllers/storytime/dashboard/custom_posts_controller.rb +1 -1
  20. data/app/controllers/storytime/dashboard/links_controller.rb +16 -0
  21. data/app/controllers/storytime/dashboard/memberships_controller.rb +56 -6
  22. data/app/controllers/storytime/dashboard/navigations_controller.rb +66 -0
  23. data/app/controllers/storytime/dashboard/pages_controller.rb +7 -3
  24. data/app/controllers/storytime/dashboard/posts_controller.rb +7 -5
  25. data/app/controllers/storytime/dashboard/sites_controller.rb +1 -1
  26. data/app/controllers/storytime/dashboard_controller.rb +3 -3
  27. data/app/controllers/storytime/pages_controller.rb +3 -3
  28. data/app/helpers/storytime/application_helper.rb +9 -1
  29. data/app/models/concerns/storytime/scoped_to_site.rb +5 -3
  30. data/app/models/storytime/blog.rb +0 -1
  31. data/app/models/storytime/link.rb +22 -0
  32. data/app/models/storytime/membership.rb +2 -0
  33. data/app/models/storytime/navigation.rb +19 -0
  34. data/app/models/storytime/post.rb +8 -4
  35. data/app/models/storytime/site.rb +3 -2
  36. data/app/policies/storytime/membership_policy.rb +13 -1
  37. data/app/policies/storytime/snippet_policy.rb +5 -1
  38. data/app/views/layouts/storytime/dashboard.html.erb +2 -1
  39. data/app/views/storytime/application/storytime/_header.html.erb +1 -0
  40. data/app/views/storytime/blogs/_tags.html.erb +1 -1
  41. data/app/views/storytime/blogs/show.html.erb +1 -1
  42. data/app/views/storytime/dashboard/_navigation.html.erb +12 -8
  43. data/app/views/storytime/dashboard/_settings_tabs.html.erb +1 -1
  44. data/app/views/storytime/dashboard/blog_posts/edit.html.erb +1 -1
  45. data/app/views/storytime/dashboard/blog_posts/new.html.erb +1 -1
  46. data/app/views/storytime/dashboard/blogs/_blog.html.erb +1 -1
  47. data/app/views/storytime/dashboard/media/_gallery.html.erb +12 -11
  48. data/app/views/storytime/dashboard/{users → memberships}/_edit.html.erb +6 -7
  49. data/app/views/storytime/dashboard/memberships/_index.html.erb +1 -1
  50. data/app/views/storytime/dashboard/memberships/_membership.html.erb +1 -1
  51. data/app/views/storytime/dashboard/{users → memberships}/_new.html.erb +3 -3
  52. data/app/views/storytime/dashboard/memberships/edit.json.jbuilder +2 -0
  53. data/app/views/storytime/dashboard/memberships/new.json.jbuilder +2 -0
  54. data/app/views/storytime/dashboard/memberships/save.json.jbuilder +1 -1
  55. data/app/views/storytime/dashboard/navigations/_blog_link_fields.html.erb +8 -0
  56. data/app/views/storytime/dashboard/navigations/_external_link_fields.html.erb +7 -0
  57. data/app/views/storytime/dashboard/navigations/_form.html.erb +58 -0
  58. data/app/views/storytime/dashboard/navigations/_navigation.html.erb +25 -0
  59. data/app/views/storytime/dashboard/navigations/_page_link_fields.html.erb +8 -0
  60. data/app/views/storytime/dashboard/navigations/edit.html.erb +1 -0
  61. data/app/views/storytime/dashboard/navigations/index.html.erb +15 -0
  62. data/app/views/storytime/dashboard/navigations/new.html.erb +1 -0
  63. data/app/views/storytime/dashboard/pages/edit.html.erb +1 -1
  64. data/app/views/storytime/dashboard/pages/new.html.erb +1 -1
  65. data/app/views/storytime/dashboard/posts/_image_toolbar.html.erb +4 -1
  66. data/app/views/storytime/dashboard/posts/_list.html.erb +10 -8
  67. data/app/views/storytime/dashboard/posts/edit.html.erb +1 -1
  68. data/app/views/storytime/dashboard/posts/index.html.erb +16 -5
  69. data/app/views/storytime/dashboard/posts/new.html.erb +1 -1
  70. data/app/views/storytime/navigations/_navigation.html.erb +3 -0
  71. data/app/views/storytime/posts/_post.html.erb +1 -1
  72. data/app/views/storytime/posts/_tags.html.erb +1 -1
  73. data/app/views/storytime/sites/_google_analytics_code.html.erb +4 -3
  74. data/app/views/storytime/snippets/_snippet.html.erb +1 -1
  75. data/config/initializers/assets.rb +1 -1
  76. data/config/initializers/storytime_admin.rb +2 -0
  77. data/config/initializers/url_for_patch.rb +6 -6
  78. data/config/locales/en.yml +18 -0
  79. data/config/routes.rb +11 -10
  80. data/db/migrate/20141021073356_create_storytime_snippets.rb +1 -1
  81. data/db/migrate/20150520181115_create_storytime_navigations.rb +12 -0
  82. data/db/migrate/20150520185227_create_storytime_links.rb +11 -0
  83. data/db/migrate/20150520190700_add_position_to_storytime_links.rb +6 -0
  84. data/db/migrate/20150529192058_add_url_to_storytime_links.rb +5 -0
  85. data/lib/generators/storytime/views_generator.rb +2 -3
  86. data/lib/generators/templates/storytime.rb +22 -15
  87. data/lib/storytime/concerns/current_site.rb +1 -1
  88. data/lib/storytime/concerns/has_versions.rb +8 -8
  89. data/lib/storytime/constraints/page_constraint.rb +2 -2
  90. data/lib/storytime/engine.rb +2 -0
  91. data/lib/storytime/storytime_helpers.rb +7 -5
  92. data/lib/storytime/version.rb +1 -1
  93. data/lib/storytime.rb +29 -11
  94. data/spec/controllers/dashboard_controller_spec.rb +4 -4
  95. data/spec/dummy/config/environments/test.rb +1 -1
  96. data/spec/dummy/db/schema.rb +61 -35
  97. data/spec/factories/navigation_factories.rb +6 -0
  98. data/spec/features/blogs_spec.rb +2 -2
  99. data/spec/features/comments_spec.rb +4 -4
  100. data/spec/features/dashboard/media_spec.rb +7 -7
  101. data/spec/features/dashboard/memberships_spec.rb +62 -4
  102. data/spec/features/dashboard/navigations_spec.rb +33 -0
  103. data/spec/features/dashboard/pages_spec.rb +26 -16
  104. data/spec/features/dashboard/posts_spec.rb +65 -15
  105. data/spec/features/dashboard/sites_spec.rb +5 -5
  106. data/spec/features/dashboard/snippets_spec.rb +5 -5
  107. data/spec/features/dashboard/subscription_spec.rb +5 -5
  108. data/spec/features/pages_spec.rb +3 -3
  109. data/spec/features/posts_spec.rb +1 -1
  110. data/spec/features/subscription_spec.rb +2 -2
  111. data/spec/lib/storytime_helpers_spec.rb +37 -0
  112. data/spec/models/navigation_spec.rb +21 -0
  113. data/spec/requests/routings_spec.rb +8 -8
  114. data/spec/spec_helper.rb +5 -5
  115. data/spec/support/feature_macros.rb +1 -1
  116. data/storytime.gemspec +6 -4
  117. metadata +69 -23
  118. data/app/views/storytime/dashboard/users/edit.json.jbuilder +0 -2
  119. data/app/views/storytime/dashboard/users/new.json.jbuilder +0 -2
  120. data/screenshots/admin.png +0 -0
  121. data/screenshots/media.png +0 -0
  122. data/screenshots/page-list.png +0 -0
  123. data/screenshots/post-editor.png +0 -0
  124. data/screenshots/site-settings.png +0 -0
  125. data/screenshots/text-snippets.png +0 -0
  126. data/screenshots/user-management.png +0 -0
  127. data/spec/features/dashboard/users_spec.rb +0 -66
@@ -1,4 +1,4 @@
1
- <%= simple_form_for @user.becomes(Storytime.user_class), :url => dashboard_user_path, remote: true, html: { class: "storytime-modal-form", data: { redirect: "index" } } do |f| %>
1
+ <%= simple_form_for @membership, :url => dashboard_membership_path, remote: true, html: { class: "storytime-modal-form", data: { redirect: "index" } } do |f| %>
2
2
  <div class="scroll-panel">
3
3
  <div class="scroll-panel-header">
4
4
  <%= link_to icon("angle-left"), [:dashboard, :memberships], class: "btn btn-sm btn-default pull-left storytime-modal-trigger", remote: true %>
@@ -14,13 +14,12 @@
14
14
  <input type="hidden" value="<%= params[:controller].camelize %>" id="storytime-modal-controller">
15
15
  <input type="hidden" value="<%= params[:action].camelize %>" id="storytime-modal-action">
16
16
 
17
- <%= f.input :storytime_name %>
18
- <%= f.input :email %>
19
-
20
- <%= f.simple_fields_for :storytime_memberships do |mf| %>
21
- <%= mf.association :storytime_role, include_blank: false, label_method: :label, input_html: { disabled: @user == @current_storytime_site.creator } %>
22
- <%= mf.input :_destroy, as: :boolean, label: "Delete membership" unless @user == @current_storytime_site.creator %>
17
+ <%= f.simple_fields_for :user do |uf| %>
18
+ <%= uf.input :storytime_name %>
19
+ <%= uf.input :email %>
23
20
  <% end %>
21
+
22
+ <%= f.association :storytime_role, include_blank: false, label_method: :label, input_html: { disabled: @user == @current_storytime_site.creator } %>
24
23
  </div>
25
24
  </div>
26
25
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <div class="scroll-panel">
2
2
  <div class="scroll-panel-header">
3
3
  <button type="button" class="close pull-left" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
4
- <%= link_to t('dashboard.users.create_new_user'), new_dashboard_user_path, class: "btn btn-sm btn-primary btn-outline pull-right storytime-modal-trigger", remote: true, id: "new-user-link" %>
4
+ <%= link_to t('dashboard.users.create_new_user'), new_dashboard_membership_path, class: "btn btn-sm btn-primary btn-outline pull-right storytime-modal-trigger", remote: true, id: "new-user-link" %>
5
5
  <h3 class="scroll-panel-title">
6
6
  <%= t('dashboard.users.users_header') %>
7
7
  </h3>
@@ -1,5 +1,5 @@
1
1
  <li class="list-group-item" id="membership_<%= membership.id %>">
2
- <%= link_to url_for(:controller => 'dashboard/users', :action => 'edit', :id => membership.user_id), class: "list-group-link storytime-modal-trigger", remote: true do %>
2
+ <%= link_to url_for(:controller => 'dashboard/memberships', :action => 'edit', :id => membership.id), class: "list-group-link storytime-modal-trigger", remote: true do %>
3
3
 
4
4
  <%= membership.storytime_name %>
5
5
  <% if membership.storytime_role %>
@@ -1,4 +1,4 @@
1
- <%= simple_form_for @user, :url => dashboard_users_path, method: :post, remote: true, html: { class: "storytime-modal-form", data: { redirect: "index" } } do |f| %>
1
+ <%= simple_form_for @user, :url => dashboard_memberships_path, method: :post, remote: true, html: { class: "storytime-modal-form", data: { redirect: "index" } } do |f| %>
2
2
  <div class="scroll-panel">
3
3
  <div class="scroll-panel-header">
4
4
  <%= link_to icon("angle-left"), [:dashboard, :memberships], class: "btn btn-sm btn-default pull-left storytime-modal-trigger", remote: true %>
@@ -10,7 +10,7 @@
10
10
  <div class="scroll-panel-body">
11
11
 
12
12
  <%= render 'storytime/dashboard/settings_tabs.html.erb' %>
13
-
13
+
14
14
  <%= f.input :storytime_name %>
15
15
  <%= f.input :email %>
16
16
 
@@ -19,7 +19,7 @@
19
19
  <% end %>
20
20
 
21
21
  <%= f.input :password %>
22
- <%= f.input :password_confirmation %>
22
+ <%= f.input :password_confirmation %>
23
23
  </div>
24
24
  </div>
25
25
  <% end %>
@@ -0,0 +1,2 @@
1
+ json.(@membership)
2
+ json.html(render partial: "edit.html.erb")
@@ -0,0 +1,2 @@
1
+ json.(@membership)
2
+ json.html(render partial: "new.html.erb")
@@ -1 +1 @@
1
- json.html(render partial: "storytime/dashboard/users/index.html.erb")
1
+ json.html(render partial: "storytime/dashboard/memberships/index.html.erb")
@@ -0,0 +1,8 @@
1
+ <tr class="nested-fields">
2
+ <td><%= f.input :text, placeholder: "Link text", label: false, wrapper_html: { class: "no-margin" }, input_html: { class: "input-sm" } %></td>
3
+ <td>
4
+ <%= f.input :linkable_type, as: :hidden, input_html: { value: "Storytime::Blog" } %>
5
+ <%= f.association :linkable, label: false, wrapper_html: { class: "no-margin" }, input_html: { class: "input-sm" }, collection: Storytime::Post.where(type: "Storytime::Blog").all, prompt: "Select a Blog" %>
6
+ </td>
7
+ <td><%= link_to_remove_association icon("trash"), f, class: "btn btn-default btn-sm pull-right" %></td>
8
+ </tr>
@@ -0,0 +1,7 @@
1
+ <tr class="nested-fields">
2
+ <td><%= f.input :text, placeholder: "Link text", label: false, input_html: { class: "input-sm" }, wrapper_html: { class: "no-margin" } %></td>
3
+ <td>
4
+ <%= f.input :url, placeholder: "URL", label: false, input_html: { class: "input-sm" }, wrapper_html: { class: "no-margin" } %>
5
+ </td>
6
+ <td><%= link_to_remove_association icon("trash"), f, class: "btn btn-default btn-sm pull-right" %></td>
7
+ </tr>
@@ -0,0 +1,58 @@
1
+ <div id="main">
2
+ <div class="scroll-panel">
3
+ <%= simple_form_for [storytime, :dashboard, @navigation] do |f| %>
4
+ <div class="scroll-panel-header">
5
+ <%= link_to "#", class: "btn btn-default btn-icon pull-left visible-xs visible-sm", data: { toggle: "off-canvas", target: "#dashboard-nav" } do %>
6
+ <i class="icon-st-icons-st-logo"></i>
7
+ <% end %>
8
+ <div class="pull-right">
9
+ <%= link_to "Cancel", [storytime, :dashboard, Storytime::Navigation], class: "btn btn-primary btn-sm btn-outline" %>
10
+ <%= f.submit "Save", class: "btn btn-sm btn-primary btn-outline" %>
11
+ </div>
12
+ <h3 class="scroll-panel-title"><%= header %></h3>
13
+ </div>
14
+ <div class="scroll-panel-body">
15
+ <div class="row">
16
+ <div class="col-sm-6">
17
+ <%= f.input :name %>
18
+ </div>
19
+ <div class="col-sm-6">
20
+ <%= f.input :handle, disabled: @navigation.persisted? %>
21
+ </div>
22
+ </div>
23
+
24
+ <div>
25
+ <table class="table">
26
+ <thead>
27
+ <tr>
28
+ <th style="width: 40%;">Link Text</th>
29
+ <th style="width: 40%;">Link</th>
30
+ <th></th>
31
+ </tr>
32
+ </thead>
33
+ <tbody id="links">
34
+ <%= f.simple_fields_for :links do |link| %>
35
+ <% if link.object.url.present? || link.object.errors[:url].present? %>
36
+ <%= render "external_link_fields", f: link %>
37
+ <% else %>
38
+ <%= render "#{link.object.linkable.type.split("::").last.downcase}_link_fields", f: link %>
39
+ <% end %>
40
+ <% end %>
41
+ </tbody>
42
+ </table>
43
+ <div class="btn-group">
44
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
45
+ Add a Link <span class="caret"></span>
46
+ </button>
47
+ <ul class="dropdown-menu left" role="menu">
48
+ <li><%= link_to_add_association "Page Link", f, :links, partial: "page_link_fields", :"data-association-insertion-node" => "#links", :"data-association-insertion-method" => "append" %></li>
49
+ <li><%= link_to_add_association "Blog Link", f, :links, partial: "blog_link_fields", :"data-association-insertion-node" => "#links", :"data-association-insertion-method" => "append" %></li>
50
+ <li><%= link_to_add_association "External Link", f, :links, partial: "external_link_fields", :"data-association-insertion-node" => "#links", :"data-association-insertion-method" => "append" %></li>
51
+ </ul>
52
+ </div>
53
+
54
+ </div>
55
+ </div>
56
+ <% end %>
57
+ </div>
58
+ </div>
@@ -0,0 +1,25 @@
1
+ <div class="panel panel-default" id="navigation_<%= navigation.id %>">
2
+ <div class="panel-heading">
3
+ <div class="row">
4
+ <div class="col-xs-8">
5
+ <h3 class="panel-title">
6
+ <%= navigation.name %>
7
+ </h3>
8
+ </div>
9
+ <div class="col-xs-4 text-right">
10
+ <%= link_to "Edit", [storytime, :edit, :dashboard, navigation], class: "btn btn-default btn-xs" %>
11
+ <%= delete_resource_link navigation, dashboard_navigation_url(navigation) %>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ <div class="panel-body">
16
+ <ul class="list-group sortable no-margin" data-update-url="<%= sort_dashboard_navigation_links_url(navigation) %>">
17
+ <% navigation.links.each do |link| %>
18
+ <%= content_tag_for :li, link, class: "list-group-item" do %>
19
+ <%= icon "bars", style: "cursor: move; margin-right: 10px;" %>
20
+ <%= link.text %>
21
+ <% end %>
22
+ <% end %>
23
+ </ul>
24
+ </div>
25
+ </div>
@@ -0,0 +1,8 @@
1
+ <tr class="nested-fields">
2
+ <td><%= f.input :text, label: false, placeholder: "Link text", wrapper_html: { class: "no-margin" }, input_html: { class: "input-sm" } %></td>
3
+ <td>
4
+ <%= f.input :linkable_type, as: :hidden, input_html: { value: "Storytime::Page" } %>
5
+ <%= f.association :linkable, label: false, wrapper_html: { class: "no-margin" }, input_html: { class: "input-sm" }, collection: Storytime::Post.where(type: "Storytime::Page").all, prompt: "Select a Page" %>
6
+ </td>
7
+ <td><%= link_to_remove_association icon("trash"), f, class: "btn btn-default btn-sm pull-right" %></td>
8
+ </tr>
@@ -0,0 +1 @@
1
+ <%= render "form", header: t('.header') %>
@@ -0,0 +1,15 @@
1
+ <div id="main">
2
+ <div class="scroll-panel">
3
+ <div class="scroll-panel-header">
4
+
5
+ <%= link_to "#", class: "btn btn-default btn-icon pull-left visible-xs visible-sm", data: { toggle: "off-canvas", target: "#dashboard-nav" } do %>
6
+ <i class="icon-st-icons-st-logo"></i>
7
+ <% end %>
8
+ <%= link_to "New Navigation List", [storytime, :new, :dashboard, :navigation], class: "btn btn-sm btn-primary btn-outline pull-right" %>
9
+ <h3 class="scroll-panel-title"><%= t('.header') %></h3>
10
+ </div>
11
+ <div class="scroll-panel-body">
12
+ <%= render partial: "storytime/dashboard/navigations/navigation", collection: @navigations, as: :navigation %>
13
+ </div>
14
+ </div>
15
+ </div>
@@ -0,0 +1 @@
1
+ <%= render "form", header: t('.header') %>
@@ -41,7 +41,7 @@
41
41
  <%= link_to (@post.published? ? "Update" : "Save / Publish"), "#", class: 'btn btn-primary btn-sm btn-outline', data: { toggle: 'collapse', target: '#post-advanced-settings' }, id: "advanced-settings-panel-toggle" %>
42
42
  </div>
43
43
  </div>
44
- <%= render 'image_toolbar' %>
44
+ <%= render 'storytime/dashboard/posts/image_toolbar' %>
45
45
  <div class="scroll-panel-body" style="top: 130px;" data-top="130px">
46
46
  <%= render 'form' %>
47
47
  </div>
@@ -20,7 +20,7 @@
20
20
  <%= link_to "Save / Publish", "#", class: 'btn btn-primary btn-sm btn-outline', data: { toggle: 'collapse', target: '#post-advanced-settings' } %>
21
21
  </div>
22
22
  </div>
23
- <%= render 'image_toolbar' %>
23
+ <%= render 'storytime/dashboard/posts/image_toolbar' %>
24
24
  <div class="scroll-panel-body" style="top: 130px;" data-top="130px">
25
25
  <%= render "form" %>
26
26
  </div>
@@ -9,13 +9,16 @@
9
9
  </div>
10
10
  <div class='medium-image-controls'>
11
11
  <div class='row'>
12
+ <div class='col-xs-3'>
13
+ <input type='text' id='medium-image-caption' placeholder='Caption' class='form-control input-sm' />
14
+ </div>
12
15
  <div class='col-xs-3'>
13
16
  <input type='text' id='medium-image-width' placeholder='Width' class='form-control input-sm' />
14
17
  </div>
15
18
  <div class='col-xs-3'>
16
19
  <input type='text' id='medium-image-height' placeholder='Height' class='form-control input-sm' />
17
20
  </div>
18
- <div class='col-xs-6'>
21
+ <div class='col-xs-3'>
19
22
  <div class='btn-group btn-group-sm'>
20
23
  <a href='#' class='btn btn-default medium-image-float' data-float='left'><i class='fa fa-align-left'></i></a>
21
24
  <a href='#' class='btn btn-default medium-image-float' data-float='none'><i class='fa fa-align-justify'></i></a>
@@ -1,6 +1,6 @@
1
- <div class="list-group">
2
- <% @posts.each do |post| %>
3
- <%= link_to [:edit, :dashboard, post], id: "#{post.class.to_s.downcase.split("::").last}_#{post.id}", class: "list-group-item" do %>
1
+ <% @posts.each do |post| %>
2
+ <li class="list-group-item" id="<%= post.class.to_s.downcase.split("::").last %>_<%= post.id %>">
3
+ <%= link_to [:edit, :dashboard, post], id: "", class: "list-group-link" do %>
4
4
  <div class="row">
5
5
  <div class="col-md-8">
6
6
  <h4><%= post.title %></h4>
@@ -11,14 +11,16 @@
11
11
  <% if post.published? && post.published_at <= Time.now %>
12
12
  Published <%= time_ago_in_words post.published_at %> ago
13
13
  <% elsif post.published? %>
14
+ <span class="label label-warning">Draft</span>
14
15
  Scheduled to publish on <%= post.published_at.strftime("%B %e at %l:%M %p") %>
15
16
  <% else %>
17
+ <span class="label label-warning">Draft</span>
16
18
  Last edited <%= time_ago_in_words post.updated_at %> ago
17
19
  <% end %>
18
20
  </p>
19
21
  <% end %>
20
- <% end %>
21
- </div>
22
- <div class="pagination-wrapper">
23
- <%= paginate @posts, param_name: "page_number" %>
24
- </div>
22
+ <div class="list-group-actions">
23
+ <%= delete_resource_link post, [:dashboard, post] %>
24
+ </div>
25
+ </li>
26
+ <% end %>
@@ -53,7 +53,7 @@
53
53
  <%= link_to (@post.published? ? "Update" : "Save / Publish"), "#", class: 'btn btn-primary btn-sm btn-outline', data: { toggle: 'collapse', target: '#post-advanced-settings' }, id: "advanced-settings-panel-toggle" %>
54
54
  </div>
55
55
  </div>
56
- <%= render 'image_toolbar' %>
56
+ <%= render 'storytime/dashboard/posts/image_toolbar' %>
57
57
  <div class="scroll-panel-body" style="top: 130px;">
58
58
  <%= render 'form' %>
59
59
  </div>
@@ -40,11 +40,18 @@
40
40
  </div>
41
41
  <div class="scroll-panel-body">
42
42
  <ul class="nav nav-tabs">
43
- <li role="presentation" class="<%= 'active' unless params[:published] == 'true' %>">
43
+ <li role="presentation" class="<%= 'active' unless (params[:published] == 'true' || params[:draft] == 'true') %>">
44
44
  <% if @blog %>
45
- <%= link_to "Drafts", [:dashboard, @blog, :blog_page_post_index, published: nil] %>
45
+ <%= link_to "All", [:dashboard, @blog, :blog_page_post_index, published: nil, draft: nil] %>
46
46
  <% else %>
47
- <%= link_to "Drafts", [:dashboard, current_post_type] %>
47
+ <%= link_to "All", [:dashboard, current_post_type, published: nil, draft: nil] %>
48
+ <% end %>
49
+ </li>
50
+ <li role="presentation" class="<%= 'active' if params[:draft] == 'true' %>">
51
+ <% if @blog %>
52
+ <%= link_to "Drafts", [:dashboard, @blog, :blog_page_post_index, published: nil, draft: true] %>
53
+ <% else %>
54
+ <%= link_to "Drafts", [:dashboard, current_post_type, draft: true] %>
48
55
  <% end %>
49
56
  </li>
50
57
  <li role="presentation" class="<%= 'active' if params[:published] == 'true' %>">
@@ -53,10 +60,14 @@
53
60
  <% else %>
54
61
  <%= link_to "Published", [:dashboard, current_post_type, published: 'true'] %>
55
62
  <% end %>
56
-
57
63
  </li>
58
64
  </ul>
59
- <%= render 'list' %>
65
+ <ul class="list-group list-group-button-links">
66
+ <%= render 'list' %>
67
+ </ul>
68
+ <div class="pagination-wrapper">
69
+ <%= paginate @posts, param_name: "page_number" %>
70
+ </div>
60
71
  </div>
61
72
  </div>
62
73
  </div>
@@ -25,7 +25,7 @@
25
25
  <%= link_to "Save / Publish", "#", class: 'btn btn-primary btn-sm btn-outline', data: { toggle: 'collapse', target: '#post-advanced-settings' } %>
26
26
  </div>
27
27
  </div>
28
- <%= render 'image_toolbar' %>
28
+ <%= render 'storytime/dashboard/posts/image_toolbar' %>
29
29
  <div class="scroll-panel-body" style="top: 130px;" data-top="130px">
30
30
  <%= render "form" %>
31
31
  </div>
@@ -0,0 +1,3 @@
1
+ <% navigation.links.each do |link| %>
2
+ <li><%= link_to link.text, (link.url.present? ? link.url : storytime.page_path(link.linkable)) %></li>
3
+ <% end %>
@@ -1,6 +1,6 @@
1
1
  <div id="blog_post_<%= post.id %>" class="blog-post">
2
2
  <h2><%= link_to post.title, storytime.post_path(post) %></h2>
3
- <p class='muted'><%= post.created_at.strftime("%b %d, %Y") %></p>
3
+ <p class='muted'><%= post.published_at.strftime("%b %d, %Y") %></p>
4
4
  <p><%= post.excerpt %></p>
5
5
  <p><%= link_to "Continue reading →", storytime.post_path(post) %></p>
6
6
  <p><%= render 'storytime/posts/tags', post: post %></p>
@@ -1,3 +1,3 @@
1
1
  <% post.tags.each do |t| %>
2
- <span class='label label-primary'><%= link_to t.name, storytime.tag_path(t.name) %></span>
2
+ <span class='label label-primary'><%= link_to t.name, storytime.blog_path(post.blog, tag: t.name) %></span>
3
3
  <% end %>
@@ -5,8 +5,9 @@
5
5
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
6
6
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
7
7
 
8
- ga('create', '<%= @current_storytime_site.ga_tracking_id %>', 'auto');
9
- ga('send', 'pageview');
8
+ ga('create', '<%= @current_storytime_site.ga_tracking_id %>', {'allowAnchor': true});
9
+
10
+ ga('send', 'pageview', { 'page': location.pathname + location.search + location.hash});
10
11
 
11
12
  </script>
12
- <% end %>
13
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= content_tag :span, class: "storytime-snippet storytime-snippet-#{snippet.id}" do %>
2
- <% if logged_in_storytime_user? && Pundit.policy(current_user, Storytime::Snippet).manage? %>
2
+ <% if logged_in_storytime_user? && Pundit.policy(current_user, snippet).manage? %>
3
3
  <%= link_to [storytime, :edit, :dashboard, snippet], class: "storytime-modal-trigger", remote: true do %>
4
4
  <span class='snippet-content'><%= raw snippet.content %></span>
5
5
  <% end %>
@@ -1 +1 @@
1
- Rails.application.config.assets.precompile += %w( chosen-sprite.png chosen-sprite@2x.png )
1
+ Rails.application.config.assets.precompile += %w( chosen-sprite.png chosen-sprite@2x.png tidy.js )
@@ -1,3 +1,5 @@
1
1
  StorytimeAdmin.configure do |config|
2
2
  config.base_controller = "Storytime::DashboardController"
3
+ config.ensure_admin_method = "storytime_admin?"
4
+ config.ensure_admin_scope = "current_storytime_site"
3
5
  end
@@ -2,15 +2,15 @@ module ActionDispatch
2
2
  module Routing
3
3
  class RouteSet
4
4
 
5
- if Rails::VERSION::MINOR >= 2
6
- def url_for_with_storytime(options, route_name = nil, url_strategy = UNKNOWN)
5
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR == 2
6
+ def url_for_with_storytime(options = {})
7
7
  Storytime::PostUrlHandler.handle_url(options)
8
- url_for_without_storytime(options, route_name, url_strategy)
8
+ url_for_without_storytime(options)
9
9
  end
10
10
  else
11
- def url_for_with_storytime(options = {})
11
+ def url_for_with_storytime(options, route_name = nil, url_strategy = UNKNOWN)
12
12
  Storytime::PostUrlHandler.handle_url(options)
13
- url_for_without_storytime(options)
13
+ url_for_without_storytime(options, route_name, url_strategy)
14
14
  end
15
15
  end
16
16
 
@@ -18,4 +18,4 @@ module ActionDispatch
18
18
 
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -56,6 +56,9 @@ en:
56
56
  roles:
57
57
  update:
58
58
  success: "Permissions successfully updated."
59
+ navigations:
60
+ destroy:
61
+ success: "Navigation list successfully deleted."
59
62
 
60
63
  simple_form:
61
64
  labels:
@@ -111,6 +114,11 @@ en:
111
114
  remove_image: "Remove Image"
112
115
  new:
113
116
  header: "New %{resource}"
117
+ navigations:
118
+ create:
119
+ success: "Your navigation list was created successfully."
120
+ update:
121
+ success: "Your navigation list was updated successfully."
114
122
 
115
123
  layout:
116
124
  title: "Storytime"
@@ -122,3 +130,13 @@ en:
122
130
  previous: "<i class='fa fa-caret-left'></i>"
123
131
  next: "<i class='fa fa-caret-right'></i>"
124
132
  last: "<i class='fa fa-caret-right'></i><i class='fa fa-caret-right'></i>"
133
+
134
+ storytime:
135
+ dashboard:
136
+ navigations:
137
+ index:
138
+ header: "Navigation Lists"
139
+ new:
140
+ header: "New Navigation List"
141
+ edit:
142
+ header: "Edit Navigation List"
data/config/routes.rb CHANGED
@@ -22,21 +22,25 @@ Storytime::Engine.routes.draw do
22
22
 
23
23
  resources :blog_posts, shallow: true, except: :show, concerns: :autosavable
24
24
  Storytime.post_types.reject{|type| %w[Storytime::Page Storytime::Blog Storytime::BlogPost].include?(type) }.each do |post_type|
25
- resources post_type.tableize.to_sym, controller: "custom_posts", only: [:new, :create]
25
+ resources post_type.tableize.to_sym, controller: "custom_posts", only: [:new, :create], defaults: { post_type: post_type }
26
26
  end
27
27
  end
28
-
28
+
29
29
  # Create / Update / Delete pages, blog_posts, custom_post_types
30
30
  Storytime.post_types.reject{|type| %w[Storytime::Page Storytime::Blog Storytime::BlogPost].include?(type) }.each do |post_type|
31
- resources post_type.tableize.to_sym, controller: "custom_posts", only: [:edit, :update, :destroy], concerns: :autosavable
31
+ resources post_type.tableize.to_sym, controller: "custom_posts", only: [:edit, :update, :destroy], concerns: :autosavable, defaults: { post_type: post_type }
32
32
  end
33
33
 
34
+ resources :navigations, except: :show do
35
+ resources :links, only: [] do
36
+ collection { post :sort }
37
+ end
38
+ end
34
39
  resources :snippets, except: [:show]
35
40
  resources :media, except: [:show, :edit, :update]
36
41
  resources :imports, only: [:new, :create]
37
42
  resources :subscriptions
38
- resources :users, path: Storytime.user_class_underscore.pluralize, only: [:new, :create, :edit, :update]
39
- resources :memberships, only: [:index, :create, :destroy]
43
+ resources :memberships
40
44
  resources :roles do
41
45
  collection do
42
46
  get :edit_multiple
@@ -47,16 +51,13 @@ Storytime::Engine.routes.draw do
47
51
 
48
52
  mount StorytimeAdmin::Engine => Storytime.dashboard_namespace_path
49
53
 
50
- # TODO: HOW DO WE DEAL WITH THIS WHEN THERE ARE MULTIPLE BLOG PAGES?
51
- get 'tags/:tag', to: 'posts#index', as: :tag
52
-
53
54
  get "/", to: "blog_homepage#show", constraints: Storytime::Constraints::BlogHomepageConstraint.new
54
55
  get "/", to: "homepage#show", constraints: Storytime::Constraints::PageHomepageConstraint.new
55
56
 
56
57
  resources :blogs, only: :show, path: "/", constraints: Storytime::Constraints::BlogConstraint.new
57
- resources :pages, only: :show, path: "/", constraints: Storytime::Constraints::PageConstraint.new
58
+ get '/*id', to: 'pages#show', constraints: Storytime::Constraints::PageConstraint.new
58
59
  resources :posts, only: [], concerns: :commentable
59
-
60
+
60
61
  Storytime.post_types.each do |post_type|
61
62
  constraints ->(request){ request.params[:component_1] != "assets" } do
62
63
  resources post_type.split("::").last.tableize, path: "(/:component_1(/:component_2(/:component_3)))/", only: :show, controller: "posts"
@@ -9,7 +9,7 @@ class CreateStorytimeSnippets < ActiveRecord::Migration
9
9
 
10
10
  Storytime::Role.seed
11
11
  Storytime::Action.seed
12
-
12
+
13
13
  manage_snippets = Storytime::Action.find_by(guid: "5qg25i")
14
14
  Storytime::Permission.find_or_create_by(role: Storytime::Role.find_by(name: "editor"), action: manage_snippets)
15
15
  Storytime::Permission.find_or_create_by(role: Storytime::Role.find_by(name: "admin"), action: manage_snippets)
@@ -0,0 +1,12 @@
1
+ class CreateStorytimeNavigations < ActiveRecord::Migration
2
+ def change
3
+ create_table :storytime_navigations do |t|
4
+ t.string :name
5
+ t.string :handle
6
+ t.integer :site_id
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_index :storytime_navigations, :site_id
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ class CreateStorytimeLinks < ActiveRecord::Migration
2
+ def change
3
+ create_table :storytime_links do |t|
4
+ t.string :text
5
+ t.belongs_to :storytime_navigation, index: true, foreign_key: true
6
+ t.references :linkable, polymorphic: true, index: true
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class AddPositionToStorytimeLinks < ActiveRecord::Migration
2
+ def change
3
+ add_column :storytime_links, :position, :integer
4
+ add_index :storytime_links, :position
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddUrlToStorytimeLinks < ActiveRecord::Migration
2
+ def change
3
+ add_column :storytime_links, :url, :string
4
+ end
5
+ end
@@ -9,7 +9,7 @@ module Storytime
9
9
  argument :scope, :required => false, :default => nil,
10
10
  :desc => "The scope to copy views to"
11
11
 
12
- class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (application, blog_posts, blogs, comments, dashboard, pages, posts, sites, snippets, subscription_mailer, subscriptions)"
12
+ class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (application, blogs, comments, dashboard, pages, posts, sites, snippets, subscription_mailer, subscriptions)"
13
13
 
14
14
  public_task :copy_views
15
15
  end
@@ -27,7 +27,6 @@ module Storytime
27
27
  end
28
28
  else
29
29
  view_directory :application
30
- view_directory :blog_posts
31
30
  view_directory :blogs
32
31
  view_directory :comments
33
32
  view_directory :pages
@@ -62,4 +61,4 @@ module Storytime
62
61
  :desc => "The scope to copy views to"
63
62
  end
64
63
  end
65
- end
64
+ end