picco_blog 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/picco_blog/application.js +15 -0
  6. data/app/assets/javascripts/picco_blog/comments.js +2 -0
  7. data/app/assets/javascripts/picco_blog/posts.js +29 -0
  8. data/app/assets/javascripts/picco_blog/simplemde.min.js +15 -0
  9. data/app/assets/javascripts/picco_blog/tag-it.min.js +17 -0
  10. data/app/assets/stylesheets/picco_blog/application.css +17 -0
  11. data/app/assets/stylesheets/picco_blog/comments.css +4 -0
  12. data/app/assets/stylesheets/picco_blog/jquery.tagit.css +69 -0
  13. data/app/assets/stylesheets/picco_blog/posts.css +179 -0
  14. data/app/assets/stylesheets/picco_blog/simplemde.min.css +7 -0
  15. data/app/assets/stylesheets/picco_blog/tagit.ui-zendesk.css +98 -0
  16. data/app/controllers/picco_blog/application_controller.rb +5 -0
  17. data/app/controllers/picco_blog/comments_controller.rb +17 -0
  18. data/app/controllers/picco_blog/posts_controller.rb +97 -0
  19. data/app/helpers/picco_blog/application_helper.rb +4 -0
  20. data/app/helpers/picco_blog/comments_helper.rb +4 -0
  21. data/app/helpers/picco_blog/posts_helper.rb +65 -0
  22. data/app/models/picco_blog/comment.rb +4 -0
  23. data/app/models/picco_blog/post.rb +39 -0
  24. data/app/models/slug.rb +77 -0
  25. data/app/views/layouts/picco_blog/application.html.erb +15 -0
  26. data/app/views/picco_blog/comments/_comment.html.erb +1 -0
  27. data/app/views/picco_blog/comments/_form.html.erb +8 -0
  28. data/app/views/picco_blog/kaminari/_first_page.html.erb +3 -0
  29. data/app/views/picco_blog/kaminari/_gap.html.erb +3 -0
  30. data/app/views/picco_blog/kaminari/_last_page.html.erb +3 -0
  31. data/app/views/picco_blog/kaminari/_next_page.html.erb +3 -0
  32. data/app/views/picco_blog/kaminari/_page.html.erb +9 -0
  33. data/app/views/picco_blog/kaminari/_paginator.html.erb +15 -0
  34. data/app/views/picco_blog/kaminari/_prev_page.html.erb +3 -0
  35. data/app/views/picco_blog/posts/_form.html.erb +48 -0
  36. data/app/views/picco_blog/posts/_members_only.html.erb +3 -0
  37. data/app/views/picco_blog/posts/_sharebuttons.html.erb +39 -0
  38. data/app/views/picco_blog/posts/_sidebar.html.erb +28 -0
  39. data/app/views/picco_blog/posts/admin_list.html.erb +51 -0
  40. data/app/views/picco_blog/posts/edit.html.erb +9 -0
  41. data/app/views/picco_blog/posts/index.html.erb +45 -0
  42. data/app/views/picco_blog/posts/new.html.erb +7 -0
  43. data/app/views/picco_blog/posts/show.html.erb +59 -0
  44. data/config/initializers/dragonfly.rb +26 -0
  45. data/config/initializers/friendly_id.rb +88 -0
  46. data/config/routes.rb +14 -0
  47. data/db/migrate/20160325154432_create_picco_blog_posts.rb +16 -0
  48. data/db/migrate/20160325215703_create_picco_blog_comments.rb +16 -0
  49. data/db/migrate/20160326004935_add_author_id_to_picco_blog_posts.rb +12 -0
  50. data/db/migrate/20160515161632_add_slug_to_picco_blog_posts.rb +12 -0
  51. data/db/migrate/20160515182921_create_friendly_id_slugs.rb +21 -0
  52. data/db/migrate/20160520121508_add_excerpt_to_picco_blog_posts.rb +11 -0
  53. data/db/migrate/20160807020315_add_state_to_picco_blog_posts.rb +12 -0
  54. data/db/migrate/20161106121455_change_picco_blog_posts_excerpt_to_text.rb +11 -0
  55. data/db/migrate/20161228031714_add_members_only_flag_to_picco_blog_posts.rb +12 -0
  56. data/db/migrate/20170102130706_add_featured_image_to_picco_blog_posts.rb +12 -0
  57. data/lib/generators/picco_blog/install/USAGE +8 -0
  58. data/lib/generators/picco_blog/install/install_generator.rb +17 -0
  59. data/lib/generators/picco_blog/install/templates/initializer.rb +40 -0
  60. data/lib/generators/picco_blog/views/USAGE +8 -0
  61. data/lib/generators/picco_blog/views/views_generator.rb +19 -0
  62. data/lib/picco_blog.rb +4 -0
  63. data/lib/picco_blog/engine.rb +36 -0
  64. data/lib/picco_blog/version.rb +3 -0
  65. data/lib/tasks/picco_blog_tasks.rake +4 -0
  66. data/test/controllers/picco_blog/comments_controller_test.rb +13 -0
  67. data/test/controllers/picco_blog/posts_controller_test.rb +52 -0
  68. data/test/dummy/README.rdoc +28 -0
  69. data/test/dummy/Rakefile +6 -0
  70. data/test/dummy/app/assets/javascripts/application.js +13 -0
  71. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  72. data/test/dummy/app/controllers/application_controller.rb +5 -0
  73. data/test/dummy/app/helpers/application_helper.rb +2 -0
  74. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  75. data/test/dummy/bin/bundle +3 -0
  76. data/test/dummy/bin/rails +4 -0
  77. data/test/dummy/bin/rake +4 -0
  78. data/test/dummy/bin/setup +29 -0
  79. data/test/dummy/config.ru +4 -0
  80. data/test/dummy/config/application.rb +26 -0
  81. data/test/dummy/config/boot.rb +5 -0
  82. data/test/dummy/config/database.yml +25 -0
  83. data/test/dummy/config/environment.rb +5 -0
  84. data/test/dummy/config/environments/development.rb +41 -0
  85. data/test/dummy/config/environments/production.rb +79 -0
  86. data/test/dummy/config/environments/test.rb +42 -0
  87. data/test/dummy/config/initializers/assets.rb +11 -0
  88. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  89. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  90. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  91. data/test/dummy/config/initializers/inflections.rb +16 -0
  92. data/test/dummy/config/initializers/mime_types.rb +4 -0
  93. data/test/dummy/config/initializers/session_store.rb +3 -0
  94. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  95. data/test/dummy/config/locales/en.yml +23 -0
  96. data/test/dummy/config/routes.rb +4 -0
  97. data/test/dummy/config/secrets.yml +22 -0
  98. data/test/dummy/db/development.sqlite3 +0 -0
  99. data/test/dummy/db/schema.rb +48 -0
  100. data/test/dummy/db/test.sqlite3 +0 -0
  101. data/test/dummy/log/development.log +364 -0
  102. data/test/dummy/log/test.log +421 -0
  103. data/test/dummy/public/404.html +67 -0
  104. data/test/dummy/public/422.html +67 -0
  105. data/test/dummy/public/500.html +66 -0
  106. data/test/dummy/public/favicon.ico +0 -0
  107. data/test/fixtures/picco_blog/comments.yml +9 -0
  108. data/test/fixtures/picco_blog/posts.yml +9 -0
  109. data/test/integration/navigation_test.rb +8 -0
  110. data/test/lib/generators/picco_blog/install_generator_test.rb +16 -0
  111. data/test/lib/generators/picco_blog/views_generator_test.rb +16 -0
  112. data/test/models/picco_blog/comment_test.rb +9 -0
  113. data/test/models/picco_blog/post_test.rb +9 -0
  114. data/test/picco_blog_test.rb +7 -0
  115. data/test/test_helper.rb +28 -0
  116. metadata +347 -0
