blog_basic 0.1.9 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +177 -0
- data/README.md +27 -112
- data/Rakefile +24 -18
- data/app/controllers/blog_basic/app_controller.rb +4 -9
- data/app/controllers/blog_basic/sessions_controller.rb +1 -9
- data/app/helpers/blog_basic/application_helper.rb +3 -2
- data/app/helpers/blog_basic/shared_helper.rb +1 -3
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/blog_basic/blog_comment.rb +1 -1
- data/app/models/blog_basic/blog_post.rb +12 -10
- data/app/models/blog_basic/user.rb +12 -11
- data/app/views/blog_basic/blog_posts/_admin_links.html.erb +1 -1
- data/app/views/blog_basic/blog_posts/_blog_post.html.erb +2 -5
- data/blog_basic.gemspec +28 -53
- data/db/migrate/1_blog_tables.rb +1 -0
- data/lib/blog_basic/version.rb +3 -0
- data/lib/blog_basic.rb +2 -1
- data/lib/generators/blog_basic/install/install_generator.rb +2 -2
- data/lib/generators/blog_basic/install/templates/blog_basic.yml +4 -1
- data/lib/generators/blog_basic/install/templates/migrations/1_blog_tables.rb +1 -0
- data/test/fixtures/.gitkeep +0 -0
- data/test/functional/.gitkeep +0 -0
- data/test/integration/.gitkeep +0 -0
- data/test/unit/.gitkeep +0 -0
- metadata +61 -98
- data/app/admin/dashboards.rb +0 -38
- data/lib/generators/blog_basic/install/templates/active_admin.rb +0 -103
- data/lib/generators/blog_basic/install/templates/devise.en.yml +0 -58
- data/lib/generators/blog_basic/install/templates/devise.rb +0 -209
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
blog_basic (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actionmailer (3.1.3)
|
10
|
+
actionpack (= 3.1.3)
|
11
|
+
mail (~> 2.3.0)
|
12
|
+
actionpack (3.1.3)
|
13
|
+
activemodel (= 3.1.3)
|
14
|
+
activesupport (= 3.1.3)
|
15
|
+
builder (~> 3.0.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
i18n (~> 0.6)
|
18
|
+
rack (~> 1.3.5)
|
19
|
+
rack-cache (~> 1.1)
|
20
|
+
rack-mount (~> 0.8.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.0.3)
|
23
|
+
activemodel (3.1.3)
|
24
|
+
activesupport (= 3.1.3)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
i18n (~> 0.6)
|
27
|
+
activerecord (3.1.3)
|
28
|
+
activemodel (= 3.1.3)
|
29
|
+
activesupport (= 3.1.3)
|
30
|
+
arel (~> 2.2.1)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.1.3)
|
33
|
+
activemodel (= 3.1.3)
|
34
|
+
activesupport (= 3.1.3)
|
35
|
+
activesupport (3.1.3)
|
36
|
+
multi_json (~> 1.0)
|
37
|
+
acts-as-taggable-on (2.1.1)
|
38
|
+
rails
|
39
|
+
addressable (2.2.6)
|
40
|
+
arel (2.2.1)
|
41
|
+
bluecloth (2.2.0)
|
42
|
+
builder (3.0.0)
|
43
|
+
cocaine (0.2.1)
|
44
|
+
coffee-script (2.2.0)
|
45
|
+
coffee-script-source
|
46
|
+
execjs
|
47
|
+
coffee-script-source (1.1.3)
|
48
|
+
diff-lcs (1.1.3)
|
49
|
+
erubis (2.7.0)
|
50
|
+
execjs (1.2.12)
|
51
|
+
multi_json (~> 1.0)
|
52
|
+
faraday (0.7.5)
|
53
|
+
addressable (~> 2.2.6)
|
54
|
+
multipart-post (~> 1.1.3)
|
55
|
+
rack (>= 1.1.0, < 2)
|
56
|
+
hashie (1.2.0)
|
57
|
+
hike (1.2.1)
|
58
|
+
i18n (0.6.0)
|
59
|
+
jquery-rails (1.0.19)
|
60
|
+
railties (~> 3.0)
|
61
|
+
thor (~> 0.14)
|
62
|
+
json (1.6.3)
|
63
|
+
mail (2.3.0)
|
64
|
+
i18n (>= 0.4.0)
|
65
|
+
mime-types (~> 1.16)
|
66
|
+
treetop (~> 1.4.8)
|
67
|
+
meta_search (1.1.1)
|
68
|
+
actionpack (~> 3.1.0)
|
69
|
+
activerecord (~> 3.1.0)
|
70
|
+
activesupport (~> 3.1.0)
|
71
|
+
polyamorous (~> 0.5.0)
|
72
|
+
mime-types (1.17.2)
|
73
|
+
multi_json (1.0.4)
|
74
|
+
multipart-post (1.1.4)
|
75
|
+
oauth2 (0.5.1)
|
76
|
+
faraday (~> 0.7.4)
|
77
|
+
multi_json (~> 1.0.3)
|
78
|
+
omniauth (1.0.1)
|
79
|
+
hashie (~> 1.2)
|
80
|
+
rack
|
81
|
+
omniauth-github (1.0.1)
|
82
|
+
omniauth (~> 1.0)
|
83
|
+
omniauth-oauth2 (~> 1.0)
|
84
|
+
omniauth-oauth2 (1.0.0)
|
85
|
+
oauth2 (~> 0.5.0)
|
86
|
+
omniauth (~> 1.0)
|
87
|
+
omniauth-openid (1.0.1)
|
88
|
+
omniauth (~> 1.0)
|
89
|
+
rack-openid (~> 1.3.1)
|
90
|
+
paperclip (2.4.5)
|
91
|
+
activerecord (>= 2.3.0)
|
92
|
+
activesupport (>= 2.3.2)
|
93
|
+
cocaine (>= 0.0.2)
|
94
|
+
mime-types
|
95
|
+
polyamorous (0.5.0)
|
96
|
+
activerecord (~> 3.0)
|
97
|
+
polyglot (0.3.3)
|
98
|
+
rack (1.3.5)
|
99
|
+
rack-cache (1.1)
|
100
|
+
rack (>= 0.4)
|
101
|
+
rack-mount (0.8.3)
|
102
|
+
rack (>= 1.0.0)
|
103
|
+
rack-openid (1.3.1)
|
104
|
+
rack (>= 1.1.0)
|
105
|
+
ruby-openid (>= 2.1.8)
|
106
|
+
rack-ssl (1.3.2)
|
107
|
+
rack
|
108
|
+
rack-test (0.6.1)
|
109
|
+
rack (>= 1.0)
|
110
|
+
rails (3.1.3)
|
111
|
+
actionmailer (= 3.1.3)
|
112
|
+
actionpack (= 3.1.3)
|
113
|
+
activerecord (= 3.1.3)
|
114
|
+
activeresource (= 3.1.3)
|
115
|
+
activesupport (= 3.1.3)
|
116
|
+
bundler (~> 1.0)
|
117
|
+
railties (= 3.1.3)
|
118
|
+
railties (3.1.3)
|
119
|
+
actionpack (= 3.1.3)
|
120
|
+
activesupport (= 3.1.3)
|
121
|
+
rack-ssl (~> 1.3.2)
|
122
|
+
rake (>= 0.8.7)
|
123
|
+
rdoc (~> 3.4)
|
124
|
+
thor (~> 0.14.6)
|
125
|
+
rake (0.9.2.2)
|
126
|
+
rdoc (3.11)
|
127
|
+
json (~> 1.4)
|
128
|
+
rspec (2.10.0)
|
129
|
+
rspec-core (~> 2.10.0)
|
130
|
+
rspec-expectations (~> 2.10.0)
|
131
|
+
rspec-mocks (~> 2.10.0)
|
132
|
+
rspec-core (2.10.1)
|
133
|
+
rspec-expectations (2.10.0)
|
134
|
+
diff-lcs (~> 1.1.3)
|
135
|
+
rspec-mocks (2.10.1)
|
136
|
+
ruby-openid (2.1.8)
|
137
|
+
sass (3.1.11)
|
138
|
+
sass-rails (3.1.5)
|
139
|
+
actionpack (~> 3.1.0)
|
140
|
+
railties (~> 3.1.0)
|
141
|
+
sass (~> 3.1.10)
|
142
|
+
tilt (~> 1.3.2)
|
143
|
+
sprockets (2.0.3)
|
144
|
+
hike (~> 1.2)
|
145
|
+
rack (~> 1.0)
|
146
|
+
tilt (~> 1.1, != 1.3.0)
|
147
|
+
thor (0.14.6)
|
148
|
+
tilt (1.3.3)
|
149
|
+
treetop (1.4.10)
|
150
|
+
polyglot
|
151
|
+
polyglot (>= 0.3.1)
|
152
|
+
tzinfo (0.3.31)
|
153
|
+
uglifier (1.1.0)
|
154
|
+
execjs (>= 0.3.0)
|
155
|
+
multi_json (>= 1.0.2)
|
156
|
+
will_paginate (3.0.2)
|
157
|
+
|
158
|
+
PLATFORMS
|
159
|
+
ruby
|
160
|
+
|
161
|
+
DEPENDENCIES
|
162
|
+
acts-as-taggable-on
|
163
|
+
blog_basic!
|
164
|
+
bluecloth (~> 2.2.0)
|
165
|
+
coffee-script
|
166
|
+
jquery-rails
|
167
|
+
json
|
168
|
+
meta_search (>= 1.1.0.pre)
|
169
|
+
omniauth (~> 1.0.0)
|
170
|
+
omniauth-github (~> 1.0.0)
|
171
|
+
omniauth-openid (~> 1.0.0)
|
172
|
+
paperclip (~> 2.3)
|
173
|
+
rspec
|
174
|
+
sass
|
175
|
+
sass-rails
|
176
|
+
uglifier
|
177
|
+
will_paginate
|
data/README.md
CHANGED
@@ -3,18 +3,23 @@ blog_basic
|
|
3
3
|
|
4
4
|
blog_basic is a fork of the rails plugin BlogKit (https://github.com/ryanstout/blog_kit)
|
5
5
|
|
6
|
-
|
6
|
+
It aims to be a gem which provides a simple and generic blogging service for people to run on their website.
|
7
|
+
It is made as easy as possible to deploy, and requires no external intregration to work.
|
8
|
+
|
9
|
+
blog_basic is self contained inside its own namespace and rails engine, and uses you google account
|
10
|
+
(or any other providor omniauth supports) for easy and seemless authentication
|
11
|
+
|
12
|
+
Features
|
7
13
|
========
|
8
14
|
|
9
|
-
|
15
|
+
Blog_basic is a rails plugin to add a blog to your application. The goal is to provide common blog
|
10
16
|
functionality that integrates into your existing app while keeping things simple.
|
11
17
|
|
12
18
|
BlogKitty has the following features.
|
13
19
|
|
14
20
|
+ Admin for Blog Articles
|
15
21
|
+ Search engine friendly urls
|
16
|
-
+
|
17
|
-
+ Comments via existing user model
|
22
|
+
+ Comments
|
18
23
|
+ Uses your existing layouts
|
19
24
|
+ Easily customizable css
|
20
25
|
+ Akismet (spam filtering) Support
|
@@ -25,9 +30,17 @@ BlogKitty has the following features.
|
|
25
30
|
+ Tags
|
26
31
|
+ Image upload (via paperclip, or something that adds has_attached_file to models)
|
27
32
|
|
33
|
+
Status
|
34
|
+
======
|
35
|
+
|
36
|
+
Blog_basic is currently fully working. However, it still needs to mature quite a bit. The testing is lacking,
|
37
|
+
there is still a lot of code cleaning to do, configuration should be improved etc.
|
28
38
|
|
29
|
-
|
30
|
-
|
39
|
+
Futhermore I need to get some feedback from people actually using it. Currently I'm just scratching my own itch, but would love to
|
40
|
+
hear what other people want from a blogging system.
|
41
|
+
|
42
|
+
Installation
|
43
|
+
============
|
31
44
|
|
32
45
|
Add blog_basic to your Gemfile
|
33
46
|
|
@@ -35,14 +48,11 @@ Add blog_basic to your Gemfile
|
|
35
48
|
|
36
49
|
then run "bundle install" to make sure you are up to date. Install blog_basic my running the generator blog_basic:install
|
37
50
|
|
38
|
-
|
51
|
+
rails g blog_basic:install
|
39
52
|
|
40
53
|
and migrate your database
|
41
54
|
|
42
|
-
|
43
|
-
|
44
|
-
edit config/initializers/blog_omniauth.rb
|
45
|
-
and config/blog_basic.yml
|
55
|
+
rake db:migrate
|
46
56
|
|
47
57
|
Now adjust config/routes.rb for your desired path and config/blog_basic.yml for the rest of the configuration
|
48
58
|
|
@@ -57,118 +67,21 @@ Blog_basic makes the following assumptions
|
|
57
67
|
Setup
|
58
68
|
=====
|
59
69
|
|
60
|
-
|
61
|
-
called User. Your User class and application controller simply need to respond to some methods to
|
62
|
-
be able to use BlogKit. These methods, while not standardized are very common, and come with plugins
|
63
|
-
like Authlogic and restful_authentication.
|
64
|
-
|
65
|
-
ApplicationController should respond to:
|
66
|
-
#require_user
|
67
|
-
#current_user
|
68
|
-
#title - (optional passes in the pages title as the first argument)
|
70
|
+
Blog_baisc tries to be as unintrusive as possible with regards to your current authentication system.
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
#name - the users name
|
73
|
-
#blog_image_url (optional, the users photo, show next to comments/posts)
|
74
|
-
#email (options - for gravatar support)
|
75
|
-
|
76
|
-
Once you have everything setup, you can see and manage the blog at /blog_posts Make sure that you have
|
77
|
-
all of the requirements below met.
|
78
|
-
|
79
|
-
Rails 3 is supported via the rails3 branch, if you are using legacy routing, you may need to copy in routes
|
80
|
-
from config/routes.rb to your main routes.rb file.
|
81
|
-
|
82
|
-
To be able to use the delete links on posts, you will need to add the following to the top of your layout:
|
83
|
-
|
84
|
-
<%= csrf_meta_tag %>
|
85
|
-
|
86
|
-
Also be sure that you have the proper javascript handling code for link_to '', :method => destroy
|
72
|
+
In the future it will integrate with your existing user model, but currently it only uses your github account to
|
73
|
+
authenticate thus eliminating the use of a User model, and makes the authentication process as simple as possible.
|
87
74
|
|
88
75
|
Requirements
|
89
76
|
============
|
90
77
|
|
91
|
-
Rails 3.
|
92
|
-
|
93
|
-
- Will_Paginate
|
94
|
-
|
95
|
-
Optional:
|
96
|
-
|
97
|
-
- Ultraviolet (and its deps, for code highlighting)
|
98
|
-
|
99
|
-
Install Oniguruma if 1.8.x
|
100
|
-
http://www.geocities.jp/kosako3/oniguruma/
|
101
|
-
|
102
|
-
source 'http://gems.github.com'
|
103
|
-
gem "spox-ultraviolet", :require => false
|
104
|
-
|
105
|
-
- BlueCloth 2 (for markdown)
|
106
|
-
|
107
|
-
gem 'bluecloth'
|
108
|
-
|
109
|
-
- Paperclip
|
110
|
-
|
111
|
-
gem 'paperclip', :git => 'http://github.com/thoughtbot/paperclip.git', :branch => 'rails3'
|
78
|
+
blog_basic has been written for Rails 3.2 and later.
|
112
79
|
|
113
80
|
Customization
|
114
81
|
=============
|
115
82
|
|
116
83
|
Be sure to edit config/blog_kit.yml, many common settings can be changed there.
|
117
84
|
|
118
|
-
** View Customization **
|
119
|
-
|
120
|
-
BlogKit is built as a rails engine plugin (for rails 2.3.x, not the previous engines plugin). You can see
|
121
|
-
the models, views, and controllers in vendor/plugins/blog_kit/app/ You can change them by copying any of
|
122
|
-
them into your apps /app directory. Rails will look in /app before looking in vendor/plugins/blog_kit/app/
|
123
|
-
Once they are copied into /app, you can customize the appearance/behavior of the blog pages.
|
124
|
-
|
125
|
-
Troubleshooting
|
126
|
-
===============
|
127
|
-
|
128
|
-
Q. Creating a blog post does not work, it instead renders the index page.
|
129
|
-
A. Make sure you aren't using the old style default routes in rails (match '/:controller(/:action(/:id))')
|
130
|
-
If you are using default routes, then simply copy the following into your routes.rb file before the default route
|
131
|
-
|
132
|
-
resources :blog_posts do
|
133
|
-
resources :blog_comments
|
134
|
-
resources :blog_images
|
135
|
-
|
136
|
-
collection do
|
137
|
-
get :drafts
|
138
|
-
end
|
139
|
-
|
140
|
-
member do
|
141
|
-
get :tag
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
Tag List
|
146
|
-
========
|
147
|
-
|
148
|
-
By default, the layout does not display a list of all tags. This can be easily added to any layout in the
|
149
|
-
application by including this in the controller:
|
150
|
-
|
151
|
-
helper :blog
|
152
|
-
|
153
|
-
Then in the view:
|
154
|
-
|
155
|
-
<%= blog_tags_list %>
|
156
|
-
|
157
|
-
You can optionally pass in a limit on the number of tags to show.
|
158
|
-
|
159
|
-
Also keep in mind that you can specify a layout just for the blog kit pages.
|
160
|
-
|
161
|
-
Titles
|
162
|
-
======
|
163
|
-
|
164
|
-
You can have blog_kit set the page title, just create a method in application_helper like:
|
165
|
-
|
166
|
-
def title(ttl)
|
167
|
-
@page_title = ttl
|
168
|
-
end
|
169
|
-
|
170
|
-
If anyone knows of a better convention for this, let me know. This is what nifty_generators uses
|
171
|
-
|
172
85
|
Code Highlighting Example
|
173
86
|
=========================
|
174
87
|
|
@@ -183,3 +96,5 @@ doc/THEMES
|
|
183
96
|
|
184
97
|
|
185
98
|
Copyright (c) 2010 Ryan Stout, released under the MIT license
|
99
|
+
|
100
|
+
Copyright (c) 2012 Arvid Boettiger, still released under the MIT license :)
|
data/Rakefile
CHANGED
@@ -5,19 +5,25 @@ require 'rake/testtask'
|
|
5
5
|
#require 'spec'
|
6
6
|
#require 'spec/rake/spectask'
|
7
7
|
|
8
|
-
require 'rubygems'
|
8
|
+
#require 'rubygems'
|
9
9
|
require 'echoe'
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
p.
|
16
|
-
p.
|
17
|
-
p.
|
18
|
-
|
11
|
+
require 'bundler'
|
12
|
+
Bundler::GemHelper.install_tasks
|
13
|
+
|
14
|
+
#Echoe.new('blog_basic', '0.1.9') do |p|
|
15
|
+
# p.name = "Blog Basic"
|
16
|
+
# p.description = "Sets up a basic but functional blogging platform."
|
17
|
+
# p.url = "http://bottiger.org/made/blog_basic"
|
18
|
+
# p.author = "Arvid Boettiger"
|
19
|
+
# p.email = "bottiger@gmail.com"
|
20
|
+
# p.ignore_pattern = ["tmp/*", "script/*"]
|
21
|
+
# p.runtime_dependencies = ['bluecloth ~>2.2.0', 'will_paginate', "paperclip >=2.3", "sass-rails", "meta_search ~>1.1.1", "acts-as-taggable-on ~>2.1.1", "omniauth ~>1.0.0", "omniauth-openid ~>1.0.0", "omniauth-github ~>1.0.0", "coderay"]
|
22
|
+
#
|
23
|
+
# p.require_signed = true
|
24
|
+
#end
|
19
25
|
|
20
|
-
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
26
|
+
#Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
21
27
|
|
22
28
|
|
23
29
|
#desc 'Test the blog_kit plugin.'
|
@@ -28,14 +34,14 @@ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
|
28
34
|
# t.verbose = true
|
29
35
|
#end
|
30
36
|
|
31
|
-
desc 'Generate documentation for the blog_basic plugin.'
|
32
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
33
|
-
rdoc.rdoc_dir = 'rdoc'
|
34
|
-
rdoc.title = 'BlogBasic'
|
35
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
36
|
-
rdoc.rdoc_files.include('README')
|
37
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
|
-
end
|
37
|
+
#desc 'Generate documentation for the blog_basic plugin.'
|
38
|
+
#RDoc::Task.new(:rdoc) do |rdoc|
|
39
|
+
# rdoc.rdoc_dir = 'rdoc'
|
40
|
+
# rdoc.title = 'BlogBasic'
|
41
|
+
# rdoc.options << '--line-numbers' << '--inline-source'
|
42
|
+
# rdoc.rdoc_files.include('README')
|
43
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
#end
|
39
45
|
|
40
46
|
#desc 'Default: run specs.'
|
41
47
|
#task :default => :spec
|
@@ -4,24 +4,19 @@ module BlogBasic
|
|
4
4
|
helper :all
|
5
5
|
|
6
6
|
def require_user
|
7
|
-
|
7
|
+
session[:user_id]
|
8
8
|
end
|
9
9
|
|
10
10
|
def signed_in?
|
11
|
-
|
11
|
+
logger.debug "(controller) Logged in: " + session[:user_id] + " == " + BlogBasic::BlogConf.data['identity']
|
12
|
+
session[:user_id] == BlogBasic::BlogConf.data['identity']
|
12
13
|
end
|
13
14
|
|
14
15
|
def current_user
|
15
16
|
logger.info "Current user ID: " + session[:user_id].to_s
|
16
17
|
if signed_in?
|
17
|
-
|
18
|
+
session[:user_id]
|
18
19
|
end
|
19
20
|
end
|
20
|
-
|
21
|
-
# def current_user
|
22
|
-
# logger.info "(from app_controller.rb) Current user ID: " + session[:user_id].to_s
|
23
|
-
# return session[:user_id].nil? ? User.new : User.find(session[:user_id])
|
24
|
-
# end
|
25
|
-
|
26
21
|
end
|
27
22
|
end
|
@@ -7,21 +7,13 @@ module BlogBasic
|
|
7
7
|
|
8
8
|
def create
|
9
9
|
auth = request.env["omniauth.auth"]
|
10
|
-
logger.debug "Auth:" + auth.inspect
|
11
|
-
user = User.where(:identifier_url => auth["uid"].to_s).first
|
12
|
-
logger.debug "newlinedddd"
|
13
|
-
logger.debug "Here, uid:" + auth["uid"].to_s + ", email:" + auth["info"].inspect
|
14
|
-
user ||= User.create!(:identifier_url => auth["uid"].to_s)
|
15
|
-
logger.debug "userid" + user.id.to_s
|
16
10
|
#user ||= User.create!(:identifier_url => auth["uid"],
|
17
11
|
# :email => auth["info"]["email"],
|
18
12
|
# :first_name => auth["info"]["first_name"],
|
19
13
|
# :last_name => auth["info"]["last_name"])
|
20
14
|
#user = User.create_with_omniauth(auth)
|
21
|
-
session[:user_id] =
|
22
|
-
logger.debug "before"
|
15
|
+
session[:user_id] = auth["info"]["email"]
|
23
16
|
redirect_to '/', :notice => "Signed in!"
|
24
|
-
logger.debug "after"
|
25
17
|
end
|
26
18
|
|
27
19
|
def destroy
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module BlogBasic
|
2
2
|
module ApplicationHelper
|
3
3
|
def signed_in?
|
4
|
-
|
4
|
+
logger.debug "(helper) Logged in: " + session[:user_id] + " == " + BlogBasic::BlogConf.data['identity']
|
5
|
+
session[:user_id] == BlogBasic::BlogConf.data['identity']
|
5
6
|
end
|
6
7
|
|
7
8
|
def current_user
|
8
9
|
logger.info "Current user ID: " + session[:user_id].to_s
|
9
10
|
if signed_in?
|
10
|
-
|
11
|
+
session[:user_id]
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
File without changes
|
data/app/models/.gitkeep
ADDED
File without changes
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module BlogBasic
|
2
2
|
class BlogPost < ActiveRecord::Base
|
3
|
-
|
3
|
+
|
4
|
+
#include BlogBasic::BlogBasicModelHelper
|
4
5
|
include ActionView::Helpers::TextHelper
|
5
6
|
|
6
7
|
unloadable
|
7
8
|
|
8
9
|
attr_accessible :title, :body, :tag_list, :published
|
9
10
|
|
10
|
-
belongs_to :user
|
11
|
+
#belongs_to :user
|
11
12
|
|
12
13
|
has_many :blog_comments, :dependent => :destroy
|
13
14
|
has_many :blog_images, :dependent => :destroy
|
@@ -78,17 +79,18 @@ module BlogBasic
|
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
81
|
-
def show_user?
|
82
|
-
|
83
|
-
end
|
82
|
+
#def show_user?
|
83
|
+
# (!BlogConf.data['show_user_who_published'] || BlogConf.data['show_user_who_published'] == true) && self.user
|
84
|
+
#end
|
84
85
|
|
85
86
|
|
86
87
|
def user_name(skip_link=false)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
return BlogConf.data['name']
|
89
|
+
#if !skip_link && BlogConf.data['link_to_user']
|
90
|
+
# return "<a href=\"/users/#{self.user.id}\">#{CGI.escapeHTML(self.user.name)}</a>"
|
91
|
+
#else
|
92
|
+
# return self.user.name
|
93
|
+
#end
|
92
94
|
end
|
93
95
|
|
94
96
|
def parsed_body(length=0)
|
@@ -6,20 +6,21 @@ module BlogBasic
|
|
6
6
|
|
7
7
|
|
8
8
|
def default_values
|
9
|
-
self.status ||= BlogBasic::BlogConf.data['
|
9
|
+
self.status ||= BlogBasic::BlogConf.data['name']
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
12
|
+
## To be deleted
|
13
|
+
#def self.create_with_omniauth(auth)
|
14
|
+
# create! do |user|
|
15
|
+
# user.provider = auth["provider"]
|
16
|
+
# user.uid = auth["uid"]
|
17
|
+
# user.name = auth["user_info"]["name"]
|
18
|
+
# end
|
19
|
+
#end
|
19
20
|
|
20
|
-
def admin?
|
21
|
-
|
22
|
-
end
|
21
|
+
#def admin?
|
22
|
+
# !self.identifier_url.nil?
|
23
|
+
#end
|
23
24
|
|
24
25
|
def name
|
25
26
|
self.name
|
@@ -2,9 +2,6 @@
|
|
2
2
|
<% content_for :head do %><%= carnonical_link(blog_post) %><% end %>
|
3
3
|
<% end %>
|
4
4
|
<div class="blogPost">
|
5
|
-
<div class="blogUserImage">
|
6
|
-
<%= blog_post.user_image_tag %>
|
7
|
-
</div>
|
8
5
|
|
9
6
|
<h1 class="blogPostTitle header">
|
10
7
|
<%= link_to(h(blog_post.title), blog_post) %>
|
@@ -24,7 +21,7 @@
|
|
24
21
|
<% if params[:action] == 'show' %>
|
25
22
|
<p class="blogPostPostedAt">
|
26
23
|
<% if blog_post.show_user? %>
|
27
|
-
By <span class="blogPoster"><a rel="author" style="color: red" href
|
24
|
+
By <span class="blogPoster"><a rel="author" style="color: red" href=/"><%= blog_post.user_name %></a></span>
|
28
25
|
<% end %>
|
29
26
|
if you liked it, hit the +1 like a man!
|
30
27
|
<g:plusone></g:plusone>
|
@@ -46,7 +43,7 @@
|
|
46
43
|
<% end %>
|
47
44
|
|
48
45
|
|
49
|
-
<% if
|
46
|
+
<% if signed_in? %>
|
50
47
|
<li><%= link_to('Edit Post', edit_blog_post_path(blog_post))%></li>
|
51
48
|
<li><%= link_to('Delete', blog_post_path(blog_post), :method => :delete, :confirm => "Are you sure you want to delete the post: #{blog_post.title}") %></li>
|
52
49
|
<% end %>
|