kublog 0.0.1.1
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/.gitignore +9 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +177 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +102 -0
- data/Rakefile +39 -0
- data/app/assets/images/kublog/.gitkeep +0 -0
- data/app/assets/images/kublog/missing_image.png +0 -0
- data/app/assets/javascripts/kublog/application.js +13 -0
- data/app/assets/javascripts/kublog/categories.js.coffee +48 -0
- data/app/assets/javascripts/kublog/comments.js.coffee +30 -0
- data/app/assets/javascripts/kublog/email.js.coffee +32 -0
- data/app/assets/javascripts/kublog/images.js.coffee +77 -0
- data/app/assets/javascripts/kublog/posts.js.coffee +44 -0
- data/app/assets/javascripts/kublog/shared.js.coffee.erb +19 -0
- data/app/assets/javascripts/kublog/wysiwyg.controls.js.coffee +68 -0
- data/app/assets/plugins/kublog/ajaxyupload/images/ajax-loader.gif +0 -0
- data/app/assets/plugins/kublog/ajaxyupload/javascripts/jquery.ajaxyupload.js +126 -0
- data/app/assets/plugins/kublog/fancybox/images/blank.gif +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_close.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_loading.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_nav_left.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_nav_right.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_shadow_e.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_shadow_n.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_shadow_ne.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_shadow_nw.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_shadow_s.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_shadow_se.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_shadow_sw.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_shadow_w.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_title_left.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_title_main.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_title_over.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancy_title_right.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancybox-x.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancybox-y.png +0 -0
- data/app/assets/plugins/kublog/fancybox/images/fancybox.png +0 -0
- data/app/assets/plugins/kublog/fancybox/javascripts/fancybox-1.3.4.js +46 -0
- data/app/assets/plugins/kublog/fancybox/stylesheets/fancybox-1.3.4.css +359 -0
- data/app/assets/plugins/kublog/livequery/javascripts/jquery.livequery.js +250 -0
- data/app/assets/plugins/kublog/wysiwyg/images/ajax-loader.gif +0 -0
- data/app/assets/plugins/kublog/wysiwyg/images/jquery.wysiwyg.bg.png +0 -0
- data/app/assets/plugins/kublog/wysiwyg/images/jquery.wysiwyg.gif +0 -0
- data/app/assets/plugins/kublog/wysiwyg/images/jquery.wysiwyg.jpg +0 -0
- data/app/assets/plugins/kublog/wysiwyg/images/jquery.wysiwyg.no-alpha.gif +0 -0
- data/app/assets/plugins/kublog/wysiwyg/javascripts/jquery.wysiwyg.js +2377 -0
- data/app/assets/plugins/kublog/wysiwyg/javascripts/wysiwyg.image.js +284 -0
- data/app/assets/plugins/kublog/wysiwyg/javascripts/wysiwyg.link.js +249 -0
- data/app/assets/plugins/kublog/wysiwyg/stylesheets/jquery.wysiwyg.css +94 -0
- data/app/assets/stylesheets/kublog/application.css +9 -0
- data/app/assets/stylesheets/kublog/categories.css +4 -0
- data/app/assets/stylesheets/kublog/comments.css +4 -0
- data/app/assets/stylesheets/kublog/email.css +7 -0
- data/app/assets/stylesheets/kublog/images.css +41 -0
- data/app/assets/stylesheets/kublog/posts.css +39 -0
- data/app/controllers/kublog/application_controller.rb +12 -0
- data/app/controllers/kublog/categories_controller.rb +47 -0
- data/app/controllers/kublog/comments_controller.rb +37 -0
- data/app/controllers/kublog/images_controller.rb +44 -0
- data/app/controllers/kublog/posts_controller.rb +66 -0
- data/app/helpers/kublog/application_helper.rb +4 -0
- data/app/helpers/kublog/posts_helper.rb +38 -0
- data/app/mailers/kublog/post_mailer.rb +11 -0
- data/app/models/kublog/category.rb +26 -0
- data/app/models/kublog/comment.rb +46 -0
- data/app/models/kublog/image.rb +23 -0
- data/app/models/kublog/post.rb +51 -0
- data/app/presenters/kublog/post_presenter.rb +23 -0
- data/app/presenters/kublog/posts_presenter.rb +29 -0
- data/app/uploaders/kublog/file_uploader.rb +56 -0
- data/app/views/kublog/post_mailer/new_post.html.erb +1 -0
- data/app/views/kublog/post_mailer/new_post.liquid.html.erb +7 -0
- data/app/views/kublog/posts/_email_form.html.erb +13 -0
- data/app/views/kublog/posts/_form.html.erb +71 -0
- data/app/views/kublog/posts/_image_form.html.erb +26 -0
- data/app/views/kublog/posts/edit.html.erb +3 -0
- data/app/views/kublog/posts/index.atom.builder +15 -0
- data/app/views/kublog/posts/index.html.erb +36 -0
- data/app/views/kublog/posts/new.html.erb +3 -0
- data/app/views/kublog/posts/show.html.erb +46 -0
- data/app/views/layouts/kublog/application.html.erb +14 -0
- data/config/locales/kublog/en.yml +54 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20110816211552_create_kublog_posts.rb +27 -0
- data/db/migrate/20110817215828_create_kublog_images.rb +11 -0
- data/db/migrate/20110818181434_create_kublog_categories.rb +11 -0
- data/db/migrate/20110822194341_create_kublog_comments.rb +14 -0
- data/kublog.gemspec +39 -0
- data/lib/kublog.rb +92 -0
- data/lib/kublog/author.rb +13 -0
- data/lib/kublog/engine.rb +5 -0
- data/lib/kublog/notifiable.rb +26 -0
- data/lib/kublog/notification/email.rb +86 -0
- data/lib/kublog/notification/email_job.rb +14 -0
- data/lib/kublog/notification/fb_post.rb +43 -0
- data/lib/kublog/notification/fb_post_job.rb +16 -0
- data/lib/kublog/notification/tweet.rb +68 -0
- data/lib/kublog/notification/tweet_job.rb +16 -0
- data/lib/kublog/user_integration/common.rb +31 -0
- data/lib/kublog/user_integration/devise.rb +23 -0
- data/lib/kublog/version.rb +3 -0
- data/lib/kublog/xhr_upload/file_helper.rb +36 -0
- data/lib/tasks/kublog_tasks.rake +4 -0
- data/script/rails +6 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/javascripts/sessions.js +2 -0
- data/test/dummy/app/assets/javascripts/users.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +157 -0
- data/test/dummy/app/assets/stylesheets/sessions.css +4 -0
- data/test/dummy/app/assets/stylesheets/users.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +19 -0
- data/test/dummy/app/controllers/sessions_controller.rb +22 -0
- data/test/dummy/app/controllers/users_controller.rb +17 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/error_messages_helper.rb +23 -0
- data/test/dummy/app/helpers/layout_helper.rb +22 -0
- data/test/dummy/app/helpers/sessions_helper.rb +2 -0
- data/test/dummy/app/helpers/users_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/ability.rb +2 -0
- data/test/dummy/app/models/user.rb +25 -0
- data/test/dummy/app/views/layouts/_account.html.erb +8 -0
- data/test/dummy/app/views/layouts/application.html.erb +29 -0
- data/test/dummy/app/views/layouts/kublog/application.html.erb +31 -0
- data/test/dummy/app/views/sessions/new.html.erb +15 -0
- data/test/dummy/app/views/users/new.html.erb +28 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +42 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +38 -0
- data/test/dummy/config/environments/production.rb +51 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/test/dummy/config/locales/en.yml +54 -0
- data/test/dummy/config/routes.rb +13 -0
- data/test/dummy/db/migrate/20110816225222_create_users.rb +11 -0
- data/test/dummy/db/migrate/20110819135547_create_delayed_jobs.rb +21 -0
- data/test/dummy/db/schema.rb +96 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/delayed_job +5 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/users.yml +9 -0
- data/test/dummy/test/functional/sessions_controller_test.rb +7 -0
- data/test/dummy/test/functional/users_controller_test.rb +7 -0
- data/test/dummy/test/unit/helpers/sessions_helper_test.rb +4 -0
- data/test/dummy/test/unit/helpers/users_helper_test.rb +4 -0
- data/test/dummy/test/unit/user_test.rb +7 -0
- data/test/factories.rb +9 -0
- data/test/fixtures/kublog/categories.yml +7 -0
- data/test/fixtures/kublog/comments.yml +7 -0
- data/test/fixtures/kublog/images.yml +9 -0
- data/test/fixtures/kublog/posts.yml +9 -0
- data/test/functional/kublog/categories_controller_test.rb +9 -0
- data/test/functional/kublog/comments_controller_test.rb +9 -0
- data/test/functional/kublog/images_controller_test.rb +9 -0
- data/test/functional/kublog/post_mailer_test.rb +9 -0
- data/test/functional/kublog/posts_controller_test.rb +9 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/kublog_test.rb +7 -0
- data/test/test_helper.rb +12 -0
- data/test/unit/helpers/kublog/categories_helper_test.rb +6 -0
- data/test/unit/helpers/kublog/comments_helper_test.rb +6 -0
- data/test/unit/helpers/kublog/images_helper_test.rb +6 -0
- data/test/unit/helpers/kublog/posts_helper_test.rb +6 -0
- data/test/unit/kublog/category_test.rb +9 -0
- data/test/unit/kublog/comment_test.rb +9 -0
- data/test/unit/kublog/image_test.rb +9 -0
- data/test/unit/kublog/post_test.rb +19 -0
- metadata +439 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<div class='post-actions'>
|
|
2
|
+
<h2><%= t('.post_actions') %></h2>
|
|
3
|
+
<ul>
|
|
4
|
+
<% if is_admin? %>
|
|
5
|
+
<li><%= link_to t('.edit'), [:edit, @presenter.post] %></li>
|
|
6
|
+
<li><%= link_to t('.delete'), @presenter.post, :method => :delete, :confirm => t('.confirm') %></li>
|
|
7
|
+
<% end %>
|
|
8
|
+
<li> <%= link_to 'All posts', posts_path %></li>
|
|
9
|
+
</ul>
|
|
10
|
+
</div>
|
|
11
|
+
<div class='post-title'>
|
|
12
|
+
<h1><%= @presenter.post %></h1>
|
|
13
|
+
<span class='published-at'><%= l @presenter.post.updated_at, :format => :short %></span>
|
|
14
|
+
</div>
|
|
15
|
+
<div class='post-pody'>
|
|
16
|
+
<%= @presenter.post.body.html_safe %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class='post-comments'>
|
|
19
|
+
<% @presenter.comments.each do |comment| %>
|
|
20
|
+
<div class='comment <%= admin_comment?(comment) %>'>
|
|
21
|
+
<h4><%= comment.author %></h4>
|
|
22
|
+
<p class='body'><%= comment.body %></p>
|
|
23
|
+
<span><%= l comment.created_at, :format => :short %></span>
|
|
24
|
+
<% if is_admin? %>
|
|
25
|
+
<div class='admin-actions'>
|
|
26
|
+
<%= link_to t('.delete'), post_comment_path(@presenter.post, comment),
|
|
27
|
+
:method => :delete, :confirm => t('.confirm'),
|
|
28
|
+
:class=> 'delete' %>
|
|
29
|
+
</div>
|
|
30
|
+
<% end %>
|
|
31
|
+
</div>
|
|
32
|
+
<% end %>
|
|
33
|
+
</div>
|
|
34
|
+
<div class='new-comment'>
|
|
35
|
+
<h2><%= t('.new_comment') %></h2>
|
|
36
|
+
<%= form_for [@presenter.post, Kublog::Comment.new], :remote => true do |f| %>
|
|
37
|
+
<%= f.text_area :body, :rows => 5, :cols => 20, :class => 'small' %> <br />
|
|
38
|
+
<% unless current_user %>
|
|
39
|
+
<%= f.label :author_name %><br />
|
|
40
|
+
<%= f.text_field :author_name %> <br />
|
|
41
|
+
<%= f.label :author_email %><br />
|
|
42
|
+
<%= f.text_field :author_email %> <br />
|
|
43
|
+
<% end %>
|
|
44
|
+
<%= f.submit %>
|
|
45
|
+
<% end %>
|
|
46
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Kublog</title>
|
|
5
|
+
<%= stylesheet_link_tag "kublog/application" %>
|
|
6
|
+
<%= javascript_include_tag "kublog/application" %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body id='kublog'>
|
|
11
|
+
<%= yield %>
|
|
12
|
+
</body>
|
|
13
|
+
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
en:
|
|
2
|
+
kublog:
|
|
3
|
+
posts:
|
|
4
|
+
index:
|
|
5
|
+
edit: 'edit'
|
|
6
|
+
delete: 'delete'
|
|
7
|
+
category_delete_confirm: 'Are you sure? All posts under this category will be left uncategorized'
|
|
8
|
+
edit_category_prompt: 'New name:'
|
|
9
|
+
actions: 'Actions'
|
|
10
|
+
categories: 'Categories'
|
|
11
|
+
new:
|
|
12
|
+
title: 'Building a Post'
|
|
13
|
+
edit:
|
|
14
|
+
title: 'Editing a Post'
|
|
15
|
+
show:
|
|
16
|
+
edit: 'Edit'
|
|
17
|
+
delete: 'Delete'
|
|
18
|
+
confirm: 'Are you sure?'
|
|
19
|
+
new_comment: 'New Comment'
|
|
20
|
+
post_actions: 'Post Actions'
|
|
21
|
+
form:
|
|
22
|
+
or: 'or'
|
|
23
|
+
cancel: 'cancel'
|
|
24
|
+
format_email: 'Format E-Mail'
|
|
25
|
+
link_to_tweet: 'A link to this post will be appended'
|
|
26
|
+
link_to_facebook: "Will be published as link to this post"
|
|
27
|
+
image_form:
|
|
28
|
+
insert_image: 'Insert Image'
|
|
29
|
+
or: 'or'
|
|
30
|
+
cancel: 'cancel'
|
|
31
|
+
insert_size: 'Size'
|
|
32
|
+
alt: 'Alt Text'
|
|
33
|
+
post_mailer:
|
|
34
|
+
new_post:
|
|
35
|
+
greetings: 'Greetings'
|
|
36
|
+
activerecord:
|
|
37
|
+
models:
|
|
38
|
+
'kublog/opst': 'Post'
|
|
39
|
+
attributes:
|
|
40
|
+
'kublog/post':
|
|
41
|
+
title: 'Title'
|
|
42
|
+
body: 'Body'
|
|
43
|
+
category_id: 'Category'
|
|
44
|
+
'kublog/comment':
|
|
45
|
+
author_name: 'Name'
|
|
46
|
+
author_email: 'E-mail'
|
|
47
|
+
helpers:
|
|
48
|
+
label:
|
|
49
|
+
post:
|
|
50
|
+
title: 'Title'
|
|
51
|
+
body: 'Body'
|
|
52
|
+
email_notify: 'Notify users via E-mail'
|
|
53
|
+
twitter_notify: 'Notify users via Twitter'
|
|
54
|
+
facebook_notify: 'Notify users via Facebook'
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Kublog::Engine.routes.draw do
|
|
2
|
+
root :to => 'posts#index'
|
|
3
|
+
resources :posts do
|
|
4
|
+
resources :comments
|
|
5
|
+
collection do
|
|
6
|
+
post :check
|
|
7
|
+
put :check
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
resources :images
|
|
11
|
+
resources :categories
|
|
12
|
+
match '/:id', :to => 'posts#show', :as => 'quickie'
|
|
13
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class CreateKublogPosts < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :kublog_posts do |t|
|
|
4
|
+
t.string :title
|
|
5
|
+
t.text :body
|
|
6
|
+
t.boolean :email_notify, :default => false
|
|
7
|
+
t.text :email_body
|
|
8
|
+
t.integer :users_notified
|
|
9
|
+
t.boolean :twitter_notify, :default => false
|
|
10
|
+
t.string :tweet_id
|
|
11
|
+
t.string :tweet_text
|
|
12
|
+
t.boolean :facebook_notify, :default => false
|
|
13
|
+
t.text :facebook_text
|
|
14
|
+
t.references :user
|
|
15
|
+
t.references :category
|
|
16
|
+
t.string :intended_for
|
|
17
|
+
t.string :slug
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
add_index :kublog_posts, :title
|
|
22
|
+
add_index :kublog_posts, :user_id
|
|
23
|
+
add_index :kublog_posts, :category_id
|
|
24
|
+
add_index :kublog_posts, :slug, :unique => true
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class CreateKublogCategories < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :kublog_categories do |t|
|
|
4
|
+
t.string :name
|
|
5
|
+
t.string :slug
|
|
6
|
+
t.timestamps
|
|
7
|
+
end
|
|
8
|
+
add_index :kublog_categories, :name
|
|
9
|
+
add_index :kublog_categories, :slug, :unique => true
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateKublogComments < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :kublog_comments do |t|
|
|
4
|
+
t.text :body
|
|
5
|
+
t.references :user
|
|
6
|
+
t.references :post
|
|
7
|
+
t.string :author_name
|
|
8
|
+
t.string :author_email
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
add_index :kublog_comments, :post_id
|
|
12
|
+
add_index :kublog_comments, :user_id
|
|
13
|
+
end
|
|
14
|
+
end
|
data/kublog.gemspec
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "kublog/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "kublog"
|
|
7
|
+
s.version = Kublog::VERSION
|
|
8
|
+
s.authors = ["Adrian Cuadros"]
|
|
9
|
+
s.email = ["adrian@innku.com"]
|
|
10
|
+
s.homepage = "http://rutanet.com/blog"
|
|
11
|
+
s.summary = %q{Product Blog Engine, simple, social and fully integrated with your Users}
|
|
12
|
+
s.description = %q{Rails Mountable Engine that sets up your Product Blog, share your posts on facebook, twitter and E-mail your users with your latest product news}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "kublog"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
# Runtime dependencies
|
|
22
|
+
s.add_runtime_dependency "rails", '~>3.1.0.rc5'
|
|
23
|
+
s.add_runtime_dependency "jquery-rails", '~>1.0.13'
|
|
24
|
+
s.add_runtime_dependency 'coffee-script', '~>2.2.0'
|
|
25
|
+
s.add_runtime_dependency "friendly_id", "~> 4.0.0.beta8"
|
|
26
|
+
s.add_runtime_dependency "sanitize", '~>2.0.3'
|
|
27
|
+
|
|
28
|
+
# This gems should stop being dependencies but optional with certain features
|
|
29
|
+
s.add_runtime_dependency "rmagick", '~>2.13.1'
|
|
30
|
+
s.add_runtime_dependency "carrierwave", '~>0.5.7'
|
|
31
|
+
s.add_runtime_dependency 'liquid', '~>2.2.2'
|
|
32
|
+
s.add_runtime_dependency 'twitter', '~>1.6.2'
|
|
33
|
+
s.add_runtime_dependency 'fb_graph', '~>1.9.5'
|
|
34
|
+
|
|
35
|
+
# Development dependencies
|
|
36
|
+
s.add_development_dependency "factory_girl_rails"
|
|
37
|
+
s.add_development_dependency "sqlite3"
|
|
38
|
+
|
|
39
|
+
end
|
data/lib/kublog.rb
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require "rails"
|
|
2
|
+
require 'coffee-script'
|
|
3
|
+
require "jquery-rails"
|
|
4
|
+
require "twitter"
|
|
5
|
+
require "fb_graph"
|
|
6
|
+
require "friendly_id"
|
|
7
|
+
require "carrierwave"
|
|
8
|
+
require "rmagick"
|
|
9
|
+
require "sanitize"
|
|
10
|
+
require "liquid"
|
|
11
|
+
|
|
12
|
+
require "kublog/engine"
|
|
13
|
+
require "kublog/version"
|
|
14
|
+
|
|
15
|
+
module Kublog
|
|
16
|
+
|
|
17
|
+
autoload :Notifiable, 'kublog/notifiable'
|
|
18
|
+
autoload :Author, 'kublog/author'
|
|
19
|
+
|
|
20
|
+
module Notification
|
|
21
|
+
autoload :Email, 'kublog/notification/email'
|
|
22
|
+
autoload :EmailJob, 'kublog/notification/email_job'
|
|
23
|
+
autoload :Tweet, 'kublog/notification/tweet'
|
|
24
|
+
autoload :TweetJob, 'kublog/notification/tweet_job'
|
|
25
|
+
autoload :FbPost, 'kublog/notification/fb_post'
|
|
26
|
+
autoload :FbPostJob, 'kublog/notification/fb_post_job'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
module XhrUpload
|
|
30
|
+
autoload :FileHelper, 'kublog/xhr_upload/file_helper'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
module UserIntegration
|
|
34
|
+
autoload :Common, 'kublog/user_integration/common'
|
|
35
|
+
autoload :Devise, 'kublog/user_integration/devise'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
mattr_accessor :default_url_options
|
|
39
|
+
@@default_url_options = {:host => 'www.example.com'}
|
|
40
|
+
|
|
41
|
+
mattr_accessor :user_kinds
|
|
42
|
+
@@user_kinds = []
|
|
43
|
+
|
|
44
|
+
mattr_reader :notification_processing
|
|
45
|
+
@@notification_processing = :immediately
|
|
46
|
+
|
|
47
|
+
mattr_accessor :image_storage
|
|
48
|
+
@@image_storage = :file
|
|
49
|
+
|
|
50
|
+
mattr_accessor :author_class
|
|
51
|
+
@@author_class = 'User'
|
|
52
|
+
|
|
53
|
+
def self.notification_processing=(method='')
|
|
54
|
+
@@notification_processing = method.to_sym
|
|
55
|
+
if @@notification_processing == :delayed_job
|
|
56
|
+
unless defined? Delayed::Job
|
|
57
|
+
raise 'You must require delayed_job in your Gemfile to use this feature'
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
KublogTwitter = Twitter.clone
|
|
63
|
+
mattr_accessor :twitter_client
|
|
64
|
+
@@twitter_client = KublogTwitter::Client.new
|
|
65
|
+
|
|
66
|
+
mattr_accessor :facebook_client
|
|
67
|
+
|
|
68
|
+
mattr_accessor :blog_name
|
|
69
|
+
@@blog_name = 'Kublog::Blog'
|
|
70
|
+
|
|
71
|
+
def self.facebook_page_token=(token)
|
|
72
|
+
@@facebook_client = FbGraph::User.me(token)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.setup
|
|
76
|
+
yield self
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.twitter
|
|
80
|
+
yield @@twitter_client
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def self.asset_path(path)
|
|
84
|
+
["/assets", self.root_path , path].join
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.root_path
|
|
88
|
+
Engine.routes.url_helpers.root_path
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Module to be included in user that enables him to be
|
|
2
|
+
# published in Posts
|
|
3
|
+
|
|
4
|
+
module Kublog
|
|
5
|
+
module Author
|
|
6
|
+
|
|
7
|
+
def self.included(base)
|
|
8
|
+
Kublog.author_class = base.name
|
|
9
|
+
base.send :has_many, :posts, :class_name => 'Kublog::Post'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Module to be included in User if it wants to implement notifications
|
|
2
|
+
# Sets class options to see if the user has required the module
|
|
3
|
+
# And defaults notification for every user to true
|
|
4
|
+
|
|
5
|
+
module Kublog
|
|
6
|
+
module Notifiable
|
|
7
|
+
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.class_eval do
|
|
10
|
+
@@kublog_notifiable = true
|
|
11
|
+
cattr_accessor :kublog_notifiable
|
|
12
|
+
end
|
|
13
|
+
base.send :include, InstanceMethods
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Defaults notification setting to true
|
|
17
|
+
# If User Kinds are being used, this should be
|
|
18
|
+
# Overriden
|
|
19
|
+
module InstanceMethods
|
|
20
|
+
def notify_post?(post)
|
|
21
|
+
true
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# This class includes the interface to all the different
|
|
2
|
+
# Delivery methods and requires the one that the user chose
|
|
3
|
+
# in the configuration File
|
|
4
|
+
|
|
5
|
+
module Kublog
|
|
6
|
+
module Notification
|
|
7
|
+
module Email
|
|
8
|
+
|
|
9
|
+
# Sets callbacks for E-mail delivery
|
|
10
|
+
# Includes necessary methods for e-mail notification callback
|
|
11
|
+
# and requires appropriate method of notification (Immediate, Delayed Job..)
|
|
12
|
+
def self.included(base)
|
|
13
|
+
|
|
14
|
+
base.send :after_create, :notify_email
|
|
15
|
+
base.send :before_validation, :build_email_body, :on => :create
|
|
16
|
+
|
|
17
|
+
base.send :include, case Kublog.notification_processing.try(:to_sym)
|
|
18
|
+
when :delayed_job then DelayedJob
|
|
19
|
+
else Immediate
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
base.send :include, InstanceMethods
|
|
23
|
+
|
|
24
|
+
# Defines a for_x type of method for each user kind
|
|
25
|
+
# Designed to interface with the user to selectively deliver E-mails
|
|
26
|
+
Kublog.user_kinds.each do |user_kind|
|
|
27
|
+
define_method "for_#{user_kind}?" do
|
|
28
|
+
self.intended_for.include?(user_kind)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
module InstanceMethods
|
|
34
|
+
|
|
35
|
+
# Called to notify users after the creation of a post
|
|
36
|
+
# probably should happen after publication
|
|
37
|
+
def notify_email
|
|
38
|
+
klass = user.class
|
|
39
|
+
if klass.try(:kublog_notifiable) && self.email_notify
|
|
40
|
+
notifications_sent = 0
|
|
41
|
+
klass.find_each do |user|
|
|
42
|
+
if user.notify_post?(self)
|
|
43
|
+
post_deliver(self, user)
|
|
44
|
+
notifications_sent += 1
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
self.update_attribute :users_notified, notifications_sent
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
protected
|
|
52
|
+
|
|
53
|
+
# Opens the ERB and Liquid Template set in the mailer view folders
|
|
54
|
+
# sets the context variables and processes them before to remove erb section
|
|
55
|
+
def build_email_body
|
|
56
|
+
if self.email_body.blank? && !Sanitize.clean(self.body).blank?
|
|
57
|
+
template_path = "app/views/kublog/post_mailer/new_post.liquid.html.erb"
|
|
58
|
+
template = File.open(File.join(Rails.root, template_path))
|
|
59
|
+
read_erb_template(template)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def read_erb_template(template)
|
|
64
|
+
post = self
|
|
65
|
+
self.email_body = ERB.new(template.read).result(binding)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Queues Process on DJ
|
|
71
|
+
module DelayedJob
|
|
72
|
+
def post_deliver(post, user)
|
|
73
|
+
Delayed::Job.enqueue(EmailJob.new(post, user))
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Delivers Immediately
|
|
78
|
+
module Immediate
|
|
79
|
+
def post_deliver(post,user)
|
|
80
|
+
PostMailer.new_post(post,user).deliver
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|