spud_blog 0.9.5 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  class SpudPost < ActiveRecord::Base
2
- searchable
2
+ spud_searchable
3
3
 
4
4
  has_and_belongs_to_many :categories,
5
5
  :class_name => 'SpudPostCategory',
@@ -16,10 +16,11 @@ class SpudPost < ActiveRecord::Base
16
16
  validates_presence_of :title, :content, :published_at, :spud_user_id, :url_name
17
17
  validates_uniqueness_of :url_name
18
18
  before_validation :set_url_name
19
+ before_save :postprocess_content
19
20
 
20
21
  after_save :set_spud_site_ids
21
22
 
22
- attr_accessible :is_news,:published_at,:title,:content,:spud_user_id,:url_name,:visible,:comments_enabled,:meta_keywords,:meta_description,:category_ids, :spud_site_ids
23
+ attr_accessible :is_news,:published_at,:title,:content,:spud_user_id,:url_name,:visible,:comments_enabled,:meta_keywords,:meta_description,:category_ids, :spud_site_ids, :content_format
23
24
  attr_accessor :spud_site_ids
24
25
 
25
26
  def self.for_spud_site(spud_site_id)
@@ -97,6 +98,29 @@ class SpudPost < ActiveRecord::Base
97
98
  end
98
99
  end
99
100
 
101
+ def postprocess_content
102
+ if self.content_format == 'Markdown'
103
+ require 'redcarpet'
104
+ renderer = Redcarpet::Render::HTML.new
105
+ extensions = {fenced_code_blocks: true}
106
+ redcarpet = Redcarpet::Markdown.new(renderer, extensions)
107
+ self.content_processed = redcarpet.render self.content
108
+ else
109
+ self.content_processed = content
110
+ end
111
+ end
112
+
113
+ def content_processed
114
+ if read_attribute(:content_processed).blank?
115
+ postprocess_content
116
+ end
117
+ read_attribute(:content_processed)
118
+ end
119
+
120
+ def content_processed=(content)
121
+ write_attribute(:content_processed,content)
122
+ end
123
+
100
124
  def display_date
101
125
  return published_at.strftime("%b %d, %Y")
102
126
  end
@@ -1,12 +1,12 @@
1
1
  class SpudPostCategory < ActiveRecord::Base
2
- searchable
2
+ spud_searchable
3
3
  acts_as_nested_set
4
4
 
5
5
  has_and_belongs_to_many :posts,
6
6
  :class_name => 'SpudPost',
7
7
  :join_table => 'spud_post_categories_posts',
8
8
  :foreign_key => 'spud_post_category_id'
9
-
9
+
10
10
  validates_presence_of :name, :url_name
11
11
  validates_uniqueness_of :name, :url_name
12
12
  before_validation :set_url_name
@@ -67,4 +67,4 @@ class SpudPostCategory < ActiveRecord::Base
67
67
  self.children.update_all(:parent_id => self.parent_id)
68
68
  self.class.rebuild!
69
69
  end
70
- end
70
+ end
@@ -41,7 +41,7 @@ class SpudPostSweeper < ActionController::Caching::Sweeper
41
41
  expire_page blog_post_path(record.url_name)
42
42
  end
43
43
  end
44
- expire_page spud_sitemap_path(:format => :xml)
44
+ # expire_page spud_sitemap_path(:format => :xml)
45
45
  end
46
46
 
47
47
  end
@@ -23,7 +23,7 @@
23
23
  <h3><%= link_to post.title, blog_post_path(post.url_name) %></h3>
24
24
  <h4>Posted by <%= post.author.full_name %> on <%= post.display_date %></h4>
25
25
  <div class="spud_blog_post_content">
26
- <%= truncate_html post.content.html_safe, :length => 250 %>
26
+ <%= truncate_html post.content_processed.html_safe, :length => 250 %>
27
27
  </div>
28
28
  </div>
29
29
  <% end %>
@@ -1,18 +1,18 @@
1
- xml.instruct! :xml, :version => "1.0"
1
+ xml.instruct! :xml, :version => "1.0"
2
2
  xml.rss :version => "2.0" do
3
3
  xml.channel do
4
4
  xml.title "#{Spud::Core.site_name} Blog Articles"
5
5
  xml.description "Blog articles for #{Spud::Core.site_name}"
6
6
  xml.link blog_url(:format => :rss)
7
-
7
+
8
8
  for article in @posts
9
9
  xml.item do