@@ -0,0 +1,3 @@
1
+ <%= post_preview(post, false) %>
2
+
3
+ <p>To access this content, you must be a subscriber, or log in if you're a member.</p>
@@ -0,0 +1,39 @@
1
+ <div id="sharebuttons">
2
+
3
+ <!-- Sharingbutton Facebook -->
4
+ <a class="resp-sharing-button__link" href="https://facebook.com/sharer/sharer.php?u=<%= post_url_encode(post) %>" target="_blank" aria-label="">
5
+ <div class="resp-sharing-button resp-sharing-button--facebook resp-sharing-button--small">
6
+ <div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
7
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.77 7.46H14.5v-1.9c0-.9.6-1.1 1-1.1h3V.5h-4.33C10.24.5 9.5 3.44 9.5 5.32v2.15h-3v4h3v12h5v-12h3.85l.42-4z"/></svg>
8
+ </div>
9
+ </div>
10
+ </a>
11
+
12
+ <!-- Sharingbutton Twitter -->
13
+ <a class="resp-sharing-button__link" href="https://twitter.com/intent/tweet/?text=<%= post_title_encode(post) %>&amp;url=<%= post_url_encode(post) %>" target="_blank" aria-label="">
14
+ <div class="resp-sharing-button resp-sharing-button--twitter resp-sharing-button--small">
15
+ <div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
16
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M23.44 4.83c-.8.37-1.5.38-2.22.02.93-.56.98-.96 1.32-2.02-.88.52-1.86.9-2.9 1.1-.82-.88-2-1.43-3.3-1.43-2.5 0-4.55 2.04-4.55 4.54 0 .36.03.7.1 1.04-3.77-.2-7.12-2-9.36-4.75-.4.67-.6 1.45-.6 2.3 0 1.56.8 2.95 2 3.77-.74-.03-1.44-.23-2.05-.57v.06c0 2.2 1.56 4.03 3.64 4.44-.67.2-1.37.2-2.06.08.58 1.8 2.26 3.12 4.25 3.16C5.78 18.1 3.37 18.74 1 18.46c2 1.3 4.4 2.04 6.97 2.04 8.35 0 12.92-6.92 12.92-12.93 0-.2 0-.4-.02-.6.9-.63 1.96-1.22 2.56-2.14z"/></svg>
17
+ </div>
18
+ </div>
19
+ </a>
20
+
21
+ <!-- Sharingbutton Google+ -->
22
+ <a class="resp-sharing-button__link" href="https://plus.google.com/share?url=<%= post_url_encode(post) %>" target="_blank" aria-label="">
23
+ <div class="resp-sharing-button resp-sharing-button--google resp-sharing-button--small">
24
+ <div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
25
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11.37 12.93c-.73-.52-1.4-1.27-1.4-1.5 0-.43.03-.63.98-1.37 1.23-.97 1.9-2.23 1.9-3.57 0-1.22-.36-2.3-1-3.05h.5c.1 0 .2-.04.28-.1l1.36-.98c.16-.12.23-.34.17-.54-.07-.2-.25-.33-.46-.33H7.6c-.66 0-1.34.12-2 .35-2.23.76-3.78 2.66-3.78 4.6 0 2.76 2.13 4.85 5 4.9-.07.23-.1.45-.1.66 0 .43.1.83.33 1.22h-.08c-2.72 0-5.17 1.34-6.1 3.32-.25.52-.37 1.04-.37 1.56 0 .5.13.98.38 1.44.6 1.04 1.84 1.86 3.55 2.28.87.23 1.82.34 2.8.34.88 0 1.7-.1 2.5-.34 2.4-.7 3.97-2.48 3.97-4.54 0-1.97-.63-3.15-2.33-4.35zm-7.7 4.5c0-1.42 1.8-2.68 3.9-2.68h.05c.45 0 .9.07 1.3.2l.42.28c.96.66 1.6 1.1 1.77 1.8.05.16.07.33.07.5 0 1.8-1.33 2.7-3.96 2.7-1.98 0-3.54-1.23-3.54-2.8zM5.54 3.9c.33-.38.75-.58 1.23-.58h.05c1.35.05 2.64 1.55 2.88 3.35.14 1.02-.08 1.97-.6 2.55-.32.37-.74.56-1.23.56h-.03c-1.32-.04-2.63-1.6-2.87-3.4-.13-1 .08-1.92.58-2.5zM23.5 9.5h-3v-3h-2v3h-3v2h3v3h2v-3h3"/></svg>
26
+ </div>
27
+ </div>
28
+ </a>
29
+
30
+ <!-- Sharingbutton E-Mail -->
31
+ <a class="resp-sharing-button__link" href="mailto:?subject=<%= post_title_encode(post) %>&amp;body=<%= post_url_encode(post) %>" target="_self" aria-label="">
32
+ <div class="resp-sharing-button resp-sharing-button--email resp-sharing-button--small">
33
+ <div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
34
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 4H2C.9 4 0 4.9 0 6v12c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM7.25 14.43l-3.5 2c-.08.05-.17.07-.25.07-.17 0-.34-.1-.43-.25-.14-.24-.06-.55.18-.68l3.5-2c.24-.14.55-.06.68.18.14.24.06.55-.18.68zm4.75.07c-.1 0-.2-.03-.27-.08l-8.5-5.5c-.23-.15-.3-.46-.15-.7.15-.22.46-.3.7-.14L12 13.4l8.23-5.32c.23-.15.54-.08.7.15.14.23.07.54-.16.7l-8.5 5.5c-.08.04-.17.07-.27.07zm8.93 1.75c-.1.16-.26.25-.43.25-.08 0-.17-.02-.25-.07l-3.5-2c-.24-.13-.32-.44-.18-.68s.44-.32.68-.18l3.5 2c.24.13.32.44.18.68z"/></svg>
35
+ </div>
36
+ </div>
37
+ </a>
38
+
39
+ </div>
@@ -0,0 +1,28 @@
1
+ <div id="picco_blog_sidebar">
2
+ <h4>Search Blog</h4>
3
+
4
+ <%= form_tag(posts_path, :method => "get", id: "search-form", enforce_utf8: false) do %>
5
+ <%= text_field_tag :search, params[:search], placeholder: "Search" %>
6
+ <% end %>
7
+
8
+ <h4>Categories</h4>
9
+
10
+ <div>
11
+ <% @available_tags.any? %>
12
+ <% @available_tags.each do |tag| %>
13
+ <p><%= link_to tag, tagged_url(:tag => tag) %></p>
14
+ <% end %>
15
+ </div>
16
+
17
+ <h4>Recent Posts</h4>
18
+
19
+ <div>
20
+ <% @recent_posts.each do |post| %>
21
+ <p>
22
+ <%= link_to post.title, post_path(post) %>
23
+ <em>Posted on <%= created_date_display(post) %></em>
24
+ </p>
25
+ <% end %>
26
+ </div>
27
+
28
+ </div>
@@ -0,0 +1,51 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <div>
4
+ <h1>Posts</h1>
5
+
6
+ <table>
7
+ <thead>
8
+ <tr>
9
+ <th>ID</th>
10
+ <th>Title</th>
11
+ <th>State</th>
12
+ <th>Members Only?</th>
13
+ <th>Created</th>
14
+ <th colspan="3"></th>
15
+ </tr>
16
+ </thead>
17
+
18
+ <tbody>
19
+ <% if @posts.exists? %>
20
+ <% @posts.each do |post| %>
21
+ <tr>
22
+ <td><%= post.id %></td>
23
+ <td><%= post.title %></td>
24
+ <td><%= post.state %></td>
25
+ <td><%= post.members_only %></td>
26
+ <td><%= post.created_at.strftime("%m/%d/%y") %></td>
27
+ <td><%= link_to 'Show', post %></td>
28
+
29
+ <% if current_user.try(:admin?) %>
30
+ <td><%= link_to 'Edit', edit_post_path(post) %></td>
31
+ <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
32
+ <% end %>
33
+
34
+ </tr>
35
+ <% end %>
36
+ <% else %>
37
+ <tr>
38
+ <td>No Posts</td>
39
+ </tr>
40
+ <% end %>
41
+ </tbody>
42
+ </table>
43
+
44
+ <div id="pagination">
45
+ <%= paginate @posts, views_prefix: 'picco_blog' %>
46
+ </div>
47
+
48
+ <br>
49
+
50
+ <%= link_to 'New Post', new_post_path %>
51
+ </div>
@@ -0,0 +1,9 @@
1
+ <div>
2
+ <h1>Editing Post</h1>
3
+
4
+ <%= render 'form' %>
5
+
6
+ <%= link_to 'Show', @post %> |
7
+ <%= link_to 'Back', posts_path %> |
8
+ <%= link_to 'Delete', post_path(@post), data: { confirm: "Are you sure?" }, method: :delete %>
9
+ </div>
@@ -0,0 +1,45 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <div>
4
+ <h1>Listing Posts</h1>
5
+
6
+ <table>
7
+ <thead>
8
+ <tr>
9
+ <th>Title</th>
10
+ <th>Text</th>
11
+ <th colspan="3"></th>
12
+ </tr>
13
+ </thead>
14
+
15
+ <tbody>
16
+ <% if @posts.exists? %>
17
+ <% @posts.each do |post| %>
18
+ <tr>
19
+ <td><%= post.title %></td>
20
+ <td><%= post.text %></td>
21
+ <td><%= link_to 'Show', post %></td>
22
+
23
+ <% if current_user.try(:admin?) %>
24
+ <td><%= link_to 'Edit', edit_post_path(post) %></td>
25
+ <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
26
+ <% end %>
27
+
28
+ </tr>
29
+ <% end %>
30
+ <% else %>
31
+ <tr>
32
+ <td>No Posts</td>
33
+ </tr>
34
+ <% end %>
35
+ </tbody>
36
+ </table>
37
+
38
+ <div id="pagination">
39
+ <%= paginate @posts, views_prefix: 'picco_blog' %>
40
+ </div>
41
+
42
+ <br>
43
+
44
+ <%= link_to 'New Post', new_post_path %>
45
+ </div>
@@ -0,0 +1,7 @@
1
+ <div>
2
+ <h1>New Post</h1>
3
+
4
+ <%= render 'form' %>
5
+
6
+ <%= link_to 'Back', posts_path %>
7
+ </div>
@@ -0,0 +1,59 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <div>
4
+
5
+ <% if post.featured_image_stored? %>
6
+ <%= link_to image_tag(post.featured_image.thumb('847x300#').url, :class => "mb24"), post_path(post) %>
7
+ <% end %>
8
+
9
+ <p>
10
+ <strong>Title:</strong>
11
+ <%= @post.title %>
12
+ </p>
13
+
14
+ <p>
15
+ <strong>Text:</strong>
16
+ <% if PiccoBlog.members_only %>
17
+ <% if @post.members_only %>
18
+ <% if user_signed_in? && members_only_check(current_user) %>
19
+ <%= markdown @post.text %>
20
+ <% else %>
21
+ <%= render "members_only", :post => @post %>
22
+ <% end -%>
23
+ <% else %>
24
+ <%= markdown @post.text %>
25
+ <% end %>
26
+ <% else %>
27
+ <%= markdown @post.text %>
28
+ <% end -%>
29
+ </p>
30
+
31
+ <p>
32
+ <b>Author:</b>
33
+ <%= @post.author.name %>
34
+ </p>
35
+
36
+ <% if @post.tag_list.any? %>
37
+ <p>
38
+ <b>Tag List:</b>
39
+ <%= linked_tag_list(@post.tag_list) %>
40
+ </p>
41
+ <% end -%>
42
+
43
+ <% if PiccoBlog.include_share_bar %>
44
+ <hr />
45
+ <%= render "sharebuttons", :post => @post %>
46
+ <% end -%>
47
+
48
+ <% if PiccoBlog.include_comments == :active_record %>
49
+ <hr />
50
+
51
+ <h3>Comments</h3>
52
+ <%= render @post.comments %>
53
+
54
+ <%= render "picco_blog/comments/form" %>
55
+ <% end -%>
56
+
57
+ <%= link_to 'Edit', edit_post_path(@post) %> |
58
+ <%= link_to 'Back', posts_path %>
59
+ </div>
@@ -0,0 +1,26 @@
1
+ require 'dragonfly'
2
+
3
+ # Configure
4
+ Dragonfly.app.configure do
5
+ plugin :imagemagick
6
+
7
+ secret "bb1477846aa3593d53607ed5e776cce98378fefa22695f3c746afd79432d0ff3"
8
+
9
+ url_format "/media/:job/:name"
10
+
11
+ datastore :file,
12
+ root_path: Rails.root.join('public/system/dragonfly', Rails.env),
13
+ server_root: Rails.root.join('public')
14
+ end
15
+
16
+ # Logger
17
+ Dragonfly.logger = Rails.logger
18
+
19
+ # Mount as middleware
20
+ Rails.application.middleware.use Dragonfly::Middleware
21
+
22
+ # Add model functionality
23
+ if defined?(ActiveRecord::Base)
24
+ ActiveRecord::Base.extend Dragonfly::Model
25
+ ActiveRecord::Base.extend Dragonfly::Model::Validations
26
+ end
@@ -0,0 +1,88 @@
1
+ # FriendlyId Global Configuration
2
+ #
3
+ # Use this to set up shared configuration options for your entire application.
4
+ # Any of the configuration options shown here can also be applied to single
5
+ # models by passing arguments to the `friendly_id` class method or defining
6
+ # methods in your model.
7
+ #
8
+ # To learn more, check out the guide:
9
+ #
10
+ # http://norman.github.io/friendly_id/file.Guide.html
11
+
12
+ FriendlyId.defaults do |config|
13
+ # ## Reserved Words
14
+ #
15
+ # Some words could conflict with Rails's routes when used as slugs, or are
16
+ # undesirable to allow as slugs. Edit this list as needed for your app.
17
+ config.use :reserved
18
+
19
+ config.reserved_words = %w(new edit index session login logout users admin
20
+ stylesheets assets javascripts images)
21
+
22
+ # ## Friendly Finders
23
+ #
24
+ # Uncomment this to use friendly finders in all models. By default, if
25
+ # you wish to find a record by its friendly id, you must do:
26
+ #
27
+ # MyModel.friendly.find('foo')
28
+ #
29
+ # If you uncomment this, you can do:
30
+ #
31
+ # MyModel.find('foo')
32
+ #
33
+ # This is significantly more convenient but may not be appropriate for
34
+ # all applications, so you must explicity opt-in to this behavior. You can
35
+ # always also configure it on a per-model basis if you prefer.
36
+ #
37
+ # Something else to consider is that using the :finders addon boosts
38
+ # performance because it will avoid Rails-internal code that makes runtime
39
+ # calls to `Module.extend`.
40
+ #
41
+ # config.use :finders
42
+ #
43
+ # ## Slugs
44
+ #
45
+ # Most applications will use the :slugged module everywhere. If you wish
46
+ # to do so, uncomment the following line.
47
+ #
48
+ # config.use :slugged
49
+ #
50
+ # By default, FriendlyId's :slugged addon expects the slug column to be named
51
+ # 'slug', but you can change it if you wish.
52
+ #
53
+ # config.slug_column = 'slug'
54
+ #
55
+ # When FriendlyId can not generate a unique ID from your base method, it appends
56
+ # a UUID, separated by a single dash. You can configure the character used as the
57
+ # separator. If you're upgrading from FriendlyId 4, you may wish to replace this
58
+ # with two dashes.
59
+ #
60
+ # config.sequence_separator = '-'
61
+ #
62
+ # ## Tips and Tricks
63
+ #
64
+ # ### Controlling when slugs are generated
65
+ #
66
+ # As of FriendlyId 5.0, new slugs are generated only when the slug field is
67
+ # nil, but if you're using a column as your base method can change this
68
+ # behavior by overriding the `should_generate_new_friendly_id` method that
69
+ # FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
70
+ # more like 4.0.
71
+ #
72
+ config.use Module.new {
73
+ def should_generate_new_friendly_id?
74
+ slug.blank? || title_changed?
75
+ end
76
+ }
77
+ #
78
+ # FriendlyId uses Rails's `parameterize` method to generate slugs, but for
79
+ # languages that don't use the Roman alphabet, that's not usually sufficient.
80
+ # Here we use the Babosa library to transliterate Russian Cyrillic slugs to
81
+ # ASCII. If you use this, don't forget to add "babosa" to your Gemfile.
82
+ #
83
+ # config.use Module.new {
84
+ # def normalize_friendly_id(text)
85
+ # text.to_slug.normalize! :transliterations => [:russian, :latin]
86
+ # end
87
+ # }
88
+ end
@@ -0,0 +1,14 @@
1
+ PiccoBlog::Engine.routes.draw do
2
+
3
+ get 'posts/admin_list' => 'posts#admin_list', :as => 'admin_list'
4
+
5
+ resources :posts do
6
+ resources :comments
7
+ end
8
+
9
+ resources :tags, only: [:index, :show]
10
+
11
+ get 'posts' => 'posts#index', :as => 'tagged'
12
+
13
+ root "posts#index"
14
+ end
@@ -0,0 +1,16 @@
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class CreatePiccoBlogPosts < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class CreatePiccoBlogPosts < ActiveRecord::Migration; end
5
+ end
6
+
7
+ CreatePiccoBlogPosts.class_eval do
8
+ def change
9
+ create_table :picco_blog_posts do |t|
10
+ t.string :title
11
+ t.text :text
12
+
13
+ t.timestamps null: false
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class CreatePiccoBlogComments < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class CreatePiccoBlogComments < ActiveRecord::Migration; end
5
+ end
6
+
7
+ CreatePiccoBlogComments.class_eval do
8
+ def change
9
+ create_table :picco_blog_comments do |t|
10
+ t.integer :post_id
11
+ t.text :text
12
+
13
+ t.timestamps null: false
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class AddAuthorIdToPiccoBlogPosts < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class AddAuthorIdToPiccoBlogPosts < ActiveRecord::Migration; end
5
+ end
6
+
7
+ AddAuthorIdToPiccoBlogPosts.class_eval do
8
+ def change
9
+ add_column :picco_blog_posts, :author_id, :integer
10
+ add_index :picco_blog_posts, :author_id
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class AddSlugToPiccoBlogPosts < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class AddSlugToPiccoBlogPosts < ActiveRecord::Migration; end
5
+ end
6
+
7
+ AddSlugToPiccoBlogPosts.class_eval do
8
+ def change
9
+ add_column :picco_blog_posts, :slug, :string
10
+ add_index :picco_blog_posts, :slug
11
+ end
12
+ end