blog_basic 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ module BlogBasic
8
8
  end
9
9
 
10
10
  def signed_in?
11
- logger.debug "(controller) Logged in: " + session[:user_id] + " == " + BlogBasic::BlogConf.data['identity']
11
+ logger.debug "(controller) Logged in: " + session[:user_id].to_s + " == " + BlogBasic::BlogConf.data['identity'].to_s
12
12
  session[:user_id] == BlogBasic::BlogConf.data['identity']
13
13
  end
14
14
 
@@ -3,7 +3,6 @@ module BlogBasic
3
3
  unloadable
4
4
 
5
5
  helper :all #blog, shared
6
- #include BlogBasic::Helpers
7
6
 
8
7
  layout :choose_layout
9
8
 
@@ -34,6 +33,7 @@ module BlogBasic
34
33
  end
35
34
 
36
35
  def show
36
+ logger.debug "(Show)ing blog post id: " + params[:id].to_s
37
37
  @blog_post = BlogPost.find(params[:id])
38
38
 
39
39
  unless @blog_post.published == 1
@@ -63,7 +63,9 @@ module BlogBasic
63
63
 
64
64
  def create
65
65
  @blog_post = BlogPost.new(params[:blog_post])
66
- @blog_post.user_id = current_user.id
66
+
67
+ logger.debug "blog_post controller (create) - FIXME"
68
+ @blog_post.user_id = 1 #current_user.id
67
69
  logger.debug "value: #{params[:blog_post][:published]}"
68
70
  @blog_post.published_at = Time.now if params[:blog_post][:published].to_i > 0 && @blog_post.published_at.nil?
69
71
 
@@ -124,7 +126,7 @@ module BlogBasic
124
126
  end
125
127
 
126
128
  def require_admin
127
- if !current_user || !current_user.admin?
129
+ if !signed_in?
128
130
  flash[:notice] = 'You must be an admin to view this page'
129
131
  redirect_to blog_posts_path
130
132
  return false
@@ -1,7 +1,7 @@
1
1
  module BlogBasic
2
2
  module ApplicationHelper
3
3
  def signed_in?
4
- logger.debug "(helper) Logged in: " + session[:user_id] + " == " + BlogBasic::BlogConf.data['identity']
4
+ logger.debug "(helper) Logged in: " + session[:user_id].to_s + " == " + BlogBasic::BlogConf.data['identity'].to_s
5
5
  session[:user_id] == BlogBasic::BlogConf.data['identity']
6
6
  end
7
7
 
@@ -12,6 +12,32 @@ module BlogBasic
12
12
 
13
13
  before_save :check_for_spam
14
14
 
15
+ def user_image_tag
16
+ if self.user && self.user.respond_to?(:blog_image_url) && self.user.blog_image_url
17
+ # Load image from model
18
+ ret = "<img src=\"#{self.user.blog_image_url}\" />"
19
+ elsif BlogConf.data['gravatar']
20
+ # Gravatar
21
+ require 'digest/md5'
22
+ if self.respond_to?(:email) && !self.email.blank?
23
+ email = self.email
24
+ elsif self.user && self.user.respond_to?(:email) && !self.user.email.blank?
25
+ email = self.user.email
26
+ else
27
+ return ''
28
+ end
29
+
30
+ hash = Digest::MD5.hexdigest(email.downcase)
31
+ ret = "<img src=\"http://www.gravatar.com/avatar/#{hash}.jpg\" />"
32
+ else
33
+ # No Image
34
+ return ''
35
+ end
36
+
37
+ return ret.html_safe if ret.respond_to?(:html_safe)
38
+ return ret
39
+ end
40
+
15
41
  def validate
16
42
  if !self.user
17
43
  self.errors.add(:name, 'is required') if self.name.blank?
@@ -1,15 +1,12 @@
1
1
  module BlogBasic
2
2
  class BlogPost < ActiveRecord::Base
3
3
 
4
- #include BlogBasic::BlogBasicModelHelper
5
4
  include ActionView::Helpers::TextHelper
6
5
 
7
6
  unloadable
8
7
 
9
8
  attr_accessible :title, :body, :tag_list, :published
10
9
 
11
- #belongs_to :user
12
-
13
10
  has_many :blog_comments, :dependent => :destroy
14
11
  has_many :blog_images, :dependent => :destroy
15
12
  has_many :blog_contents
@@ -79,9 +76,9 @@ module BlogBasic
79
76
  end
80
77
  end
81
78
 