10
10
  xml.title article.title
11
- xml.description article.content
11
+ xml.description article.content_processed
12
12
  xml.pubDate article.created_at.to_s(:rfc822)
13
13
  xml.link blog_post_url(article.url_name)
14
14
  xml.guid blog_post_url(article.url_name)
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -22,7 +22,7 @@
22
22
  </p>
23
23
  <% end %>
24
24
  <div id="spud_blog_post_content">
25
- <%= raw @post.content %>
25
+ <%= raw @post.content_processed %>
26
26
  </div>
27
27
  </div>
28
28
 
@@ -1,12 +1,20 @@
1
1
  <%=error_messages_for(f.object)%>
2
2
 
3
3
  <fieldset>
4
+ <div class="control-group">
4
5
  <%= f.label :title, :required=>true,:style =>"display:none;" %>
5
6
  <%= f.text_field :title, :class => "full-width",:placeholder=>"Enter title here" %>
7
+ </div>
6
8
  </fieldset>
7
-
8
- <div>
9
- <%= f.text_area :content,:style => "width:100%;", :class => 'tinymce full-width' %>
9
+ <%if Spud::Blog.config.markdown_enabled%>
10
+ <div class="control-group">
11
+ <div class="controls">
12
+ <%=f.select :content_format,[["HTML"],["Markdown"]], {:include_blank => false}, :class => "pull-right", "data-formatter" => "spud_post_content"%>
13
+ </div>
14
+ </div>
15
+ <%end%>
16
+ <div style="clear:both;">
17
+ <%= f.text_area :content,:style => "width:100%;", :class => 'tinymce full-width', "data-format" => f.object.content_format%>
10
18
  </div>
11
19
 
12
20
  <% if Spud::Blog.config.has_custom_fields %>
@@ -0,0 +1,5 @@
1
+ class AddContentFormatToSpudPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :spud_posts, :content_format, :string, :default => "HTML"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddContentProcessedToSpudPost < ActiveRecord::Migration
2
+ def change
3
+ add_column :spud_posts, :content_processed, :text
4
+ end
5
+ end
@@ -6,7 +6,7 @@ module Spud
6
6
  :news_enabled, :posts_per_page, :blog_path,
7
7
  :news_path, :enable_sitemap, :has_custom_fields,
8
8
  :cache_mode, :action_caching_duration,
9
- :enable_rakismet
9
+ :enable_rakismet, :enable_markdown
10
10
  )
11
11
  self.base_layout = 'application'
12
12
  self.news_layout = nil
@@ -20,5 +20,6 @@ module Spud
20
20
  self.cache_mode = nil #options :full_page, :action
21
21
  self.action_caching_duration = 3600
22
22
  self.enable_rakismet = false
23
+ self.enable_markdown = false
23
24
  end
24
25
  end
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Blog
3
- VERSION = "0.9.5"
3
+ VERSION = "0.9.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spud_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-17 00:00:00.000000000 Z
12
+ date: 2013-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.9.4
37
+ version: 0.9.10
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.9.4
45
+ version: 0.9.10
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: spud_permalinks
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: redcarpet
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: mysql2
96
112
  requirement: !ruby/object:Gem::Requirement
@@ -294,6 +310,8 @@ files:
294
310
  - db/migrate/20120825142547_add_spam_fields_to_spud_post_comments.rb
295
311
  - db/migrate/20120825144506_add_permalink_to_spud_post_comments.rb
296
312
  - db/migrate/20121113135812_add_nested_set_to_post_categories.rb
313
+ - db/migrate/20130120151857_add_content_format_to_spud_posts.rb
314
+ - db/migrate/20130121130612_add_content_processed_to_spud_post.rb
297
315
  - lib/generators/spud/blog/random_posts_generator.rb
298
316
  - lib/generators/spud/blog/views_generator.rb
299
317
  - lib/spud_blog/configuration.rb
@@ -320,7 +338,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
320
338
  version: '0'
321
339
  segments:
322
340
  - 0
323
- hash: 4047856296351614869
341
+ hash: 1495090918977313494
324
342
  required_rubygems_version: !ruby/object:Gem::Requirement
325
343
  none: false
326
344
  requirements:
@@ -329,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
347
  version: '0'
330
348
  segments:
331
349
  - 0
332
- hash: 4047856296351614869
350
+ hash: 1495090918977313494
333
351
  requirements: []
334
352
  rubyforge_project:
335
353
  rubygems_version: 1.8.24