blog_basic 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +24 -0
- data/MIT-LICENSE +20 -0
- data/Manifest +0 -0
- data/README.md +186 -0
- data/Rakefile +47 -0
- data/app/admin/blog_basic_blog_posts.rb +9 -0
- data/app/admin/dashboards.rb +38 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/javascripts/active_admin.js +1 -0
- data/app/assets/javascripts/application.js +9 -0
- data/app/assets/stylesheets/active_admin.css.scss +6 -0
- data/app/assets/stylesheets/application.css +7 -0
- data/app/controllers/application_controller.rb +3 -0
- data/app/controllers/blog_basic/app_controller.rb +27 -0
- data/app/controllers/blog_basic/application_controller.rb +4 -0
- data/app/controllers/blog_basic/blog_comments_controller.rb +69 -0
- data/app/controllers/blog_basic/blog_posts_controller.rb +149 -0
- data/app/controllers/blog_basic/sessions_controller.rb +32 -0
- data/app/controllers/blog_basic/tags_controller.rb +11 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/blog_basic/application_helper.rb +21 -0
- data/app/helpers/blog_basic/blog_posts_helper.rb +17 -0
- data/app/helpers/blog_basic/shared_helper.rb +36 -0
- data/app/helpers/blog_basic/tags_helper.rb +5 -0
- data/app/models/admin_user.rb +9 -0
- data/app/models/blog_basic/blog_comment.rb +78 -0
- data/app/models/blog_basic/blog_content.rb +4 -0
- data/app/models/blog_basic/blog_image.rb +23 -0
- data/app/models/blog_basic/blog_post.rb +104 -0
- data/app/models/blog_basic/session.rb +5 -0
- data/app/models/blog_basic/user.rb +22 -0
- data/app/views/blog_basic/blog_comments/_new_blog_comment.html.erb +43 -0
- data/app/views/blog_basic/blog_posts/_admin_links.html.erb +9 -0
- data/app/views/blog_basic/blog_posts/_blog_post.html.erb +62 -0
- data/app/views/blog_basic/blog_posts/_comment.html.erb +18 -0
- data/app/views/blog_basic/blog_posts/_comments.html.erb +6 -0
- data/app/views/blog_basic/blog_posts/_form.html.erb +133 -0
- data/app/views/blog_basic/blog_posts/_image.html.erb +20 -0
- data/app/views/blog_basic/blog_posts/drafts.html.erb +21 -0
- data/app/views/blog_basic/blog_posts/edit.html.erb +6 -0
- data/app/views/blog_basic/blog_posts/index.atom.builder +12 -0
- data/app/views/blog_basic/blog_posts/index.html.erb +31 -0
- data/app/views/blog_basic/blog_posts/new.html.erb +6 -0
- data/app/views/blog_basic/blog_posts/show.html.erb +8 -0
- data/app/views/blog_basic/shared/_footer.html.erb +15 -0
- data/app/views/blog_basic/shared/_index_top.html.erb +12 -0
- data/app/views/blog_basic/shared/_topbar.html.erb +24 -0
- data/app/views/layouts/application.html.erb +14 -0
- data/blog_basic.gemspec +57 -0
- data/config/routes.rb +21 -0
- data/db/migrate/1_blog_tables.rb +86 -0
- data/init.rb +9 -0
- data/lib/akismetor.rb +77 -0
- data/lib/blog_basic/active_admin.rb +103 -0
- data/lib/blog_basic/blog_basic_model_helper.rb +85 -0
- data/lib/blog_basic/blog_conf.rb +36 -0
- data/lib/blog_basic/engine.rb +13 -0
- data/lib/blog_basic/engine.rb.backup +80 -0
- data/lib/blog_basic.rb +16 -0
- data/lib/generators/blog_basic/create_assets/blog_assets_generator.rb +49 -0
- data/lib/generators/blog_basic/create_assets/templates/blog_comments_migration.rb +23 -0
- data/lib/generators/blog_basic/create_assets/templates/blog_images_migration.rb +19 -0
- data/lib/generators/blog_basic/create_assets/templates/blog_posts_migration.rb +17 -0
- data/lib/generators/blog_basic/create_assets/templates/config/blog_basic.yml +52 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/active4d.css +114 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/all_hallows_eve.css +72 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/amy.css +147 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/blackboard.css +88 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/brilliance_black.css +605 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/brilliance_dull.css +599 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/cobalt.css +149 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/dawn.css +121 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/eiffel.css +121 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/espresso_libre.css +109 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/idle.css +62 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/iplastic.css +80 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/lazy.css +73 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/mac_classic.css +123 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/magicwb_amiga.css +104 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/pastels_on_dark.css +188 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/slush_poppies.css +85 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/spacecadet.css +51 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/sunburst.css +180 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/twilight.css +137 -0
- data/lib/generators/blog_basic/create_assets/templates/syntax/zenburnesque.css +91 -0
- data/lib/generators/blog_basic/install/install_generator.rb +53 -0
- data/lib/generators/blog_basic/install/templates/active_admin.rb +103 -0
- data/lib/generators/blog_basic/install/templates/blog_basic.yml +52 -0
- data/lib/generators/blog_basic/install/templates/blog_kit.css +75 -0
- data/lib/generators/blog_basic/install/templates/devise.en.yml +58 -0
- data/lib/generators/blog_basic/install/templates/devise.rb +209 -0
- data/lib/generators/blog_basic/install/templates/migrations/1_blog_tables.rb +86 -0
- data/lib/generators/blog_basic/install/templates/migrations/20111213104240_devise_create_admin_users.rb +28 -0
- data/lib/generators/blog_basic/install/templates/migrations/20111213114257_create_admin_notes.rb +16 -0
- data/lib/generators/blog_basic/install/templates/migrations/20111213114258_move_admin_notes_to_comments.rb +25 -0
- data/lib/generators/blog_basic/install/templates/omniauth.rb.erb +10 -0
- data/lib/tasks/blog_basic_tasks.rake +0 -0
- data/lib/url_validator.rb +24 -0
- data/test/database.yml +4 -0
- data/test/fixtures/admin_users.yml +11 -0
- data/test/functional/blog_assets_generator_test.rb +35 -0
- data/test/functional/blog_comments_controller_test.rb +0 -0
- data/test/functional/blog_posts_controller_test.rb +84 -0
- data/test/performance/browsing_test.rb +12 -0
- data/test/schema.rb +61 -0
- data/test/test_helper.rb +13 -0
- data/test/unit/admin_user_test.rb +7 -0
- data/uninstall.rb +1 -0
- metadata +310 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module BlogBasic
|
|
2
|
+
module ApplicationHelper
|
|
3
|
+
def signed_in?
|
|
4
|
+
!session[:user_id].nil?
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def current_user
|
|
8
|
+
logger.info "Current user ID: " + session[:user_id].to_s
|
|
9
|
+
if signed_in?
|
|
10
|
+
@current_user ||= User.find(session[:user_id])
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def ensure_signed_in
|
|
15
|
+
unless signed_in?
|
|
16
|
+
session[:redirect_to] = request.request_uri
|
|
17
|
+
redirect_to(new_session_path)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module BlogBasic
|
|
2
|
+
module BlogPostsHelper
|
|
3
|
+
|
|
4
|
+
def display_name(name, site)
|
|
5
|
+
if !site.blank?
|
|
6
|
+
return link_to(name, site, :rel => 'nofollow')
|
|
7
|
+
else
|
|
8
|
+
return name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def carnonical_link(post)
|
|
13
|
+
"<link rel=\"canonical\" href=\"/".html_safe + post.id.to_s + "\" />".html_safe
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module BlogBasic
|
|
2
|
+
module SharedHelper
|
|
3
|
+
|
|
4
|
+
def require_user
|
|
5
|
+
#return true
|
|
6
|
+
logger.info session[:user_id].to_s
|
|
7
|
+
@current_user ||= User.new(session[:user_id])
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def title(page_title)
|
|
11
|
+
content_for(:title, page_title)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def sidebar_ad(posted_at)
|
|
15
|
+
if (posted_at < 30.days.ago) && !danish?
|
|
16
|
+
raw render(:partial => '/snippets/v_text_ad')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def leaderboard_ad
|
|
21
|
+
if !danish?
|
|
22
|
+
raw render(:partial => '/snippets/h_leaderboard_ad')
|
|
23
|
+
else
|
|
24
|
+
raw render :text => "<div></div>"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def danish?
|
|
31
|
+
#geoip ||= GeoIP.new("#{RAILS_ROOT}/db/GeoIP.dat")
|
|
32
|
+
#return geoip.country(request.ip).country_code2 == "DK"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#class AdminUser < ActiveRecord::Base
|
|
2
|
+
# Include default devise modules. Others available are:
|
|
3
|
+
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
|
|
4
|
+
# devise :database_authenticatable,
|
|
5
|
+
# :recoverable, :rememberable, :trackable, :validatable
|
|
6
|
+
|
|
7
|
+
# Setup accessible (or protected) attributes for your model
|
|
8
|
+
# attr_accessible :email, :password, :password_confirmation, :remember_me
|
|
9
|
+
#end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
module BlogBasic
|
|
2
|
+
class BlogComment < ActiveRecord::Base
|
|
3
|
+
include BlogBasic::BlogBasicModelHelper
|
|
4
|
+
|
|
5
|
+
unloadable
|
|
6
|
+
|
|
7
|
+
belongs_to :user
|
|
8
|
+
belongs_to :blog_article
|
|
9
|
+
|
|
10
|
+
validates_presence_of :body
|
|
11
|
+
validates :site_url, :url => true, :if => Proc.new{ |comment| !comment.site.blank? }
|
|
12
|
+
|
|
13
|
+
before_save :check_for_spam
|
|
14
|
+
|
|
15
|
+
def validate
|
|
16
|
+
if !self.user
|
|
17
|
+
self.errors.add(:name, 'is required') if self.name.blank?
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def formatted_created_at
|
|
22
|
+
self.created_at.strftime(BlogBasic::BlogConf.data['post_date_format'] || '%m/%d/%Y at %I:%M%p')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def parsed_body
|
|
26
|
+
# # Going to add markdown/html support later for comments
|
|
27
|
+
# self.code_highlight_and_markdown(self.body, {:escape_html => true})
|
|
28
|
+
|
|
29
|
+
self.body
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def user_name
|
|
33
|
+
name = self.user ? self.user.name : self.name
|
|
34
|
+
if !self.site_url.blank? && false
|
|
35
|
+
return "<a href=\"".html_safe << self.site_url << "\">".html_safe << name << "</a>".html_safe
|
|
36
|
+
else
|
|
37
|
+
return name
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def site
|
|
42
|
+
self.site_url.blank? ? "" : self.site_url
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Used to set more tracking for akismet
|
|
46
|
+
def request=(request)
|
|
47
|
+
self.user_ip = request.remote_ip
|
|
48
|
+
self.user_agent = request.env['HTTP_USER_AGENT']
|
|
49
|
+
self.referrer = request.env['HTTP_REFERER']
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def check_for_spam
|
|
53
|
+
if BlogBasic::BlogConf.data['akismet_key'] && BlogBasic::BlogConf.data['blog_url']
|
|
54
|
+
if Akismetor.spam?(akismet_attributes)
|
|
55
|
+
self.errors.add_to_base('This comment has been detected as spam')
|
|
56
|
+
return false
|
|
57
|
+
else
|
|
58
|
+
return true
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
true
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def akismet_attributes
|
|
65
|
+
{
|
|
66
|
+
:key => BlogBasic::BlogConf.data['akismet_key'],
|
|
67
|
+
:blog => BlogBasic::BlogConf.data['blog_url'],
|
|
68
|
+
:user_ip => user_ip,
|
|
69
|
+
:user_agent => user_agent,
|
|
70
|
+
:comment_author => name,
|
|
71
|
+
:comment_author_email => email,
|
|
72
|
+
:comment_author_url => site_url,
|
|
73
|
+
:comment_content => body
|
|
74
|
+
}
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module BlogBasic
|
|
2
|
+
class BlogImage < ActiveRecord::Base
|
|
3
|
+
unloadable
|
|
4
|
+
|
|
5
|
+
belongs_to :blog_post
|
|
6
|
+
|
|
7
|
+
attr_accessor :random_id
|
|
8
|
+
|
|
9
|
+
# Check for paperclip
|
|
10
|
+
if self.respond_to?(:has_attached_file)
|
|
11
|
+
has_attached_file(:image, {
|
|
12
|
+
:styles => {
|
|
13
|
+
:original => '1000x1000>',
|
|
14
|
+
:large => '600x600>',
|
|
15
|
+
:medium => '300x300>',
|
|
16
|
+
:small => '100x100>',
|
|
17
|
+
:thumb => '30x30>'
|
|
18
|
+
}
|
|
19
|
+
}.merge(BlogConf.data['paperclip'] || {}))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module BlogBasic
|
|
2
|
+
class BlogPost < ActiveRecord::Base
|
|
3
|
+
include BlogBasic::BlogBasicModelHelper
|
|
4
|
+
include ActionView::Helpers::TextHelper
|
|
5
|
+
|
|
6
|
+
unloadable
|
|
7
|
+
|
|
8
|
+
belongs_to :user
|
|
9
|
+
|
|
10
|
+
has_many :blog_comments, :dependent => :destroy
|
|
11
|
+
has_many :blog_images, :dependent => :destroy
|
|
12
|
+
has_many :blog_contents
|
|
13
|
+
|
|
14
|
+
accepts_nested_attributes_for :blog_images, :allow_destroy => true
|
|
15
|
+
|
|
16
|
+
validates_presence_of :title
|
|
17
|
+
validates_presence_of :body
|
|
18
|
+
|
|
19
|
+
default_scope :order => 'published_at DESC'
|
|
20
|
+
|
|
21
|
+
scope :published, { :conditions => {:published => 1 }}
|
|
22
|
+
scope :drafts, { :conditions => {:published => 0 }}
|
|
23
|
+
|
|
24
|
+
before_save :check_published, :if => :not_resaving?
|
|
25
|
+
after_save :replace_blog_image_tags, :if => :not_resaving?
|
|
26
|
+
|
|
27
|
+
acts_as_taggable
|
|
28
|
+
|
|
29
|
+
def not_resaving?
|
|
30
|
+
!@resaving
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# For images that haven't been uploaded yet, they get a random image id
|
|
34
|
+
# with 'upload' infront of it. We replace those with their new image
|
|
35
|
+
# id
|
|
36
|
+
def replace_blog_image_tags
|
|
37
|
+
@resaving = true
|
|
38
|
+
self.body.gsub!(/[{]blog_image:upload[0-9]+:[a-zA-Z]+[}]/) do |image_tag|
|
|
39
|
+
random_id, size = image_tag.scan(/upload([0-9]+)[:]([a-zA-Z]+)/).flatten
|
|
40
|
+
|
|
41
|
+
new_id = random_id
|
|
42
|
+
|
|
43
|
+
matching_image = self.blog_images.reject {|bi| !bi.random_id || bi.random_id != random_id }.first
|
|
44
|
+
|
|
45
|
+
if matching_image
|
|
46
|
+
new_id = matching_image.id
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
"{blog_image:#{new_id}:#{size}}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
self.save
|
|
53
|
+
@resaving = false
|
|
54
|
+
|
|
55
|
+
return true
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def check_published
|
|
59
|
+
if self.published_change && self.published_change == [false, true]
|
|
60
|
+
# Moved to published state, update published_on
|
|
61
|
+
self.published_at = Time.now
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def show_user?
|
|
66
|
+
(!BlogConf.data['show_user_who_published'] || BlogConf.data['show_user_who_published'] == true) && self.user
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def user_name(skip_link=false)
|
|
71
|
+
if !skip_link && BlogConf.data['link_to_user']
|
|
72
|
+
return "<a href=\"/users/#{self.user.id}\">#{CGI.escapeHTML(self.user.name)}</a>"
|
|
73
|
+
else
|
|
74
|
+
return self.user.name
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def parsed_body(length=0)
|
|
79
|
+
image_parsed_body = self.body.gsub(/[{]blog_image[:]([0-9]+)[:]([a-zA-Z]+)[}]/) do |str|
|
|
80
|
+
puts "IMAGE ID: #{$1.to_i}"
|
|
81
|
+
img = BlogImage.find_by_id($1.to_i)
|
|
82
|
+
logger.debug img.inspect.to_s
|
|
83
|
+
if img
|
|
84
|
+
img.image.url($2)
|
|
85
|
+
else
|
|
86
|
+
''
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
if length > 0
|
|
90
|
+
image_parsed_body = truncate(image_parsed_body, :length => length, :separator => ' ')
|
|
91
|
+
end
|
|
92
|
+
return code_highlight_and_markdown(image_parsed_body)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def formatted_updated_at
|
|
96
|
+
self.updated_at.strftime(BlogConf.data['post_date_format'] || '%m/%d/%Y at %I:%M%p')
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Provide SEO Friendly URL's
|
|
100
|
+
def to_param
|
|
101
|
+
"#{id}-#{title.gsub(/[^a-z0-9]+/i, '-')}"
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module BlogBasic
|
|
2
|
+
class User < ActiveRecord::Base
|
|
3
|
+
|
|
4
|
+
def self.create_with_omniauth(auth)
|
|
5
|
+
create! do |user|
|
|
6
|
+
user.provider = auth["provider"]
|
|
7
|
+
user.uid = auth["uid"]
|
|
8
|
+
user.name = auth["user_info"]["name"]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def admin?
|
|
13
|
+
#self.email == "bottiger@gmail.com"
|
|
14
|
+
!self.identifier_url.nil?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def name
|
|
18
|
+
"Arvid Bottiger"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<div class="blogNewComment">
|
|
2
|
+
<h2>Post a Comment</h2>
|
|
3
|
+
<% if !current_user && (!BlogBasic::BlogConf.data['anonymous_comments'] || BlogBasic::BlogConf.data['anonymous_comments'] == false) %>
|
|
4
|
+
<p>You must be logged in to post a comment.</p>
|
|
5
|
+
<% else %>
|
|
6
|
+
<% if current_user %>
|
|
7
|
+
<p>Posting as <span class="blogPoster"><%=h current_user.name %></span></p>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% form_for([@blog_post, blog_comment]) do |f| %>
|
|
10
|
+
<% if blog_comment.errors.size > 0 %>
|
|
11
|
+
<div id="errorExplanation">
|
|
12
|
+
<h2>The comment could not be saved:</h2>
|
|
13
|
+
<ul>
|
|
14
|
+
<% blog_comment.errors.full_messages.each do |msg| %>
|
|
15
|
+
<li><%= msg %></li>
|
|
16
|
+
<% end %>
|
|
17
|
+
</ul>
|
|
18
|
+
</div>
|
|
19
|
+
<% end %>
|
|
20
|
+
<% unless current_user %>
|
|
21
|
+
<p>
|
|
22
|
+
<%= f.label :name %><br />
|
|
23
|
+
<%= f.text_field :name %>
|
|
24
|
+
</p>
|
|
25
|
+
<p>
|
|
26
|
+
<%= f.label :site_url, 'Web Site (optional)' %><br />
|
|
27
|
+
<%= f.text_field :site_url %>
|
|
28
|
+
</p>
|
|
29
|
+
<p>
|
|
30
|
+
<%= f.label :email, 'Email (optional)' %><br />
|
|
31
|
+
<%= f.text_field :email %>
|
|
32
|
+
</p>
|
|
33
|
+
<% end %>
|
|
34
|
+
<p>
|
|
35
|
+
<%= f.label :body, 'Comment' %><br />
|
|
36
|
+
<%= f.text_area :body, :class => 'blogNewCommentField' %>
|
|
37
|
+
</p>
|
|
38
|
+
<p>
|
|
39
|
+
<%= f.submit 'Post' %>
|
|
40
|
+
</p>
|
|
41
|
+
<% end %>
|
|
42
|
+
<% end %>
|
|
43
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% if current_user && current_user.admin? %>
|
|
2
|
+
<div class="blogAdminLinks">
|
|
3
|
+
<ul class="blogList">
|
|
4
|
+
<li class="blogListFirst"><%= link_to 'New Blog Post', new_blog_post_path %></li>
|
|
5
|
+
<li><%= link_to 'Edit Drafts', drafts_blog_posts_path %></li>
|
|
6
|
+
<li><%= link_to 'All Posts', blog_posts_path %></li>
|
|
7
|
+
</ul>
|
|
8
|
+
</div>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<% if params[:action] == 'show' %>
|
|
2
|
+
<% content_for :head do %><%= carnonical_link(blog_post) %><% end %>
|
|
3
|
+
<% end %>
|
|
4
|
+
<div class="blogPost">
|
|
5
|
+
<div class="blogUserImage">
|
|
6
|
+
<%= blog_post.user_image_tag %>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<h1 class="blogPostTitle header">
|
|
10
|
+
<%= link_to(h(blog_post.title), blog_post) %>
|
|
11
|
+
<% if !blog_post.published? %>
|
|
12
|
+
[Draft]
|
|
13
|
+
<% end %>
|
|
14
|
+
</h1>
|
|
15
|
+
|
|
16
|
+
<div class="blogPostBody">
|
|
17
|
+
<% if defined?(show_comments) %>
|
|
18
|
+
<%= blog_post.parsed_body %>
|
|
19
|
+
<% else %>
|
|
20
|
+
<%= blog_post.parsed_body(1000) %>
|
|
21
|
+
<% end %>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<% if params[:action] == 'show' %>
|
|
25
|
+
<p class="blogPostPostedAt">
|
|
26
|
+
<% if blog_post.show_user? %>
|
|
27
|
+
By <span class="blogPoster"><a rel="author" style="color: red" href="http://who.is.bottiger.org"><%= blog_post.user_name %></a></span>
|
|
28
|
+
<% end %>
|
|
29
|
+
if you liked it, hit the +1 like a man!
|
|
30
|
+
<g:plusone></g:plusone>
|
|
31
|
+
</p>
|
|
32
|
+
<% end %>
|
|
33
|
+
|
|
34
|
+
<p class="blogPostTags">
|
|
35
|
+
<b>Tags: </b>
|
|
36
|
+
<% blog_post.tag_list.each do |tag| %>
|
|
37
|
+
<%= link_to tag, tag_url(tag) %><% if tag != blog_post.tag_list.last %>, <% end %>
|
|
38
|
+
<% end %>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<p class="blogFooter">
|
|
42
|
+
<ul class="blogList">
|
|
43
|
+
<li class="blogListFirst"><%= link_to(pluralize(blog_post.blog_comments.count, 'comment'), blog_post_path(blog_post), :class => 'blogCommentCount') %></li>
|
|
44
|
+
<% if params[:action] == 'show' %>
|
|
45
|
+
<li><%= link_to('Back', blog_posts_path) %></li>
|
|
46
|
+
<% end %>
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<% if current_user && current_user.admin? %>
|
|
50
|
+
<li><%= link_to('Edit Post', edit_blog_post_path(blog_post))%></li>
|
|
51
|
+
<li><%= link_to('Delete', blog_post_path(blog_post), :method => :delete, :confirm => "Are you sure you want to destroy the post: #{blog_post.title}") %></li>
|
|
52
|
+
<% end %>
|
|
53
|
+
</ul>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<% if defined?(show_comments) %>
|
|
57
|
+
<%= render :partial => 'blog_basic/blog_comments/new_blog_comment', :locals => {:blog_comment => @blog_comment} %>
|
|
58
|
+
<%= render :partial => 'blog_basic/blog_posts/comments' %>
|
|
59
|
+
<% end %>
|
|
60
|
+
|
|
61
|
+
<br style="clear: both;" />
|
|
62
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div class="blogComment<% if comment.user && comment.user.respond_to?(:admin?) && comment.user.admin? %> blogCommentAdmin<% end %>">
|
|
2
|
+
<div class="blogUserImage">
|
|
3
|
+
<%= comment.user_image_tag %>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p class="blogCommentPostedAt">
|
|
7
|
+
By <span class="blogPoster"><%= display_name(comment.user_name, comment.site) %></span>
|
|
8
|
+
on
|
|
9
|
+
<span class="blogPostDate"><%= comment.formatted_created_at%></span>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<%= h(comment.parsed_body) %>
|
|
13
|
+
|
|
14
|
+
<% if current_user && current_user.admin? %>
|
|
15
|
+
<p><%= button_to('Delete', blog_post_blog_comment_path(@blog_post, comment), :method => :delete, :confirm => 'Are you sure you want to delete this comment?') %></p>
|
|
16
|
+
<% end %>
|
|
17
|
+
<br style="clear: both;" />
|
|
18
|
+
</div>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
function addImage() {
|
|
3
|
+
var newImageDiv = document.getElementById('newImage');
|
|
4
|
+
var blogImagesDiv = document.getElementById('blogImages');
|
|
5
|
+
|
|
6
|
+
var add_html = (newImageDiv.innerHTML+'').replace(/replace_with_rand/g, Math.round(Math.random() * 1000000000));
|
|
7
|
+
|
|
8
|
+
blogImagesDiv.innerHTML += add_html;
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function removeImage(image_id) {
|
|
13
|
+
document.getElementById('image_' + image_id).value = '1';
|
|
14
|
+
document.getElementById('imageDiv' + image_id).style.display = 'none';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function insertImage(image_id) {
|
|
18
|
+
var blogBody = document.getElementById('blog_post_body');
|
|
19
|
+
if (typeof(BLOG_EDITOR) !== 'undefined') {
|
|
20
|
+
BLOG_EDITOR.setContent(BLOG_EDITOR.getContent() + '\n<img src="{blog_image:' + image_id + ':large}" />\n');
|
|
21
|
+
} else {
|
|
22
|
+
blogBody.value += '\n\n';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
<%= form_for(@blog_post, :html => { :multipart => true }) do |f| %>
|
|
27
|
+
<% if BlogBasic::BlogConf.data['use_markdown'] == false && BlogBasic::BlogConf.data['html_editor'] == true %>
|
|
28
|
+
<script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script>
|
|
29
|
+
<script type="text/javascript">
|
|
30
|
+
bkLib.onDomLoaded(function() {
|
|
31
|
+
nicEditors.allTextAreas();
|
|
32
|
+
BLOG_EDITOR = nicEditors.findEditor('blog_post_body');
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
<% end %>
|
|
36
|
+
|
|
37
|
+
<div class="editBlogPost">
|
|
38
|
+
<div class="blogEditLeftPanel">
|
|
39
|
+
<% if @blog_post.errors.size > 0 %>
|
|
40
|
+
<div id="errorExplanation">
|
|
41
|
+
<h2>The blog post could not be saved:</h2>
|
|
42
|
+
<ul>
|
|
43
|
+
<% @blog_post.errors.full_messages.each do |msg| %>
|
|
44
|
+
<li><%= msg %></li>
|
|
45
|
+
<% end %>
|
|
46
|
+
</ul>
|
|
47
|
+
</div>
|
|
48
|
+
<% end %>
|
|
49
|
+
<p>
|
|
50
|
+
<%= f.label :title %><br />
|
|
51
|
+
<%= f.text_field :title %>
|
|
52
|
+
</p>
|
|
53
|
+
<p>
|
|
54
|
+
<%= f.label :body %><br />
|
|
55
|
+
<%= f.text_area :body, :size => "120x40" %>
|
|
56
|
+
</p>
|
|
57
|
+
<p>
|
|
58
|
+
<%= f.label :tags, 'Tags (comma seperated)' %><br />
|
|
59
|
+
<%= f.text_field :tag_list %>
|
|
60
|
+
</p>
|
|
61
|
+
<p>
|
|
62
|
+
<%= f.label :published, 'Status' %><br />
|
|
63
|
+
<%= f.radio_button :published,0 %><%= f.label :published_false, 'Draft' %>
|
|
64
|
+
<%= f.radio_button :published, 1 %><%= f.label :published_post, 'Post' %>
|
|
65
|
+
<%= f.radio_button :published, 2 %><%= f.label :published_page, 'Page' %>
|
|
66
|
+
</p>
|
|
67
|
+
<p>
|
|
68
|
+
<%= f.submit 'Save' %> or <%= link_to 'Back', blog_posts_path %>
|
|
69
|
+
</p>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="blogEditRightPanel">
|
|
72
|
+
<h2>Images</h2>
|
|
73
|
+
|
|
74
|
+
<p>
|
|
75
|
+
You can upload images for the blog post below and insert them using the [insert]
|
|
76
|
+
link. Once inserted, you can change the size to thumb, small, medium, or large.
|
|
77
|
+
Small is the default.
|
|
78
|
+
</p>
|
|
79
|
+
|
|
80
|
+
<table id="blogImages">
|
|
81
|
+
<tr class="blogImageHeader">
|
|
82
|
+
<td></td>
|
|
83
|
+
<td>Image</td>
|
|
84
|
+
<td>ID</td>
|
|
85
|
+
<td>File</td>
|
|
86
|
+
<td></td>
|
|
87
|
+
</td>
|
|
88
|
+
<%= f.fields_for(:blog_images) do |g| %>
|
|
89
|
+
<%= render :partial => 'image', :locals => {:g => g} %>
|
|
90
|
+
<% end %>
|
|
91
|
+
</table>
|
|
92
|
+
|
|
93
|
+
<button onclick="addImage();return false;">Add Image</button>
|
|
94
|
+
|
|
95
|
+
<% if BlogBasic::BlogConf.data['use_markdown'] != false %>
|
|
96
|
+
<div class="blogMarkdownHelp">
|
|
97
|
+
<h2>Editing Help</h2>
|
|
98
|
+
<p>This blog uses Markdown to format its syntax, here is a quick guide</p>
|
|
99
|
+
<ul>
|
|
100
|
+
<li>**bold text**</li>
|
|
101
|
+
<li>*italicized text*</li>
|
|
102
|
+
<li>>This text is blockquoted</li>
|
|
103
|
+
<li>>>This text is a nested blockquote</li>
|
|
104
|
+
<li>* This is an unordered list (ul) item</li>
|
|
105
|
+
<li>1. This is an ordered list (ol) item</li>
|
|
106
|
+
<li>[This is a link](http://www.example.com/)</li>
|
|
107
|
+
<li>[This is a link](http://www.example.com/ "with a title attribute")</li>
|
|
108
|
+
<li>
|
|
109
|
+
Code can be highlighted with the following wrapper<br />
|
|
110
|
+
|
|
111
|
+
<pre><code lang="ruby">
|
|
112
|
+
... your code ...
|
|
113
|
+
</code></pre>
|
|
114
|
+
</li>
|
|
115
|
+
</ul>
|
|
116
|
+
</div>
|
|
117
|
+
<% end %>
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
</div>
|
|
121
|
+
<br style="clear: both;" />
|
|
122
|
+
</div>
|
|
123
|
+
<% end %>
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
<!-- used to create new images -->
|
|
127
|
+
<table id="newImage" style="display: none;">
|
|
128
|
+
<%= fields_for(@empty_blog_post) do |h| %>
|
|
129
|
+
<%= h.fields_for(:blog_images, :child_index => 'replace_with_rand') do |g| %>
|
|
130
|
+
<%= render :partial => 'image', :locals => {:g => g} %>
|
|
131
|
+
<% end %>
|
|
132
|
+
<% end %>
|
|
133
|
+
</table>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<tr id="imageDiv<%= g.options[:child_index] || g.object.id %>">
|
|
2
|
+
<% if !g.object || g.object.new_record? %>
|
|
3
|
+
<td>[<a href="" onclick="insertImage('upload<%= g.options[:child_index] %>');return false;">Insert</a>]</td>
|
|
4
|
+
<td></td>
|
|
5
|
+
<td><%= g.options[:child_index] %></td>
|
|
6
|
+
<td>
|
|
7
|
+
<%= g.file_field(:image, :size => '10') %>
|
|
8
|
+
<%= g.hidden_field :random_id, :value => g.options[:child_index] %>
|
|
9
|
+
</td>
|
|
10
|
+
<% else %>
|
|
11
|
+
<td>[<a href="" onclick="insertImage(<%= g.object.id %>);return false;">Insert</a>]</td>
|
|
12
|
+
<td><img src="<%= g.object.image.url(:thumb) %>" /></td>
|
|
13
|
+
<td><%= g.object.id %></td>
|
|
14
|
+
<td class="imageFileName"><%= g.object.image_file_name %></td>
|
|
15
|
+
<% end %>
|
|
16
|
+
<td>
|
|
17
|
+
[<%= link_to_function('delete', "removeImage(#{g.options[:child_index] || g.object.id})") %>]
|
|
18
|
+
<%= g.hidden_field :_destroy, :id => "image_#{g.options[:child_index] || g.object.id}" %>
|
|
19
|
+
</td>
|
|
20
|
+
</tr>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<% self.respond_to?(:title) && title('Drafts') %>
|
|
2
|
+
<% @show_title = false -%>
|
|
3
|
+
<%= stylesheet_link_tag 'blog_kit' %>
|
|
4
|
+
<%= stylesheet_link_tag 'syntax/' + (BlogBasic::BlogConf.data['theme'] || 'mac_classic') %>
|
|
5
|
+
|
|
6
|
+
<%= render :partial => 'admin_links' %>
|
|
7
|
+
|
|
8
|
+
<% if @blog_posts.size == 0 && !params[:page] %>
|
|
9
|
+
<div class="blogPost">
|
|
10
|
+
<h1>No Blog Posts</h1>
|
|
11
|
+
<p>There are currently no blog posts, please check back shortly.</p>
|
|
12
|
+
</div>
|
|
13
|
+
<% else %>
|
|
14
|
+
<%= render :collection => @blog_posts, :partial => 'blog_post' %>
|
|
15
|
+
<% end %>
|
|
16
|
+
|
|
17
|
+
<div class="blogPages">
|
|
18
|
+
<%= will_paginate @blog_posts %>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<%= render :partial => 'admin_links' %>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
atom_feed do |feed|
|
|
2
|
+
feed.title(BlogBasic::BlogConf.data['blog_name'])
|
|
3
|
+
feed.updated(@blog_posts.first.created_at) if @blog_posts.first
|
|
4
|
+
|
|
5
|
+
@blog_posts.each do |post|
|
|
6
|
+
feed.entry(post) do |entry|
|
|
7
|
+
entry.title(post.title)
|
|
8
|
+
entry.content(post.parsed_body, :type => 'html')
|
|
9
|
+
#entry.author { |author| author.name(post.user_name(true)) }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|