refinerycms-recommendations 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/refinery/recommendations/recommendations_controller.rb +1 -1
- data/app/models/refinery/recommendations/recommendation.rb +11 -3
- data/app/views/refinery/recommendations/admin/recommendations/_form.html.erb +2 -8
- data/app/views/refinery/recommendations/admin/recommendations/_recommendation.html.erb +3 -1
- data/app/views/refinery/recommendations/recommendations/_item.html.erb +18 -0
- data/app/views/refinery/recommendations/recommendations/_items.html.erb +10 -0
- data/app/views/refinery/recommendations/recommendations/_latest.html.erb +14 -0
- data/app/views/refinery/recommendations/recommendations/index.html.erb +1 -10
- data/app/views/refinery/recommendations/recommendations/show.html.erb +12 -77
- data/config/locales/en.yml +15 -1
- data/db/migrate/2_add_slug_to_recommendations_recommendations.rb +11 -0
- data/lib/generators/refinery/recommendations_generator.rb +22 -1
- data/lib/generators/refinery/templates/helpers/recommendations_helper.rb +19 -0
- data/lib/generators/refinery/templates/images/close_quote.gif +0 -0
- data/lib/generators/refinery/templates/images/open_quote.gif +0 -0
- data/lib/generators/refinery/templates/recommendations.css.scss +44 -0
- data/lib/generators/refinery/templates/recommendations.js +0 -0
- data/readme.md +20 -7
- metadata +26 -1
@@ -13,7 +13,7 @@ module Refinery
|
|
13
13
|
|
14
14
|
def show
|
15
15
|
@recommendation = Recommendation.find(params[:id])
|
16
|
-
|
16
|
+
@other_recommendations = Recommendation.find(:all, :conditions => ["slug != ?", params[:id]])
|
17
17
|
# you can use meta fields from your model instead (e.g. browser_title)
|
18
18
|
# by swapping @page for @recommendation in the line below:
|
19
19
|
present(@page)
|
@@ -1,15 +1,23 @@
|
|
1
1
|
module Refinery
|
2
2
|
module Recommendations
|
3
3
|
class Recommendation < Refinery::Core::BaseModel
|
4
|
+
extend FriendlyId
|
4
5
|
self.table_name = 'refinery_recommendations'
|
5
|
-
|
6
|
-
|
6
|
+
|
7
|
+
friendly_id :friendly_id_source, :use => [:slugged]
|
8
|
+
|
9
|
+
attr_accessible :name, :position, :role, :company, :company_url, :source_url, :publish_date, :description, :youtube_id, :photo_id, :widget_visible
|
7
10
|
|
8
11
|
acts_as_indexed :fields => [:name, :company, :company_url, :source_url, :role, :description, :youtube_id]
|
9
12
|
|
10
13
|
validates :name, :presence => true, :uniqueness => true
|
11
|
-
|
14
|
+
|
12
15
|
belongs_to :photo, :class_name => '::Refinery::Image'
|
16
|
+
|
17
|
+
def friendly_id_source
|
18
|
+
"#{name} #{role} #{company}"
|
19
|
+
end
|
20
|
+
|
13
21
|
end
|
14
22
|
end
|
15
23
|
end
|
@@ -5,39 +5,33 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
<div class='field'>
|
8
|
-
<%= f.label
|
8
|
+
<%= f.label "Recommender's Name" -%>
|
9
9
|
<%= f.text_field :name, :class => 'larger widest' -%>
|
10
|
-
|
11
10
|
</div>
|
12
11
|
|
13
12
|
<div class='field'>
|
14
|
-
<%= f.label
|
13
|
+
<%= f.label "Job Role" -%>
|
15
14
|
<%= f.text_field :role -%>
|
16
|
-
|
17
15
|
</div>
|
18
16
|
|
19
17
|
<div class='field'>
|
20
18
|
<%= f.label :company -%>
|
21
19
|
<%= f.text_field :company -%>
|
22
|
-
|
23
20
|
</div>
|
24
21
|
|
25
22
|
<div class='field'>
|
26
23
|
<%= f.label :company_url -%>
|
27
24
|
<%= f.text_field :company_url -%>
|
28
|
-
|
29
25
|
</div>
|
30
26
|
|
31
27
|
<div class='field'>
|
32
28
|
<%= f.label :source_url -%>
|
33
29
|
<%= f.text_field :source_url -%>
|
34
|
-
|
35
30
|
</div>
|
36
31
|
|
37
32
|
<div class='field'>
|
38
33
|
<%= f.label :publish_date -%>
|
39
34
|
<%= f.datetime_select :publish_date -%>
|
40
|
-
|
41
35
|
</div>
|
42
36
|
|
43
37
|
<div class='field'>
|
@@ -1,7 +1,9 @@
|
|
1
1
|
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(recommendation) -%>">
|
2
2
|
<span class='title'>
|
3
3
|
<%= recommendation.name %>
|
4
|
-
|
4
|
+
<span class="preview">
|
5
|
+
<%= l(recommendation.publish_date, :format => :short) %>
|
6
|
+
</span>
|
5
7
|
</span>
|
6
8
|
<span class='actions'>
|
7
9
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="recommendation">
|
2
|
+
<div class="left-media">
|
3
|
+
<% if recommendation.photo.present? %>
|
4
|
+
<%= image_fu recommendation.photo, '120x150#' %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
<div class="right-media">
|
8
|
+
<% if recommendation.youtube_id.present? %>
|
9
|
+
<iframe width="240" height="140" src="http://www.youtube.com/embed/<%= recommendation.youtube_id%>" frameborder="0" allowfullscreen></iframe>
|
10
|
+
<% end %>
|
11
|
+
</div>
|
12
|
+
<blockquote>
|
13
|
+
<p><%= raw recommendation.description %></p>
|
14
|
+
<p><cite><%= raw citation_line(recommendation) %></cite></p>
|
15
|
+
</blockquote>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<aside>
|
2
|
+
<nav id="latest_recommendations">
|
3
|
+
<h2><%= t('.other') %></h2>
|
4
|
+
<ul id="recommendations">
|
5
|
+
<% @recommendations.each do |recommendation| %>
|
6
|
+
<li>
|
7
|
+
<%= link_to recommendation.name, refinery.recommendations_recommendation_path(recommendation) %>
|
8
|
+
</li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</nav>
|
12
|
+
</aside>
|
13
|
+
|
14
|
+
|
@@ -1,11 +1,2 @@
|
|
1
|
-
|
2
|
-
<ul id="recommendations">
|
3
|
-
<% @recommendations.each do |recommendation| %>
|
4
|
-
<li>
|
5
|
-
<%= link_to recommendation.name, refinery.recommendations_recommendation_path(recommendation) %>
|
6
|
-
</li>
|
7
|
-
<% end %>
|
8
|
-
</ul>
|
9
|
-
<% end %>
|
10
|
-
|
1
|
+
<%= render 'items' %>
|
11
2
|
<%= render '/refinery/content_page' %>
|
@@ -1,81 +1,16 @@
|
|
1
|
-
<% content_for :body_content_title do %>
|
2
|
-
<%= @recommendation.name %>
|
3
|
-
<% end %>
|
4
|
-
|
5
1
|
<% content_for :body_content_left do %>
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
</
|
12
|
-
<section>
|
13
|
-
<h1>Role</h1>
|
14
|
-
<p>
|
15
|
-
<%=raw @recommendation.role %>
|
16
|
-
</p>
|
17
|
-
</section>
|
18
|
-
<section>
|
19
|
-
<h1>Company</h1>
|
20
|
-
<p>
|
21
|
-
<%=raw @recommendation.company %>
|
22
|
-
</p>
|
23
|
-
</section>
|
24
|
-
<section>
|
25
|
-
<h1>Company Url</h1>
|
26
|
-
<p>
|
27
|
-
<%=raw @recommendation.company_url %>
|
28
|
-
</p>
|
29
|
-
</section>
|
30
|
-
<section>
|
31
|
-
<h1>Source Url</h1>
|
32
|
-
<p>
|
33
|
-
<%=raw @recommendation.source_url %>
|
34
|
-
</p>
|
35
|
-
</section>
|
36
|
-
<section>
|
37
|
-
<h1>Publish Date</h1>
|
38
|
-
<p>
|
39
|
-
<%=raw @recommendation.publish_date %>
|
40
|
-
</p>
|
41
|
-
</section>
|
42
|
-
<section>
|
43
|
-
<h1>Description</h1>
|
44
|
-
<p>
|
45
|
-
<%=raw @recommendation.description %>
|
46
|
-
</p>
|
47
|
-
</section>
|
48
|
-
<section>
|
49
|
-
<h1>Youtube</h1>
|
50
|
-
<p>
|
51
|
-
<%=raw @recommendation.youtube_id %>
|
52
|
-
</p>
|
53
|
-
</section>
|
54
|
-
<section>
|
55
|
-
<h1>Photo</h1>
|
56
|
-
<p>
|
57
|
-
<%= image_fu @recommendation.photo, nil %>
|
58
|
-
</p>
|
59
|
-
</section>
|
60
|
-
<section>
|
61
|
-
<h1>Widget Visible</h1>
|
62
|
-
<p>
|
63
|
-
<%=raw @recommendation.widget_visible %>
|
64
|
-
</p>
|
65
|
-
</section>
|
2
|
+
<div class="recommendations">
|
3
|
+
<%= render 'item', :recommendation => @recommendation %>
|
4
|
+
<% @other_recommendations.each do |rec| %>
|
5
|
+
<%= render 'item', :recommendation => rec %>
|
6
|
+
<% end %>
|
7
|
+
</div>
|
66
8
|
<% end %>
|
9
|
+
<%= render '/refinery/content_page' %>
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
67
15
|
|
68
|
-
<% content_for :body_content_right do %>
|
69
|
-
<aside>
|
70
|
-
<h2><%= t('.other') %></h2>
|
71
|
-
<ul id="recommendations">
|
72
|
-
<% @recommendations.each do |recommendation| %>
|
73
|
-
<li>
|
74
|
-
<%= link_to recommendation.name, refinery.recommendations_recommendation_path(recommendation) %>
|
75
|
-
</li>
|
76
|
-
<% end %>
|
77
|
-
</ul>
|
78
|
-
</aside>
|
79
|
-
<% end %>
|
80
16
|
|
81
|
-
<%= render '/refinery/content_page' %>
|
data/config/locales/en.yml
CHANGED
@@ -21,6 +21,14 @@ en:
|
|
21
21
|
recommendations:
|
22
22
|
show:
|
23
23
|
other: Other Recommendations
|
24
|
+
back_to_index: "Back to all recommendations"
|
25
|
+
latest:
|
26
|
+
other: Other Recommendations
|
27
|
+
index:
|
28
|
+
published: Published
|
29
|
+
read_more: Read more
|
30
|
+
no_items_yet: There are no news item entries yet.
|
31
|
+
|
24
32
|
activerecord:
|
25
33
|
attributes:
|
26
34
|
'refinery/recommendations/recommendation':
|
@@ -33,4 +41,10 @@ en:
|
|
33
41
|
description: Description
|
34
42
|
youtube_id: Youtube
|
35
43
|
photo: Photo
|
36
|
-
widget_visible: Widget Visible
|
44
|
+
widget_visible: Widget Visible
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Refinery
|
2
2
|
class RecommendationsGenerator < Rails::Generators::Base
|
3
3
|
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
desc "This generator installs Refinery-Recomendations (including Assets)"
|
6
|
+
|
4
7
|
def rake_db
|
5
8
|
rake("refinery_recommendations:install:migrations")
|
6
9
|
end
|
@@ -15,5 +18,23 @@ Refinery::Recommendations::Engine.load_seed
|
|
15
18
|
EOH
|
16
19
|
end
|
17
20
|
end
|
21
|
+
|
22
|
+
def add_assets
|
23
|
+
insert_into_file "app/assets/javascripts/application.js", "//= require recommendations \n", :after => "jquery_ujs\n"
|
24
|
+
|
25
|
+
# Add our own require:
|
26
|
+
content = File.read("app/assets/stylesheets/application.css")
|
27
|
+
if content.match(/require_tree\s+\.\s*$/)
|
28
|
+
# Good enough - that'll include our recommendationd.css
|
29
|
+
else
|
30
|
+
style_require_block = " *= require recommendations\n"
|
31
|
+
insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => "require_self\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
copy_file "recommendations.js", "app/assets/javascripts/recommendations.js"
|
35
|
+
copy_file "recommendations.css.scss", "app/assets/stylesheets/recommendations.css.scss"
|
36
|
+
directory 'images', 'app/assets/images'
|
37
|
+
directory 'helpers', 'app/helpers'
|
38
|
+
end
|
18
39
|
end
|
19
|
-
end
|
40
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RecommendationsHelper
|
2
|
+
|
3
|
+
def citation_line(t)
|
4
|
+
[
|
5
|
+
content_tag(:b, h(t.name)),
|
6
|
+
h(t.role),
|
7
|
+
website_or_company(t)
|
8
|
+
].reject{|o| o.blank?}.join(', ').sub(/,\s/, ': ')
|
9
|
+
end
|
10
|
+
|
11
|
+
def website_or_company(t)
|
12
|
+
if t.company_url.blank?
|
13
|
+
h(t.company)
|
14
|
+
else
|
15
|
+
content_tag(:a, h(t.company.blank? ? t.company_url : t.company), :href => h(t.company_url))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
Binary file
|
Binary file
|
@@ -0,0 +1,44 @@
|
|
1
|
+
.recommendations {
|
2
|
+
border-bottom:1px dashed #ddd; margin:20px 0;
|
3
|
+
}
|
4
|
+
|
5
|
+
.recommendation {
|
6
|
+
border-top:1px dashed #ddd;
|
7
|
+
width: 100%;
|
8
|
+
min-height: 180px;
|
9
|
+
clear: both;
|
10
|
+
position: relative;
|
11
|
+
|
12
|
+
.left-media{
|
13
|
+
left: 0;
|
14
|
+
position: absolute;
|
15
|
+
top: 0;
|
16
|
+
width:200px;
|
17
|
+
height:100%;
|
18
|
+
padding:25px;
|
19
|
+
}
|
20
|
+
.right-media{
|
21
|
+
width:280px;
|
22
|
+
height:100%;
|
23
|
+
float: right;
|
24
|
+
padding:25px;
|
25
|
+
padding-top:30px;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
cite {font-style:normal;}
|
30
|
+
blockquote p {
|
31
|
+
padding: 0 10px 0 240px;}
|
32
|
+
|
33
|
+
blockquote p:first-child {
|
34
|
+
background: transparent url(open_quote.gif) no-repeat scroll 0 0;
|
35
|
+
padding-top:36px;
|
36
|
+
margin-left:200px;
|
37
|
+
}
|
38
|
+
|
39
|
+
blockquote {
|
40
|
+
background: transparent url(close_quote.gif) no-repeat scroll right bottom;
|
41
|
+
margin:0 0 14px;
|
42
|
+
margin-right:320px;
|
43
|
+
}
|
44
|
+
|
File without changes
|
data/readme.md
CHANGED
@@ -1,10 +1,23 @@
|
|
1
|
-
|
1
|
+
###Usage:
|
2
|
+
The usual:
|
3
|
+
* bundle install
|
4
|
+
* rails generate refinery:recommendations
|
5
|
+
* rake db:migrate db:seed
|
2
6
|
|
3
|
-
|
7
|
+
###Functionality:
|
8
|
+
Hopefully similair to Testimonials refinery1.0 gem, but with:
|
9
|
+
* Compatability with refinerycms 2.0
|
10
|
+
* BE/admin: Ability to load new recommendations with photo, video and company links etc.
|
11
|
+
* FE: Displays all recomendations data for all on both index page and individual shows (including friendly ids to maximise seo)
|
4
12
|
|
5
|
-
|
6
|
-
|
7
|
-
gem install refinerycms-recommendations.gem
|
13
|
+
Items todo.
|
14
|
+
* Homepage widgets (with rotating display of selections made in BE)
|
8
15
|
|
9
|
-
|
10
|
-
|
16
|
+
###Additional things you might like to do
|
17
|
+
####Change the name from recommendations to say testimonials.
|
18
|
+
* Easiest way, after installing the gem, copy across the components from config/locales/en.yml that you'd like to rename, i.e:
|
19
|
+
en:
|
20
|
+
refinery:
|
21
|
+
plugins:
|
22
|
+
recommendations:
|
23
|
+
title: Testimonials
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-recommendations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -28,6 +28,22 @@ dependencies:
|
|
28
28
|
- - ~>
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 2.0.4
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: friendly_id
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 4.0.4
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 4.0.4
|
31
47
|
- !ruby/object:Gem::Dependency
|
32
48
|
name: refinerycms-testing
|
33
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,6 +78,9 @@ files:
|
|
62
78
|
- app/views/refinery/recommendations/admin/recommendations/edit.html.erb
|
63
79
|
- app/views/refinery/recommendations/admin/recommendations/index.html.erb
|
64
80
|
- app/views/refinery/recommendations/admin/recommendations/new.html.erb
|
81
|
+
- app/views/refinery/recommendations/recommendations/_item.html.erb
|
82
|
+
- app/views/refinery/recommendations/recommendations/_items.html.erb
|
83
|
+
- app/views/refinery/recommendations/recommendations/_latest.html.erb
|
65
84
|
- app/views/refinery/recommendations/recommendations/index.html.erb
|
66
85
|
- app/views/refinery/recommendations/recommendations/show.html.erb
|
67
86
|
- config/locales/en.yml
|
@@ -71,8 +90,14 @@ files:
|
|
71
90
|
- config/locales/nl.yml
|
72
91
|
- config/routes.rb
|
73
92
|
- db/migrate/1_create_recommendations_recommendations.rb
|
93
|
+
- db/migrate/2_add_slug_to_recommendations_recommendations.rb
|
74
94
|
- db/seeds.rb
|
75
95
|
- lib/generators/refinery/recommendations_generator.rb
|
96
|
+
- lib/generators/refinery/templates/helpers/recommendations_helper.rb
|
97
|
+
- lib/generators/refinery/templates/images/close_quote.gif
|
98
|
+
- lib/generators/refinery/templates/images/open_quote.gif
|
99
|
+
- lib/generators/refinery/templates/recommendations.css.scss
|
100
|
+
- lib/generators/refinery/templates/recommendations.js
|
76
101
|
- lib/refinery/recommendations/engine.rb
|
77
102
|
- lib/refinery/recommendations.rb
|
78
103
|
- lib/refinerycms-recommendations.rb
|