spree_awesome_blog 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/README.md +13 -0
  2. data/app/controllers/admin/comments_controller.rb +32 -0
  3. data/app/controllers/admin/post_images_controller.rb +55 -0
  4. data/app/controllers/admin/posts_controller.rb +19 -0
  5. data/app/controllers/comments_controller.rb +23 -0
  6. data/app/controllers/posts_controller.rb +32 -0
  7. data/app/helpers/posts_helper.rb +19 -0
  8. data/app/models/comment.rb +31 -0
  9. data/app/models/comment.rb~ +31 -0
  10. data/app/models/post.rb +47 -0
  11. data/app/stylesheets/blog.less +234 -0
  12. data/app/views/admin/comments/_form.html.erb +28 -0
  13. data/app/views/admin/comments/edit.html.erb +8 -0
  14. data/app/views/admin/comments/index.html.erb +45 -0
  15. data/app/views/admin/post_images/_form.html.erb +8 -0
  16. data/app/views/admin/post_images/edit.html.erb +18 -0
  17. data/app/views/admin/post_images/index.html.erb +44 -0
  18. data/app/views/admin/post_images/new.html.erb +22 -0
  19. data/app/views/admin/posts/_form.html.erb +39 -0
  20. data/app/views/admin/posts/edit.html.erb +8 -0
  21. data/app/views/admin/posts/index.html.erb +53 -0
  22. data/app/views/admin/posts/new.html.erb +6 -0
  23. data/app/views/comments/_form.html.erb +30 -0
  24. data/app/views/comments/new.html.erb +3 -0
  25. data/app/views/posts/_sidebar.html.erb +34 -0
  26. data/app/views/posts/_tag_cloud.html.erb +5 -0
  27. data/app/views/posts/_tags.html.erb +3 -0
  28. data/app/views/posts/index.html.erb +32 -0
  29. data/app/views/posts/index.rss.builder +18 -0
  30. data/app/views/posts/show.html.erb +43 -0
  31. data/app/views/shared/_blog_sub_menu.html.erb +9 -0
  32. data/app/views/shared/_blog_tabs.html.erb +25 -0
  33. data/config/locales/en-US.yml +35 -0
  34. data/config/routes.rb +20 -0
  35. data/lib/generators/spree_awesome_blog/install_generator.rb +14 -0
  36. data/lib/generators/templates/db/migrate/20110110042721_create_posts.rb +21 -0
  37. data/lib/generators/templates/db/migrate/20110110042722_create_comments.rb +20 -0
  38. data/lib/generators/templates/db/migrate/20110110053623_acts_as_taggable_on_migration.rb +28 -0
  39. data/lib/generators/templates/public/images/markitup/bold.png +0 -0
  40. data/lib/generators/templates/public/images/markitup/clean.png +0 -0
  41. data/lib/generators/templates/public/images/markitup/h1.png +0 -0
  42. data/lib/generators/templates/public/images/markitup/h2.png +0 -0
  43. data/lib/generators/templates/public/images/markitup/h3.png +0 -0
  44. data/lib/generators/templates/public/images/markitup/h4.png +0 -0
  45. data/lib/generators/templates/public/images/markitup/h5.png +0 -0
  46. data/lib/generators/templates/public/images/markitup/h6.png +0 -0
  47. data/lib/generators/templates/public/images/markitup/image.png +0 -0
  48. data/lib/generators/templates/public/images/markitup/italic.png +0 -0
  49. data/lib/generators/templates/public/images/markitup/link.png +0 -0
  50. data/lib/generators/templates/public/images/markitup/list-bullet.png +0 -0
  51. data/lib/generators/templates/public/images/markitup/list-numeric.png +0 -0
  52. data/lib/generators/templates/public/images/markitup/paragraph.png +0 -0
  53. data/lib/generators/templates/public/images/markitup/picture.png +0 -0
  54. data/lib/generators/templates/public/images/markitup/preview.png +0 -0
  55. data/lib/generators/templates/public/images/markitup/quotes.png +0 -0
  56. data/lib/generators/templates/public/images/markitup/stroke.png +0 -0
  57. data/lib/generators/templates/public/javascripts/admin/blog.js +15 -0
  58. data/lib/generators/templates/public/javascripts/jquery.markitup.showdown.js +1904 -0
  59. data/lib/generators/templates/public/stylesheets/admin/blog.css +163 -0
  60. data/lib/generators/templates/public/stylesheets/blog.css +34 -0
  61. data/lib/spree_awesome_blog.rb +5 -0
  62. data/lib/spree_awesome_blog/engine.rb +29 -0
  63. data/lib/spree_awesome_blog_hooks.rb +10 -0
  64. metadata +179 -0