82
- #def show_user?
83
- # (!BlogConf.data['show_user_who_published'] || BlogConf.data['show_user_who_published'] == true) && self.user
84
- #end
79
+ def show_user?
80
+ (!BlogConf.data['show_user_who_published'] || BlogConf.data['show_user_who_published'] == true)
81
+ end
85
82
 
86
83
 
87
84
  def user_name(skip_link=false)
@@ -3,9 +3,6 @@
3
3
  <% if !current_user && (!BlogBasic::BlogConf.data['anonymous_comments'] || BlogBasic::BlogConf.data['anonymous_comments'] == false) %>
4
4
  <p>You must be logged in to post a comment.</p>
5
5
  <% else %>
6
- <% if current_user %>
7
- <p>Posting as <span class="blogPoster"><%=h current_user.name %></span></p>
8
- <% end %>
9
6
  <% form_for([@blog_post, blog_comment]) do |f| %>
10
7
  <% if blog_comment.errors.size > 0 %>
11
8
  <div id="errorExplanation">
@@ -5,5 +5,6 @@
5
5
  <li><%= link_to 'Edit Drafts', drafts_blog_posts_path %></li>
6
6
  <li><%= link_to 'All Posts', blog_posts_path %></li>
7
7
  </ul>
8
+ Signed in as: <b><%= current_user %></b>
8
9
  </div>
9
10
  <% end %>
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = ["bottiger@gmail.com"]
11
11
  s.homepage = "http://bottiger.org/made/blog_basic"
12
12
  s.summary = "Provides a basic blogging platform"
13
- s.description = "Simply generates lorem ipsum text."
13
+ s.description = "blog_basic is a gem which allows you to set up a generic blog which rdoesnøt require any work in order t ointegrate with your website."
14
14
 
15
15
 
16
16
  s.add_dependency("bluecloth", "~> 2.2.0")
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency("coderay")
25
25
  s.add_dependency("will_paginate", "~> 3.0.3")
26
26
 
27
- s.add_development_dependency "rspec"
27
+ s.add_development_dependency("rspec-rails", "~> 2.0")
28
28
 
29
29
  s.rubyforge_project = "blog_basic"
30
30
 
@@ -1,3 +1,3 @@
1
1
  module BlogBasic
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.14"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blog_basic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bluecloth
16
- requirement: &3860640 !ruby/object:Gem::Requirement
16
+ requirement: &7405240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *3860640
24
+ version_requirements: *7405240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: paperclip
27
- requirement: &3871880 !ruby/object:Gem::Requirement
27
+ requirement: &7402100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *3871880
35
+ version_requirements: *7402100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sass-rails
38
- requirement: &3869440 !ruby/object:Gem::Requirement
38
+ requirement: &7400400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *3869440
46
+ version_requirements: *7400400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: meta_search
49
- requirement: &3890820 !ruby/object:Gem::Requirement
49
+ requirement: &7413360 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.1.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *3890820
57
+ version_requirements: *7413360
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: acts-as-taggable-on
60
- requirement: &3888060 !ruby/object:Gem::Requirement
60
+ requirement: &7410420 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.2.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *3888060
68
+ version_requirements: *7410420
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: omniauth
71
- requirement: &3899160 !ruby/object:Gem::Requirement
71
+ requirement: &7408560 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *3899160
79
+ version_requirements: *7408560
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: omniauth-openid
82
- requirement: &3897020 !ruby/object:Gem::Requirement
82
+ requirement: &7422080 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.0.0
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *3897020
90
+ version_requirements: *7422080
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: omniauth-github
93
- requirement: &3895560 !ruby/object:Gem::Requirement
93
+ requirement: &7417720 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.0.0
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *3895560
101
+ version_requirements: *7417720
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: coderay
104
- requirement: &3894620 !ruby/object:Gem::Requirement
104
+ requirement: &7428560 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *3894620
112
+ version_requirements: *7428560
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: will_paginate
115
- requirement: &3892800 !ruby/object:Gem::Requirement
115
+ requirement: &7426320 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,19 +120,20 @@ dependencies:
120
120
  version: 3.0.3
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *3892800
123
+ version_requirements: *7426320
124
124
  - !ruby/object:Gem::Dependency
125
- name: rspec
126
- requirement: &3891500 !ruby/object:Gem::Requirement
125
+ name: rspec-rails
126
+ requirement: &7438820 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
- - - ! '>='
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: '2.0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *3891500
135
- description: Simply generates lorem ipsum text.
134
+ version_requirements: *7438820
135
+ description: blog_basic is a gem which allows you to set up a generic blog which rdoesnøt
136
+ require any work in order t ointegrate with your website.
136
137
  email:
137
138
  - bottiger@gmail.com
138
139
  executables: []