inkwell_timelines 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +187 -0
- data/Rakefile +40 -0
- data/app/assets/images/inkwell_timelines/checkbox-checked.png +0 -0
- data/app/assets/images/inkwell_timelines/checkbox-unchecked.png +0 -0
- data/app/assets/images/inkwell_timelines/minus.png +0 -0
- data/app/assets/images/inkwell_timelines/plus.png +0 -0
- data/app/assets/images/inkwell_timelines/radiobutton_no.png +0 -0
- data/app/assets/images/inkwell_timelines/radiobutton_yes.png +0 -0
- data/app/assets/images/inkwell_timelines/up-down.png +0 -0
- data/app/assets/images/inkwell_timelines/wi-comment-hover.png +0 -0
- data/app/assets/images/inkwell_timelines/wi-comment.png +0 -0
- data/app/assets/images/inkwell_timelines/wi-favorite-active.png +0 -0
- data/app/assets/images/inkwell_timelines/wi-favorite-hover.png +0 -0
- data/app/assets/images/inkwell_timelines/wi-favorite.png +0 -0
- data/app/assets/images/inkwell_timelines/wi-reblog-active.png +0 -0
- data/app/assets/images/inkwell_timelines/wi-reblog-hover.png +0 -0
- data/app/assets/images/inkwell_timelines/wi-reblog.png +0 -0
- data/app/assets/javascripts/inkwell_timelines/index.js.erb +17 -0
- data/app/assets/javascripts/inkwell_timelines/inkwell_multi_selector.js +216 -0
- data/app/assets/javascripts/inkwell_timelines/inkwell_timeline.js.erb +149 -0
- data/app/assets/stylesheets/inkwell_timelines/index.css +30 -0
- data/app/assets/stylesheets/inkwell_timelines/multi_selector.css.erb +112 -0
- data/app/assets/stylesheets/inkwell_timelines/tab-menu.css +26 -0
- data/app/assets/stylesheets/inkwell_timelines/wall_item.css.erb +106 -0
- data/app/controllers/inkwell_timelines/application_controller.rb +4 -0
- data/app/helpers/inkwell_timelines/application_helper.rb +4 -0
- data/app/views/default_partials/_comment.html.erb +21 -0
- data/app/views/default_partials/_multi_selector.html.erb +15 -0
- data/app/views/default_partials/_multi_selector_items.html.erb +8 -0
- data/app/views/default_partials/_post.html.erb +22 -0
- data/app/views/default_partials/_tab_menu.html.erb +9 -0
- data/app/views/layouts/inkwell_timelines/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/lib/inkwell_timelines.rb +6 -0
- data/lib/inkwell_timelines/engine.rb +5 -0
- data/lib/inkwell_timelines/version.rb +3 -0
- data/lib/main/to_controller.rb +22 -0
- data/lib/main/to_helpers.rb +93 -0
- data/lib/tasks/inkwell_timelines_tasks.rake +4 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +16 -0
- data/test/dummy/app/assets/javascripts/test.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +14 -0
- data/test/dummy/app/assets/stylesheets/test.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +9 -0
- data/test/dummy/app/controllers/test_controller.rb +5 -0
- data/test/dummy/app/controllers/timeline_controller.rb +11 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/test_helper.rb +2 -0
- data/test/dummy/app/models/blogline.rb +3 -0
- data/test/dummy/app/models/bloglines_categories.rb +3 -0
- data/test/dummy/app/models/category.rb +7 -0
- data/test/dummy/app/models/comment.rb +16 -0
- data/test/dummy/app/models/favoriteline.rb +3 -0
- data/test/dummy/app/models/post.rb +16 -0
- data/test/dummy/app/models/user.rb +109 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/test/show.html.erb +1 -0
- data/test/dummy/app/views/timeline/show.html.erb +1 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -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 +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/inkwell_timelines.rb +42 -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 +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130422111954_create_posts.rb +16 -0
- data/test/dummy/db/migrate/20130422112200_create_users.rb +10 -0
- data/test/dummy/db/migrate/20130422112350_create_comments.rb +16 -0
- data/test/dummy/db/migrate/20130422112504_create_bloglines.rb +13 -0
- data/test/dummy/db/migrate/20130422112804_create_favoritelines.rb +11 -0
- data/test/dummy/db/migrate/20130422112954_create_categories.rb +14 -0
- data/test/dummy/db/migrate/20130422113135_create_bloglines_categories.rb +12 -0
- data/test/dummy/db/schema.rb +92 -0
- data/test/dummy/db/seeds.rb +625 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +104306 -0
- data/test/dummy/log/test.log +815 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/spec/helpers/test_helper_spec.rb +8 -0
- data/test/dummy/spec/spec_helper.rb +52 -0
- data/test/dummy/spec/watir/autoload_spec.rb +33 -0
- data/test/dummy/spec/watir/main_spec.rb +80 -0
- data/test/dummy/spec/watir/selector_spec.rb +103 -0
- data/test/dummy/spec/watir/tab_menu_spec.rb +36 -0
- data/test/dummy/tmp/cache/assets/C56/8F0/sprockets%2F1ad046fb9937420d5382984483fc8401 +0 -0
- data/test/dummy/tmp/cache/assets/C63/420/sprockets%2F5daa64d9601a1dd14726112003d08364 +0 -0
- data/test/dummy/tmp/cache/assets/C65/790/sprockets%2Feacce513669090988829f66e61634451 +0 -0
- data/test/dummy/tmp/cache/assets/C77/DD0/sprockets%2F055f9cd12326c5150492b8c584314fa3 +0 -0
- data/test/dummy/tmp/cache/assets/C84/E70/sprockets%2F0530f24346bbf970634035b6e55f886e +0 -0
- data/test/dummy/tmp/cache/assets/C85/420/sprockets%2F4734da42d41574596ab532629d0867ec +0 -0
- data/test/dummy/tmp/cache/assets/C87/A50/sprockets%2F667342f892546b573c52d11f814ae4f3 +0 -0
- data/test/dummy/tmp/cache/assets/CA1/750/sprockets%2Fa8471b3ea18986e7368e8273a95865e8 +0 -0
- data/test/dummy/tmp/cache/assets/CAC/DB0/sprockets%2Fc424393ee4e4f66aa4014619048753cb +0 -0
- data/test/dummy/tmp/cache/assets/CB2/170/sprockets%2F4479eb189646408ec3130b45153ebf7b +0 -0
- data/test/dummy/tmp/cache/assets/CB9/630/sprockets%2Fe5952cc2ece61727517547af4232892e +0 -0
- data/test/dummy/tmp/cache/assets/CBD/960/sprockets%2F5a35c922c979e889b0338374a9b3f4b0 +0 -0
- data/test/dummy/tmp/cache/assets/CC4/730/sprockets%2F78d0941e0543313bbb0a9f0cf630030d +0 -0
- data/test/dummy/tmp/cache/assets/CD1/F50/sprockets%2Fbf2261613d1c32c54a6e38a7673531fa +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CD9/1E0/sprockets%2F293460f7bea2aea456231b769212f36f +0 -0
- data/test/dummy/tmp/cache/assets/CDC/EC0/sprockets%2Ff9a21d40846491577ab5ebe00de07077 +0 -0
- data/test/dummy/tmp/cache/assets/CE6/8D0/sprockets%2F9e823d2b49662dbb4389f2841a23e8c1 +0 -0
- data/test/dummy/tmp/cache/assets/CEE/110/sprockets%2Faf0654ff711843e082592cd70cf89a88 +0 -0
- data/test/dummy/tmp/cache/assets/CEE/490/sprockets%2F97139dc7ad35759531fc7fa572f0c761 +0 -0
- data/test/dummy/tmp/cache/assets/CF9/6F0/sprockets%2F952426cea414c6c2a04cc1216a1f36f5 +0 -0
- data/test/dummy/tmp/cache/assets/CFA/DE0/sprockets%2F25bf1e7766a300a4c37195df0cbb1107 +0 -0
- data/test/dummy/tmp/cache/assets/CFB/A10/sprockets%2F72699e3ed6f9c3984a718b62932ba66e +0 -0
- data/test/dummy/tmp/cache/assets/CFC/640/sprockets%2Fc7f89943cb904e76b2437e59348cc5c9 +0 -0
- data/test/dummy/tmp/cache/assets/D13/0C0/sprockets%2F218a6e24bfe5005a8a86798baa2585c8 +0 -0
- data/test/dummy/tmp/cache/assets/D13/3B0/sprockets%2F00cf5d507582a705af9694cde93ba186 +0 -0
- data/test/dummy/tmp/cache/assets/D13/6A0/sprockets%2F4819aa020210496ecf49ee70b78e8be6 +0 -0
- data/test/dummy/tmp/cache/assets/D15/560/sprockets%2Ff0007939832a29a27abe3a9579eed81c +0 -0
- data/test/dummy/tmp/cache/assets/D16/860/sprockets%2Fb45890d98668c132fee5cae4b15320d9 +0 -0
- data/test/dummy/tmp/cache/assets/D1A/150/sprockets%2F49ad9f8620b7712e6f2d4fc2e354e545 +0 -0
- data/test/dummy/tmp/cache/assets/D20/4F0/sprockets%2Fb15d3257899ad89007d1348eb9a5f5fe +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D36/810/sprockets%2Fb84416b6a4f5a39b0bc23ab72ad94279 +0 -0
- data/test/dummy/tmp/cache/assets/D39/390/sprockets%2F3c87a321da4296312f18efc704cd6d2f +0 -0
- data/test/dummy/tmp/cache/assets/D3A/260/sprockets%2F69551919ec05c0eb11e55bb59dc143ec +0 -0
- data/test/dummy/tmp/cache/assets/D41/350/sprockets%2F2111b16bc0081c14b803cfd350eb4baa +0 -0
- data/test/dummy/tmp/cache/assets/D43/D20/sprockets%2Fbcbf2f35591e507593ec6116eac6e924 +0 -0
- data/test/dummy/tmp/cache/assets/D48/3C0/sprockets%2F41be77d9f6b62168967ca14ccc6b51d6 +0 -0
- data/test/dummy/tmp/cache/assets/D4D/7C0/sprockets%2F5f4f24c2540cffe8b3c5e835756c35f7 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D51/6A0/sprockets%2F80b05d6f75c78bdb1e450c898e47d97a +0 -0
- data/test/dummy/tmp/cache/assets/D56/4C0/sprockets%2F66059379b6c72ffe570f4ae394a89eda +0 -0
- data/test/dummy/tmp/cache/assets/D56/D30/sprockets%2Fe910c76d93fd4da6984d82e469f62f0c +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D65/600/sprockets%2Fdaa0e3c217673cb0ebb89d97438a1b80 +0 -0
- data/test/dummy/tmp/cache/assets/D66/6C0/sprockets%2Fa06355ade2a095c01afd8c6f5e67019d +0 -0
- data/test/dummy/tmp/cache/assets/D6A/E70/sprockets%2Fc9f71142e4d4a807cb6be80451f74adb +0 -0
- data/test/dummy/tmp/cache/assets/D76/E50/sprockets%2F6289e3eb865565eab3fdfb4fae810702 +0 -0
- data/test/dummy/tmp/cache/assets/D86/6A0/sprockets%2Fac97d7e4e37faa819a833c7c52c9e687 +0 -0
- data/test/dummy/tmp/cache/assets/D91/C00/sprockets%2Fb1cf6c48f161db0a058d10817ddd5e5b +0 -0
- data/test/dummy/tmp/cache/assets/D9C/C90/sprockets%2Fa903431f8703bbaafcae42e4f4692ff8 +0 -0
- data/test/dummy/tmp/cache/assets/DA0/C60/sprockets%2F90d8e40e6baa19d6556ab9c6ac891a2e +0 -0
- data/test/dummy/tmp/cache/assets/DA1/F90/sprockets%2F3bd196480867f8e3c74b10dbcbbe1f9b +0 -0
- data/test/dummy/tmp/cache/assets/DA7/EE0/sprockets%2Ffced4a1e089dc82bf773475da4e53c46 +0 -0
- data/test/dummy/tmp/cache/assets/DA9/4D0/sprockets%2F3d68828b990fbfa9cdf51daa76c242d5 +0 -0
- data/test/dummy/tmp/cache/assets/DB5/4C0/sprockets%2F5e815df4827231fe949b2f9bffd0d9de +0 -0
- data/test/dummy/tmp/cache/assets/DB6/910/sprockets%2F3c19b64141a5ceeccf3a3baf4c452a06 +0 -0
- data/test/dummy/tmp/cache/assets/DC4/8D0/sprockets%2Fd8daccd2ece841a83a2a584c50e352d5 +0 -0
- data/test/dummy/tmp/cache/assets/DCC/6A0/sprockets%2Fa92fb625cc83fe72fc4115e2fb2ed61e +0 -0
- data/test/dummy/tmp/cache/assets/DCC/940/sprockets%2Fe7f0ee8bf122b8b72b8e3c7cd13a5d81 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E08/E50/sprockets%2F22c72aded517c5cdf8cce6f4b58c76b8 +0 -0
- data/test/dummy/tmp/cache/assets/E24/740/sprockets%2F2ecee9c0ae221af87da9c5d034c8dd0c +0 -0
- data/test/dummy/tmp/cache/assets/E2D/160/sprockets%2Fdb479da69eeed6322f3b8dab3bf91bb0 +0 -0
- data/test/dummy/tmp/cache/assets/E4C/810/sprockets%2Fdaf244418a8cfda1aca3e32dbdf17fd2 +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/screen/main.png +0 -0
- data/test/test_helper.rb +15 -0
- metadata +413 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
<div class="inkwell_multi_selector" id="inkwell_<%= options[:id]%>">
|
2
|
+
<span class="name"> <%= options[:name] %>: </span>
|
3
|
+
<div class="action">
|
4
|
+
<span class="action_name">Change</span>
|
5
|
+
<span class="action_icon"></span>
|
6
|
+
<div class="dropdown" style="display: none">
|
7
|
+
<%= render :partial => 'default_partials/multi_selector_items', :locals => {:records => records, :id => nil, :selector_id => options[:id]} %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="current_state">
|
11
|
+
<% records.select {|record| record.parent_category_id == nil }.each do |record| %>
|
12
|
+
<span id="<%= "inkwell_#{options[:id]}_state_#{record.id}" %>"><%= record.name %></span>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% records.select {|record| record.parent_category_id == id }.each do |current_record| %>
|
2
|
+
<div<% if id %> class="nested" style="display: none" <% end %>>
|
3
|
+
<% child_records = records.select {|record| record.parent_category_id == current_record.id} %>
|
4
|
+
<span class="nesting <% unless child_records.empty? %>collapsed<% end %>"></span>
|
5
|
+
<span class="checkbox_with_label checked" id="<%= "inkwell_#{selector_id}_checkbox_#{current_record.id}" %>"><%= current_record.name %></span>
|
6
|
+
<%= render :partial => 'default_partials/multi_selector_items', :locals => {:records => records, :id => current_record.id, :selector_id => selector_id} unless child_records.empty? %>
|
7
|
+
</div>
|
8
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="wall_item" id="<%= timeline %>_<%= record.item_id %>">
|
2
|
+
<a href="<%= user_path record.user.id %>" class="avatar_link"><img class="avatar" src="<%= record.user.avatar %>" alt="<%= record.user.nick %>"></a>
|
3
|
+
|
4
|
+
<div class="item_container">
|
5
|
+
<div class="item_description">
|
6
|
+
<span class="name"> <%= record.user.name %>:</span>
|
7
|
+
<span class="title"> <%= record.title %></span>
|
8
|
+
</div>
|
9
|
+
<% if record.preview_image %><a class="item_img_link"><img src="<%= record.preview_image %>" class="item_img"></a><% end%>
|
10
|
+
|
11
|
+
<p><%= truncate record.body, :length => 500 %></p>
|
12
|
+
|
13
|
+
<div class="clear item_menu">
|
14
|
+
<span class="favorite_action action<% if record.is_favorited %> active<% end%>"><%= record.favorite_count %></span>
|
15
|
+
<span class="reblog_action action<% if record.is_reblogged %> active<% end%>"><%= record.reblog_count %></span>
|
16
|
+
<span class="comment_action action"><%= record.comment_count %></span>
|
17
|
+
<span class="date" style="display: none;"><%= record.created_at.utc.to_i * 1000 %></span>
|
18
|
+
<div class="clear"></div>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
</div>
|
22
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>InkwellTimelines</title>
|
5
|
+
<%= stylesheet_link_tag "inkwell_timelines/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "inkwell_timelines/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module InkwellTimelines
|
2
|
+
module MethodsForControllers
|
3
|
+
def inkwell_timelines_get_params(request_body, options = {})
|
4
|
+
request_params = ActiveSupport::JSON.decode(request_body).symbolize_keys!
|
5
|
+
options.merge! request_params
|
6
|
+
options.merge! ActiveSupport::JSON.decode(options[:transferred_params]).symbolize_keys!
|
7
|
+
options.delete :transferred_params
|
8
|
+
|
9
|
+
if options[:selectors_values]
|
10
|
+
options[:selectors_values].each do |selector_values|
|
11
|
+
selector_values.symbolize_keys!
|
12
|
+
options[selector_values[:name].to_sym] = selector_values[:data]
|
13
|
+
end
|
14
|
+
options.delete :selectors_values
|
15
|
+
end
|
16
|
+
|
17
|
+
options
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
ActionController::Base.send :include, InkwellTimelines::MethodsForControllers
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module InkwellTimelines
|
2
|
+
module Helpers
|
3
|
+
def inkwell_timelines_tag(block_id, options = {})
|
4
|
+
partials_dir = InkwellTimelines::Engine::config.respond_to?('partials_dir') ? InkwellTimelines::Engine::config.partials_dir : 'default_partials'
|
5
|
+
|
6
|
+
block_configs = InkwellTimelines::Engine::config.timeline_blocks
|
7
|
+
block_index = block_configs.index{|block| block[:id] == block_id}
|
8
|
+
current_block = block_configs[block_index]
|
9
|
+
|
10
|
+
tab_menu_params = []
|
11
|
+
transferred_params = []
|
12
|
+
active_timeline = nil
|
13
|
+
timeline_configs = current_block[:timelines]
|
14
|
+
timeline_configs.each do |config|
|
15
|
+
tab_menu_params << {
|
16
|
+
:name => config[:name],
|
17
|
+
:class => config[:id],
|
18
|
+
:active => config[:active]
|
19
|
+
}
|
20
|
+
active_timeline = config if config[:active]
|
21
|
+
|
22
|
+
if config[:transferred_params] and !config[:transferred_params].empty?
|
23
|
+
passed_options = {:name => config[:id], :value => {}}
|
24
|
+
config[:transferred_params].each {|param| passed_options[:value][param] = options[param]}
|
25
|
+
transferred_params << passed_options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
tab_menu = render :partial => "#{partials_dir}/tab_menu", :locals => {:options => tab_menu_params}
|
30
|
+
|
31
|
+
multi_selectors = ActionView::OutputBuffer.new
|
32
|
+
if active_timeline[:multi_selectors] and !active_timeline[:multi_selectors].empty?
|
33
|
+
active_timeline[:multi_selectors].each do |selector|
|
34
|
+
records = selector[:data_get].call(options)
|
35
|
+
multi_selectors += render :partial => "#{partials_dir}/multi_selector", :locals => {:records => records, :options => selector}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
data = active_timeline[:data_get].call(options)
|
40
|
+
wall_items = ActionView::OutputBuffer.new
|
41
|
+
puts
|
42
|
+
data.each do |record|
|
43
|
+
wall_item = render :partial => "#{partials_dir}/#{record.class.to_s.downcase}", :locals => {:record => record, :timeline => active_timeline[:id]}
|
44
|
+
wall_items += wall_item
|
45
|
+
end
|
46
|
+
|
47
|
+
transferred_params_fields = ActionView::OutputBuffer.new
|
48
|
+
unless transferred_params.empty?
|
49
|
+
transferred_params.each do |params|
|
50
|
+
transferred_params_fields += tag :input, :type => :hidden, :class => "transferred_params #{params[:name]}", :value => ActiveSupport::JSON.encode(params[:value])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
content_tag :div, tab_menu + multi_selectors + (transferred_params_fields unless transferred_params.empty?) + wall_items, :class => 'inkwell_timelines', :id => block_id
|
55
|
+
end
|
56
|
+
|
57
|
+
def inkwell_timelines_autoload_tag(options = {})
|
58
|
+
partials_dir = InkwellTimelines::Engine::config.respond_to?('partials_dir') ? InkwellTimelines::Engine::config.partials_dir : 'default_partials'
|
59
|
+
|
60
|
+
block_configs = InkwellTimelines::Engine::config.timeline_blocks
|
61
|
+
block_index = block_configs.index { |block| block[:id] == options[:block_name] }
|
62
|
+
raise "block #{options[:block_name]} is not found" unless block_index
|
63
|
+
current_block = block_configs[block_index]
|
64
|
+
|
65
|
+
block_timelines = current_block[:timelines]
|
66
|
+
active_timeline = nil
|
67
|
+
block_timelines.each { |timeline| active_timeline = timeline if timeline[:id] == options[:timeline] }
|
68
|
+
|
69
|
+
multi_selectors = ActionView::OutputBuffer.new
|
70
|
+
puts(options[:include_selectors])
|
71
|
+
puts(!options[:last_item_id] || !options[:include_selectors])
|
72
|
+
if options[:include_selectors]
|
73
|
+
if active_timeline[:multi_selectors] and !active_timeline[:multi_selectors].empty?
|
74
|
+
active_timeline[:multi_selectors].each do |selector|
|
75
|
+
records = selector[:data_get].call(options)
|
76
|
+
multi_selectors += render :partial => "#{partials_dir}/multi_selector", :locals => {:records => records, :options => selector}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
data = active_timeline[:data_get].call options
|
82
|
+
wall_items = ActionView::OutputBuffer.new
|
83
|
+
data.each do |record|
|
84
|
+
wall_item = render :partial => "#{partials_dir}/#{record.class.to_s.downcase}", :locals => {:record => record, :timeline => active_timeline[:id]}
|
85
|
+
wall_items += wall_item
|
86
|
+
end
|
87
|
+
multi_selectors + wall_items
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
ActionView::Base.send :include, InkwellTimelines::Helpers
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
16
|
+
//= require inkwell_timelines
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*= require inkwell_timelines
|
14
|
+
*/
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class TimelineController < ApplicationController
|
2
|
+
def show
|
3
|
+
@options = inkwell_timelines_get_params(request.body, :for_user => current_user)
|
4
|
+
|
5
|
+
#Here you can check came from js options. For exapmle:
|
6
|
+
user = User.find @options[:user_id]
|
7
|
+
raise "current user has no permissions to see #{user.nick} timeline" unless current_user.can_see_timeline user
|
8
|
+
|
9
|
+
render :layout => false
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
#attr_accessible :title, :body
|
3
|
+
has_many :posts
|
4
|
+
has_many :comments
|
5
|
+
|
6
|
+
def blogline(options = {})
|
7
|
+
last_shown_obj_id = options[:last_item_id]
|
8
|
+
limit = options[:limit] || 10
|
9
|
+
for_user = options[:for_user]
|
10
|
+
category = options[:category]
|
11
|
+
|
12
|
+
if category
|
13
|
+
categories = Category.find category
|
14
|
+
category_ids = []
|
15
|
+
categories.each do |category|
|
16
|
+
category_ids = category_ids | ActiveSupport::JSON.decode(category.child_ids) | [category.id]
|
17
|
+
end
|
18
|
+
|
19
|
+
if last_shown_obj_id
|
20
|
+
bloglines_categories = BloglinesCategories.where(:category_id => category_ids).where("blog_item_created_at < ?", Blogline.find(last_shown_obj_id).created_at).order("blog_item_created_at DESC").limit(limit)
|
21
|
+
else
|
22
|
+
bloglines_categories = BloglinesCategories.where(:category_id => category_ids).order("blog_item_created_at DESC").limit(limit)
|
23
|
+
end
|
24
|
+
|
25
|
+
blog_items_ids = []
|
26
|
+
bloglines_categories.each do |record|
|
27
|
+
blog_items_ids << record.blog_item_id
|
28
|
+
end
|
29
|
+
blog_items = Blogline.where(:id => blog_items_ids, :owner_id => self.id, :owner_type => 'u').order("created_at DESC")
|
30
|
+
else
|
31
|
+
if last_shown_obj_id
|
32
|
+
blog_items = Blogline.where(:owner_id => self.id, :owner_type => 'u').where("created_at < ?", Blogline.find(last_shown_obj_id).created_at).order("created_at DESC").limit(limit)
|
33
|
+
else
|
34
|
+
blog_items = Blogline.where(:owner_id => self.id, :owner_type => 'u').order("created_at DESC").limit(limit)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
result = []
|
39
|
+
blog_items.each do |item|
|
40
|
+
if item.item_type == 'c'
|
41
|
+
blog_obj = Comment.find item.item_id
|
42
|
+
else
|
43
|
+
blog_obj = Post.find item.item_id
|
44
|
+
end
|
45
|
+
|
46
|
+
blog_obj.item_id = item.id
|
47
|
+
|
48
|
+
if for_user
|
49
|
+
blog_obj.is_reblogged = for_user.reblog? blog_obj
|
50
|
+
blog_obj.is_favorited = for_user.favorite? blog_obj
|
51
|
+
end
|
52
|
+
|
53
|
+
result << blog_obj
|
54
|
+
end
|
55
|
+
result
|
56
|
+
end
|
57
|
+
|
58
|
+
def favoriteline(options = {})
|
59
|
+
last_shown_obj_id = options[:last_item_id]
|
60
|
+
limit = options[:limit] || 10
|
61
|
+
for_user = options[:for_user]
|
62
|
+
|
63
|
+
if last_shown_obj_id
|
64
|
+
favorite_items = Favoriteline.where(:owner_id => self.id, :owner_type => 'u').where("created_at < ?", Favoriteline.find(last_shown_obj_id).created_at).order("created_at DESC").limit(limit)
|
65
|
+
else
|
66
|
+
favorite_items = Favoriteline.where(:owner_id => self.id, :owner_type => 'u').order("created_at DESC").limit(limit)
|
67
|
+
end
|
68
|
+
|
69
|
+
result = []
|
70
|
+
favorite_items.each do |item|
|
71
|
+
if item.item_type == 'c'
|
72
|
+
favorite_obj = Comment.find item.item_id
|
73
|
+
else
|
74
|
+
favorite_obj = Post.find item.item_id
|
75
|
+
end
|
76
|
+
|
77
|
+
favorite_obj.item_id = item.id
|
78
|
+
|
79
|
+
if for_user
|
80
|
+
favorite_obj.is_reblogged = for_user.reblog? favorite_obj
|
81
|
+
favorite_obj.is_favorited = for_user.favorite? favorite_obj
|
82
|
+
end
|
83
|
+
|
84
|
+
result << favorite_obj
|
85
|
+
end
|
86
|
+
result
|
87
|
+
end
|
88
|
+
|
89
|
+
def reblog?(obj)
|
90
|
+
if obj.id % 2 == 1
|
91
|
+
true
|
92
|
+
else
|
93
|
+
false
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
def favorite?(obj)
|
99
|
+
if obj.id % 2 == 1
|
100
|
+
true
|
101
|
+
else
|
102
|
+
false
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def can_see_timeline(other_user)
|
107
|
+
true
|
108
|
+
end
|
109
|
+
end
|