@@ -0,0 +1,28 @@
1
+ <%= render "shared/error_messages", :target => f.object %>
2
+ <fieldset>
3
+ <%= f.field_container :name do %>
4
+ <%= f.label :name, t("name") %> <span class="required">*</span><br />
5
+ <%= f.text_field :name, :class => 'fullwidth name' %>
6
+ <%= f.error_message_on :name %>
7
+ <% end %>
8
+ <%= f.field_container :email do %>
9
+ <%= f.label :email, t("email") %> <span class="required">*</span><br />
10
+ <%= f.text_field :email, :class => 'fullwidth' %>
11
+ <%= f.error_message_on :email %>
12
+ <% end %>
13
+ <%= f.field_container :url do %>
14
+ <%= f.label :url, t("url") %> <span class="required">*</span><br />
15
+ <%= f.text_field :url, :class => 'fullwidth' %>
16
+ <%= f.error_message_on :url %>
17
+ <% end %>
18
+ <%= f.field_container :message do %>
19
+ <%= f.label :message, t("message") %><span class="required">*</span><br />
20
+ <%= f.text_area :message, :class => 'fullwidth editor' %>
21
+ <%= f.error_message_on :message %>
22
+ <% end %>
23
+ <%= f.field_container :approved do %>
24
+ <%= f.check_box :approved %>
25
+ <%= f.label :approved, t("approved") %>
26
+ <%= f.error_message_on :approved %>
27
+ <% end %>
28
+ </fieldset>
@@ -0,0 +1,8 @@
1
+ <%= render 'shared/blog_sub_menu' %>
2
+
3
+ <h1><%= t('editing_comment') %></h1>
4
+
5
+ <%= form_for @comment, :url => object_path do |f| %>
6
+ <%= render 'form', :f => f %>
7
+ <%= render :partial => 'admin/shared/edit_resource_links' %>
8
+ <% end %>
@@ -0,0 +1,45 @@
1
+ <%= render 'shared/blog_sub_menu' %>
2
+
3
+ <h1><%= @post ? "#{t("comments_for")} \"#{@post.title}\"" : t("comments") %></h1>
4
+ <table class="index">
5
+ <thead>
6
+ <%= hook :admin_comments_index_headers do %>
7
+ <% unless @post %>
8
+ <th width="100px"><%= t("post") %></td>
9
+ <% end %>
10
+ <th><%= t("name") %></td>
11
+ <th><%= t("email") %></td>
12
+ <th><%= t("url") %></td>
13
+ <th><%= t("message") %></td>
14
+ <th width="80px"><%= t("status") %></td>
15
+ <% end %>
16
+ <th width="100px">
17
+ <%= hook :admin_comments_header_actions %>
18
+ </th>
19
+ </tr>
20
+ <thead>
21
+ <% @comments.each do |comment| %>
22
+ <tr id="<%= dom_id comment %>">
23
+ <%- locals = {:comment => comment} %>
24
+ <%= hook :admin_comments_index_rows, locals do %>
25
+ <% unless @post %>
26
+ <td><%= link_to comment.post.title, edit_admin_post_path(comment.post) %></td>
27
+ <% end %>
28
+ <td><%= comment.name %></td>
29
+ <td><%= comment.email %></td>
30
+ <td><%= link_to(comment.url, comment.url) unless comment.url.blank? %></td>
31
+ <td><%= markdown comment.message %></td>
32
+ <td><%= comment.approved ? link_to(t(comment.status), post_path(comment.post), :target => comment.post.permalink) : t(comment.status) %></td>
33
+ <% end %>
34
+ <td class="actions">
35
+ <%= hook :admin_comments_index_row_actions, locals do %>
36
+ <%= link_to_edit comment %>&nbsp;
37
+ <%= link_to_delete comment %>
38
+ <% end %>
39
+ </td>
40
+ </tr>
41
+ <% end %>
42
+ </tbody>
43
+ </table>
44
+ <%= will_paginate(:previous_label => "&#171; #{t('previous')}", :next_label => "#{t('next')} &#187;") %>
45
+
@@ -0,0 +1,8 @@
1
+ <tr>
2
+ <td><%= t("filename") %>:</td>
3
+ <td><%= f.file_field :attachment %></td>
4
+ </tr>
5
+ <tr>
6
+ <td><%= t("alt_text") %>:</td>
7
+ <td><%= f.text_area :alt %></td>
8
+ </tr>
@@ -0,0 +1,18 @@
1
+ <%= render :partial => 'shared/blog_sub_menu' %>
2
+
3
+ <%= render :partial => 'shared/blog_tabs', :locals => {:current => "Images"} %>
4
+
5
+ <%= form_for(:image, :url => admin_post_image_url(@post), :html => { :method => :put, :multipart => true }) do |f| %>
6
+ <%= render "shared/error_messages", :target => @image %>
7
+ <table class="basic-table">
8
+ <tr>
9
+ <td><%= t("thumbnail") %>:</td>
10
+ <td><%= link_to(image_tag(@image.attachment.url(:mini)), @image.attachment.url(:post)) %></td>
11
+ </tr>
12
+ <%= render :partial => "form", :locals => { :f => f } %>
13
+ </table>
14
+ <p class="form-buttons">
15
+ <%= button t("update") %>
16
+ <%= t('or') %> <%= link_to t("cancel"), admin_post_images_url(@post), :id => "cancel_link" %>
17
+ </p>
18
+ <% end %>
@@ -0,0 +1,44 @@
1
+ <%= render :partial => 'shared/blog_sub_menu' %>
2
+
3
+ <%= render :partial => 'shared/blog_tabs', :locals => {:current => "Images"} %>
4
+
5
+ <table class="index">
6
+ <tr>
7
+ <th><%= t("thumbnail") %></th>
8
+ <th><%= t("alt_text") %></th>
9
+ <th><%= t("action") %></th>
10
+ </tr>
11
+
12
+ <% @parent_object.images.each do |image| %>
13
+ <tr id="<%= dom_id(image) %>">
14
+ <td><%= link_to(image_tag(image.attachment.url(:mini)), image.attachment.url(:product)) %></td>
15
+ <td><%= image.alt %></td>
16
+ <td class="actions">
17
+ <%= link_to_with_icon('edit', t("edit"), edit_admin_post_image_url(@post, image)) %>
18
+ &nbsp;
19
+ <%= link_to_delete image, {:url => admin_post_image_url(@post, image) }%>
20
+ </td>
21
+ </tr>
22
+ <% end %>
23
+
24
+ </table>
25
+
26
+ <div id="images"></div>
27
+ <br/>
28
+ <p>
29
+ <%= link_to icon('add') + ' ' + t("new_image"), new_admin_post_image_url(@post), :id => "new_image_link" %>
30
+ </p>
31
+
32
+ <% content_for :head do %>
33
+ <script type="text/javascript">
34
+ jQuery(document).ready(function(){
35
+
36
+ jQuery('#new_image_link').click(function (event) {
37
+ event.preventDefault();
38
+ jQuery(this).hide();
39
+ jQuery.ajax({type: 'GET', url: this.href, data: ({authenticity_token: AUTH_TOKEN}), success: function(r){ jQuery('#images').html(r);} });
40
+ });
41
+
42
+ });
43
+ </script>
44
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <h4><%= t("new_image") %></h4>
2
+ <%= form_for(:image, :url => admin_post_images_path(@post), :html => { :multipart => true }) do |form| %>
3
+ <table class="basic-table">
4
+ <%= render :partial => "form", :locals => { :f => form } %>
5
+ </table>
6
+ <p class="form-buttons">
7
+ <%= button t("update") %>
8
+ <%= t('or') %> <%= link_to t("cancel"), "#", :id => "cancel_link" %>
9
+ </p>
10
+ <% end %>
11
+
12
+
13
+ <script type="text/javascript">
14
+ jQuery('#cancel_link').click(function (event) {
15
+ jQuery('#new_image_link').show();
16
+ jQuery('#images').html('');
17
+ });
18
+
19
+ </script>
20
+
21
+
22
+
@@ -0,0 +1,39 @@
1
+ <%= render "shared/error_messages", :target => f.object %>
2
+
3
+ <div id="images" style="display:none">
4
+ <% f.object.images.each do |image| %>
5
+ <%= image_tag image.attachment.url(:large), :alt => image.alt %>
6
+ <% end %>
7
+ </div>
8
+
9
+ <fieldset>
10
+ <%= f.field_container :title do %>
11
+ <%= f.label :title, t("title") %> <span class="required">*</span><br />
12
+ <%= f.text_field :title, :class => 'fullwidth title' %>
13
+ <%= f.error_message_on :title %>
14
+ <% end %>
15
+ <%= f.field_container :tag_list do %>
16
+ <%= f.label :tag_list, t("tags") %> <span class="small"><%= t("comma_seperated") %><span>
17
+ <%= f.text_field :tag_list, :class => 'fullwidth' %>
18
+ <%= f.error_message_on :tags %>
19
+ <% end %>
20
+ <%= f.field_container :body do %>
21
+ <%= f.label :body, t("body") %>
22
+ <%= f.text_area :body, :class => 'fullwidth editor' %>
23
+ <%= f.error_message_on :body %>
24
+ <% end %>
25
+ <%= f.field_container :publish do %>
26
+ <%= f.check_box :publish %>
27
+ <%= f.label :publish, t("publish") %>
28
+ <%= f.error_message_on :publish %>
29
+ <% end %>
30
+ <h2><%= t("metadata") %></h2>
31
+ <p>
32
+ <%= f.label :meta_keywords, t("meta_keywords")%><br />
33
+ <%= f.text_field :meta_keywords, :class => 'fullwidth' %>
34
+ </p>
35
+ <p>
36
+ <%= f.label :meta_description, t("meta_description")%><br />
37
+ <%= f.text_field :meta_description, :class => 'fullwidth' %>
38
+ </p>
39
+ </fieldset>
@@ -0,0 +1,8 @@
1
+ <%= render 'shared/blog_sub_menu' %>
2
+
3
+ <%= render :partial => 'shared/blog_tabs', :locals => {:current => "Post"} %>
4
+
5
+ <%= form_for @post, :url => object_path do |f| %>
6
+ <%= render 'form', :f => f %>
7
+ <%= render :partial => 'admin/shared/edit_resource_links' %>
8
+ <% end %>
@@ -0,0 +1,53 @@
1
+ <%= render 'shared/blog_sub_menu' %>
2
+
3
+ <div class='toolbar'>
4
+ <ul class='actions'>
5
+ <li id="new_post_link">
6
+ <%= button_link_to t("new_post"),
7
+ new_object_url,
8
+ {:remote => :true, :icon => 'add' } %>
9
+ </li>
10
+ </ul>
11
+ <br class='clear' />
12
+ </div>
13
+ <div id="new_post"></div>
14
+
15
+ <h1><%= t("posts") %></h1>
16
+ <table class="index">
17
+ <thead>
18
+ <%= hook :admin_posts_index_headers do %>
19
+ <th><%= t("title") %></td>
20
+ <th><%= t("status") %></td>
21
+ <% end %>
22
+ <th>
23
+ <%= hook :admin_posts_header_actions %>
24
+ </th>
25
+ </tr>
26
+ <thead>
27
+ <% @posts.each do |post| %>
28
+ <tr id="<%= dom_id post %>">
29
+ <%- locals = {:post => post} %>
30
+ <%= hook :admin_posts_index_rows, locals do %>
31
+ <td><%= link_to post.title, edit_admin_post_path(post) %></td>
32
+ <td>
33
+ <% if post.publish %>
34
+ <%= link_to(t(post.status), post_path(post), :target => post.permalink) %>
35
+ <br/>
36
+ <%= time_ago_in_words post.published_on %> ago
37
+ <% else %>
38
+ <%= t(post.status) %>
39
+ <% end %>
40
+ </td>
41
+ <% end %>
42
+ <td class="actions">
43
+ <%= hook :admin_posts_index_row_actions, locals do %>
44
+ <%= link_to_edit post %>&nbsp;
45
+ <%= link_to_delete post %>
46
+ <% end %>
47
+ </td>
48
+ </tr>
49
+ <% end %>
50
+ </tbody>
51
+ </table>
52
+ <%= will_paginate(:previous_label => "&#171; #{t('previous')}", :next_label => "#{t('next')} &#187;") %>
53
+
@@ -0,0 +1,6 @@
1
+ <%= render 'shared/blog_sub_menu' %>
2
+
3
+ <%= form_for @post, :url => collection_path do |f| %>
4
+ <%= render 'form', :f => f %>
5
+ <%= render :partial => 'admin/shared/new_resource_links' %>
6
+ <% end %>
@@ -0,0 +1,30 @@
1
+ <%= form_for comment, :url => post_comments_path(post) do |f| %>
2
+ <%= render "shared/error_messages", :target => f.object %>
3
+ <p>
4
+ <%= f.label :name, t('your_name') %><span class="required">*</span>
5
+ <br/>
6
+ <%= f.text_field :name %>
7
+ </p>
8
+ <p>
9
+ <%= f.label :email, t('your_email') %><span class="required">*</span>
10
+ <br/>
11
+ <% if current_user %>
12
+ <%= current_user.email %>
13
+ <% else %>
14
+ <%= f.text_field :email %>
15
+ <% end %>
16
+ <br/>
17
+ <span class="small"><%= t('not_shared') %></span>
18
+ </p>
19
+ <p>
20
+ <%= f.label :url, t('your_website') %>
21
+ <br/>
22
+ <%= f.text_field :url %>
23
+ </p>
24
+ <p>
25
+ <%= f.label :message, t('message') %> <span class="required">*</span>
26
+ <br/>
27
+ <%= f.text_area :message %>
28
+ </p>
29
+ <%= f.submit t('post_comment'), :class=>'button' %>
30
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h1><%= t('commenting_on') % @post.title %></h1>
2
+
3
+ <%= render 'form', :comment => @comment, :post => @post %>
@@ -0,0 +1,34 @@
1
+ <h2><%= t('blog_archive') %></h2>
2
+ <div id="blog-archive">
3
+ <ul class="years">
4
+ <% @dates.each do |year, months| %>
5
+ <li>
6
+ <span><%= year %></span>
7
+ <ul class="months">
8
+ <% months.each do |month, posts| %>
9
+ <li><span><%= month.strftime('%B') %></span>
10
+ <ul class="posts">
11
+ <% posts.each do |post| %>
12
+ <li><%= link_to post.title, post_path(post) %></li>
13
+ <% end %>
14
+ </ul>
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+ </li>
19
+ <% end %>
20
+ </ul>
21
+ </div>
22
+
23
+ <%= javascript_tag do %>
24
+ $('#blog-archive')
25
+ .find('ul:not(.years)')
26
+ .slideUp()
27
+ .end()
28
+ .find('span').click(function() {
29
+ $(this).find('+ul').slideToggle('slow');
30
+ });
31
+ <% end %>
32
+
33
+ <h2><%= t('tags') %></h2>
34
+ <%= render 'tag_cloud' %>
@@ -0,0 +1,5 @@
1
+ <div class="tag-cloud">
2
+ <% tag_cloud(@tags, %w(tag1 tag2 tag3 tag4)) do |tag, css_class| %>
3
+ <%= link_to tag.name, posts_by_tag_path(tag.name), :class => css_class %>
4
+ <% end %>
5
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= t("tags") %> <%= tags.collect do |tag|
2
+ link_to(tag.name, posts_by_tag_path(tag.name))
3
+ end.join(', ').html_safe %>
@@ -0,0 +1,32 @@
1
+ <% self.title = make_title(@tag, @year, @month, @day) %>
2
+
3
+ <% content_for(:head) do %>
4
+ <%= stylesheet_link_tag 'blog' %>
5
+ <% end %>
6
+ <% content_for(:sidebar) do %>
7
+ <%= render 'sidebar' %>
8
+ <% end %>
9
+
10
+ <div id="posts">
11
+ <h1><%= make_title(@tag, @year, @month, @day) %></h1>
12
+
13
+ <% @posts.each do |post| %>
14
+ <div class="post">
15
+ <span class="date"> <%= post.published_on.to_date.strftime '%A, %B %d, %Y' %> </span>
16
+ <h2><%= link_to post.title, post_path(post) %></h2>
17
+ <div class="body">
18
+ <%= markdown post.body %>
19
+ </div>
20
+ <div class="info">
21
+ Posted <%= time_ago_in_words post.published_on %> ago
22
+ <%= link_to t("comments"), "#{post_path(post)}#comments" %>
23
+ <br/>
24
+ <%= render 'tags', :tags => post.tags %>
25
+ </div>
26
+ <hr/>
27
+ </div>
28
+ <% end %>
29
+ <%= will_paginate(@posts,
30
+ :previous_label => "&#171; #{t('previous')}",
31
+ :next_label => "#{t('next')} &#187;") %>
32
+ </div>
@@ -0,0 +1,18 @@
1
+ xml.instruct! :xml, :version=>"1.0"
2
+ xml.rss(:version=>"2.0"){
3
+ xml.channel{
4
+ xml.title(Spree::Config[:blog_title] || "#{Spree::Config['site_name']} Blog")
5
+ xml.link(posts_url)
6
+ xml.description("")
7
+ xml.language('en-us')
8
+ for post in @posts
9
+ xml.item do
10
+ xml.title(post.title)
11
+ xml.description(markdown(post.body))
12
+ xml.pubDate(post.published_on.strftime("%a, %d %b %Y %H:%M:%S %z"))
13
+ xml.link(post_url(post))
14
+ xml.guid(post.permalink)
15
+ end
16
+ end
17
+ }
18
+ }
@@ -0,0 +1,43 @@
1
+ <% self.title = @post.title %>
2
+ <% def self.object; @post; end %>
3
+
4
+ <% content_for(:head) do %>
5
+ <%= stylesheet_link_tag 'blog' %>
6
+ <% end %>
7
+ <% content_for(:sidebar) do %>
8
+ <%= render 'sidebar' %>
9
+ <% end %>
10
+
11
+ <div id="post">
12
+ <div class="date"><%= @post.published_on.to_date.strftime '%A, %B %d, %Y' %></div>
13
+ <h1><%= @post.title %></h1>
14
+ <div id="body">
15
+ <%= markdown @post.body %>
16
+ </div>
17
+ <div id="tags">
18
+ <%= render 'tags', :tags => @post.tags %>
19
+ </div>
20
+ <div id="date">
21
+ Posted <%= time_ago_in_words @post.published_on %> ago
22
+ </div>
23
+
24
+ <div id="comments">
25
+ <h2><%= t("comments") %></h2>
26
+ <% @post.comments.approved.each do |comment| %>
27
+ <div class="comment">
28
+ <p class="info">
29
+ Posted by <b><%= comment.url.blank? ? comment.name : link_to(comment.name, comment.url) %></b> <%= time_ago_in_words comment.created_at %> ago
30
+ </p>
31
+ <div>
32
+ <%= markdown comment.message %>
33
+ </div>
34
+ <hr/>
35
+ </div>
36
+ <% end %>
37
+ <div id="new-comment">
38
+ <p><%= t('comment_on_post') %></p>
39
+
40
+ <%= render 'comments/form', :comment => @post.comments.new, :post => @post %>
41
+ </div>
42
+ </div>
43
+ </div>