From f7dd2bd7d07311e4f8d9b1b452cbca4876cbbf0f Mon Sep 17 00:00:00 2001 From: Vikko Date: Thu, 20 Oct 2011 09:59:05 +0200 Subject: [PATCH] Tags --- app/assets/stylesheets/main.css.scss | 58 +++++++++++++++++++------ app/controllers/abouts_controller.rb | 4 ++ app/controllers/blogpages_controller.rb | 24 ++++++++++ app/controllers/cases_controller.rb | 8 +++- app/controllers/home_controller.rb | 2 +- app/controllers/pages_controller.rb | 2 +- app/models/profile.rb | 26 ++++++++++- app/views/abouts/_form.html.erb | 6 ++- app/views/abouts/show.html.erb | 14 +++--- app/views/application/_events.html.erb | 19 ++++---- app/views/application/_search.html.erb | 2 +- app/views/blogpages/_form.html.erb | 4 ++ app/views/blogpages/show.html.erb | 5 ++- app/views/cases/_form.html.erb | 4 ++ app/views/cases/index.html.erb | 3 ++ app/views/cases/show.html.erb | 5 ++- app/views/events/_form.html.erb | 4 ++ app/views/events/index.html.erb | 7 ++- app/views/pages/index.html.erb | 2 +- app/views/profiles/_form.html.erb | 5 ++- app/views/profiles/index.html.erb | 24 +++------- db/schema.rb | 4 +- 22 files changed, 173 insertions(+), 59 deletions(-) diff --git a/app/assets/stylesheets/main.css.scss b/app/assets/stylesheets/main.css.scss index 0e4ef61..87724a5 100644 --- a/app/assets/stylesheets/main.css.scss +++ b/app/assets/stylesheets/main.css.scss @@ -42,7 +42,7 @@ div#footer { table { width: 100%; } - width: 490px; + width: 470px; margin-left: 20px; margin-right: 0px;; } @@ -83,6 +83,15 @@ div#leftcontent { padding: 10px; } +div.links { + p { + margin-left: 10px; + } + div#line { + border-bottom: solid 1px; + } +} + H2 { font-family: Interstatelight !important; font-size:160%; @@ -106,7 +115,7 @@ H3 { } div#midcol { - width: 490px; + width: 470px; float: left; margin-top: 15px; margin-left: 10px; @@ -118,7 +127,7 @@ div#navigation { width:100%; float:left; text-align:center; - font-family:Interstatelight, Verdana, monospace; + font-family: Interstatelight, Verdana, monospace; font-size:120%; } @@ -135,7 +144,6 @@ table.navmenu { } } - div a.navlink { text-decoration: none; font-family: Interstatelight, Verdana, monospace; @@ -155,7 +163,8 @@ td.navlink { div table#contact { float: right; margin-top: -12px; - margin-right: -203px; + margin-right: -223px; + letter-spacing: 0.1em; } div#content { @@ -164,7 +173,12 @@ div#content { padding-top: 5px; padding-left: 15px; padding-right: 15px; - padding-bottom: 10px;} + padding-bottom: 10px; + p img { + margin-top: 2px; + margin-right: 10px; + } +} div.actions { text-align:right; @@ -188,7 +202,7 @@ div#rightcol { margin-left: 10px; margin-bottom: 10px; margin-right: 0px; - width: 180px; + width: 200px; float: right; input { width: 160px; @@ -199,7 +213,7 @@ div#search input#search_content_contains { width: 154px; } -div#login, div#search, div#events { +div#login, div#search, div#events, div.related { background-color: #FFFFFF; color: #000000; font-family: Interstatelight, Verdana, Geneva; @@ -213,16 +227,29 @@ div#login, div#search, div#events { } } -td.eventtitle { - a { - text-decoration: none; - } -} - td.eventmonth { + padding-top: 15px; text-transform: uppercase; } + +div#events { + img { + width: 145px !important; + height: auto !important; + } + img.readmore { + width: 7px !important; + } + table { + width: 145px; + p { + margin-top: 0px; + margin-bottom: 0px; + } + } +} + div.backgroundtitle { background-color:#2e3192; color: #FFFFFF; @@ -235,6 +262,9 @@ div.backgroundtitle { color: #FFF; text-decoration: none; } + h4 { + font-weight: normal; + } } div.field { diff --git a/app/controllers/abouts_controller.rb b/app/controllers/abouts_controller.rb index f03efe5..8316cbe 100644 --- a/app/controllers/abouts_controller.rb +++ b/app/controllers/abouts_controller.rb @@ -1,3 +1,7 @@ class AboutsController < InheritedResources::Base load_and_authorize_resource + def show + @agenda = Event.find(:all, :order => "date ASC", :limit => 3) + show! + end end diff --git a/app/controllers/blogpages_controller.rb b/app/controllers/blogpages_controller.rb index 97feace..334f7ad 100644 --- a/app/controllers/blogpages_controller.rb +++ b/app/controllers/blogpages_controller.rb @@ -7,6 +7,30 @@ def index def show @blogpage = Blogpage.find(params[:id]) @comments = @blogpage.comments + search = [] + if @blogpage.tags + search = @blogpage.tags.split(", ") + end + pages = [] + profiles = [] + search.each do |s| + pages << Page.where("tags LIKE ?", '%'+s+'%') + profiles << Profile.where("tags LIKE ?", '%'+s+'%') + end + @relatedpages = [] + @relatedprofiles = [] + pages.each do |pa| + pa.each do |page| + @relatedpages << page + end + end + profiles.each do |pr| + pr.each do |profile| + @relatedprofiles << profile + end + end + @relatedpages.uniq! + @relatedprofiles.uniq! end def create diff --git a/app/controllers/cases_controller.rb b/app/controllers/cases_controller.rb index 6e46661..808912f 100644 --- a/app/controllers/cases_controller.rb +++ b/app/controllers/cases_controller.rb @@ -2,7 +2,13 @@ class CasesController < InheritedResources::Base load_and_authorize_resource def index - @blogpages = Blogpage.order("created_at DESC") + @cases = Case.order("created_at DESC") + @agenda = Event.find(:all, :order => "date ASC", :limit => 3) + end + + def show + @agenda = Event.find(:all, :order => "date ASC", :limit => 3) + show! end def new diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index e9c9153..7cf5f76 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -3,6 +3,6 @@ def index @sidetext = About.find(6) @cases = Case.where(:published => true).order("created_at DESC").limit(3) @blogpages = Blogpage.where(:published => true).order("created_at DESC").limit(3) - @agenda = Event.find(:all, :order => "date ASC", :limit => 4) + @agenda = Event.find(:all, :order => "date ASC", :limit => 3) end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 5e1537e..97188c8 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -2,6 +2,6 @@ class PagesController < ApplicationController load_and_authorize_resource def index @search = Page.search(params[:search]) - @pages = @search#.where("published=?", true) # or @search.relation to lazy load in view + @pages = @search end end diff --git a/app/models/profile.rb b/app/models/profile.rb index a169d92..386fdbd 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -1,2 +1,26 @@ class Profile < ActiveRecord::Base -end + + def shortname + name = "" + unless self.prefix.blank? + name += self.prefix.strip + " " + end + name += self.firstname.strip + " " + unless self.middlename.blank? + name += self.middlename.strip + " " + end + name += self.lastname.strip + " " + unless self.suffix.blank? + name += self.suffix.strip + end + return name + end + + def fullname + name = self.shortname + unless self.firstnamefull.blank? + name += " (" + self.firstnamefull.strip + ")" + end + return name + end +end \ No newline at end of file diff --git a/app/views/abouts/_form.html.erb b/app/views/abouts/_form.html.erb index b783e08..3b02752 100644 --- a/app/views/abouts/_form.html.erb +++ b/app/views/abouts/_form.html.erb @@ -19,14 +19,18 @@ <%= f.cktext_area :content, :toolbar => 'Easy' %>
- <%= f.label :published %> <%= f.check_box :published %> + <%= f.label :published %>
<% if (current_user.role == "editor") %>
<%= f.label :author %> <%= f.text_field :author %>
+
+ <%= f.label :tags %> + <%= f.text_field :tags %> +
<% end %>
<%= f.submit "Save" %> diff --git a/app/views/abouts/show.html.erb b/app/views/abouts/show.html.erb index 098b9e1..0efd70d 100644 --- a/app/views/abouts/show.html.erb +++ b/app/views/abouts/show.html.erb @@ -1,10 +1,11 @@ <% content_for :leftcol do %> - -

+ <% end %>

+ <% end %>

<%= @about.title %>

@@ -33,4 +34,7 @@ <%= link_to "Edit", edit_about_path(@about) %> <% end %>
-<%= raw @about.content %> \ No newline at end of file +<%= raw @about.content %> +<% content_for :rightcol do %> + <%= render :partial => "events" %> +<% end %> \ No newline at end of file diff --git a/app/views/application/_events.html.erb b/app/views/application/_events.html.erb index fed6ac6..9de832f 100644 --- a/app/views/application/_events.html.erb +++ b/app/views/application/_events.html.erb @@ -7,20 +7,21 @@ <%= l(event.date, :format => "%B") %> <% end %> <%= l(event.date, :format => "%d") %> - - <% if event.external_link %> - <%= link_to event.title, event.external_link %> - <% else %> + + <% if event.external_link.blank? %> <%= link_to event.title, event %> - <% end %> + <% else %> + <%= link_to event.title, event.external_link %> + <% end %> - <%= strip_tags(event.content) %>
+ <%= truncate_html(event.content, :length => 80, :omission => "..") %> <% if event.external_link %> - <%= link_to "read more", event.external_link, :class => "readmore" %> + <%= link_to "read more", event.external_link, :class => "readmore" %> <% else %> - <%= link_to "read more", event, :class => "readmore" %> + <%= link_to "read more", event, :class => "readmore" %> <% end %> <% end %> - \ No newline at end of file +

+<%= link_to "more events", events_path, :class => "readmore" %>

\ No newline at end of file diff --git a/app/views/application/_search.html.erb b/app/views/application/_search.html.erb index 1b66ae7..588bb48 100644 --- a/app/views/application/_search.html.erb +++ b/app/views/application/_search.html.erb @@ -1,5 +1,5 @@ <% @search = Page.search(params[:search]) %> <%= form_for @search do |f| %> - <%= f.text_field :content_contains, :size => '30' %> + <%= f.text_field :content_contains %> <%= f.submit "Search" %> <% end %> \ No newline at end of file diff --git a/app/views/blogpages/_form.html.erb b/app/views/blogpages/_form.html.erb index 83f7918..45eebcc 100644 --- a/app/views/blogpages/_form.html.erb +++ b/app/views/blogpages/_form.html.erb @@ -28,6 +28,10 @@ <%= f.label :author %> <%= f.text_field :author %> +
+ <%= f.label :tags %> + <%= f.text_field :tags %> +
<% end %>
<%= f.submit "Save" %> diff --git a/app/views/blogpages/show.html.erb b/app/views/blogpages/show.html.erb index 5afc18d..3620e42 100644 --- a/app/views/blogpages/show.html.erb +++ b/app/views/blogpages/show.html.erb @@ -25,4 +25,7 @@ <% if @comments.blank? %>

No comments were found.

<% end %> -<%= link_to "Add comment", new_blogpage_comment_path(@blogpage, Comment.new) %> \ No newline at end of file +<%= link_to "Add comment", new_blogpage_comment_path(@blogpage, Comment.new) %> +<% content_for :rightcol do %> + <%= render :partial => "related" %> +<% end %> \ No newline at end of file diff --git a/app/views/cases/_form.html.erb b/app/views/cases/_form.html.erb index c15e341..d715a0a 100644 --- a/app/views/cases/_form.html.erb +++ b/app/views/cases/_form.html.erb @@ -28,6 +28,10 @@ <%= f.label :author %> <%= f.text_field :author %>
+
+ <%= f.label :tags %> + <%= f.text_field :tags %> +
<% end %>
<%= f.submit "Save" %> diff --git a/app/views/cases/index.html.erb b/app/views/cases/index.html.erb index 9db2b1b..87dc8ea 100644 --- a/app/views/cases/index.html.erb +++ b/app/views/cases/index.html.erb @@ -15,4 +15,7 @@
<%= truncate_html(page.content, :length => 400, :omission => '...') %> <%= link_to "read more", page, :class => "readmore" %> +<% end %> +<% content_for :rightcol do %> + <%= render :partial => "events" %> <% end %> \ No newline at end of file diff --git a/app/views/cases/show.html.erb b/app/views/cases/show.html.erb index eb059e7..4837aa3 100644 --- a/app/views/cases/show.html.erb +++ b/app/views/cases/show.html.erb @@ -7,4 +7,7 @@ <%= link_to "Delete", @case, :confirm => "Are you sure you want to delete "+@case.title+"?\nThis action cannot be undone!", :method => :delete %> <% end %> -<%= raw @case.content %> \ No newline at end of file +<%= raw @case.content %> +<% content_for :rightcol do %> + <%= render :partial => "events" %> +<% end %> \ No newline at end of file diff --git a/app/views/events/_form.html.erb b/app/views/events/_form.html.erb index 0d999e7..8139c6a 100644 --- a/app/views/events/_form.html.erb +++ b/app/views/events/_form.html.erb @@ -37,6 +37,10 @@ <%= f.label :external_link %> <%= f.text_field :external_link %> +
+ <%= f.label :tags %> + <%= f.text_field :tags %> +
<%= f.submit "Save" %>
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 0752af5..2735115 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -10,6 +10,11 @@ <% else %> <%= link_to event.title, event.external_link %> <% end %> -

on: <%= l(event.date, :format => "%d-%b-%Y") %>


+ +
+ <% if can? :update, event %> + <%= link_to "Edit", edit_event_path(event) %> + <% end %>
+

on: <%= l(event.date, :format => "%d-%b-%Y") %>


<%= truncate_html(event.content, :length => 400, :omission => '...') %> <% end %> \ No newline at end of file diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb index dd84016..a3704f7 100644 --- a/app/views/pages/index.html.erb +++ b/app/views/pages/index.html.erb @@ -1,7 +1,7 @@

search results

<% @pages.each do |page| %> <% if can? :read, page %> -

<%= link_to page.title, page %>


<%= truncate_html(page.content, :length => 50, :omission => "...") %>

+

<%= link_to page.title, page %>


<%= truncate_html(page.content, :length => 400, :omission => "...") %>

<% end %> <% end %> \ No newline at end of file diff --git a/app/views/profiles/_form.html.erb b/app/views/profiles/_form.html.erb index 9fe1640..3552258 100644 --- a/app/views/profiles/_form.html.erb +++ b/app/views/profiles/_form.html.erb @@ -47,7 +47,10 @@ <%= f.label "Department" %>: <%= f.text_field :department %> - +
+ <%= f.label :tags %> + <%= f.text_field :tags %> +
<%= f.submit %>
diff --git a/app/views/profiles/index.html.erb b/app/views/profiles/index.html.erb index 83510ba..b0b6a87 100644 --- a/app/views/profiles/index.html.erb +++ b/app/views/profiles/index.html.erb @@ -4,32 +4,18 @@ <% end %> <% @profiles.each do |profile| %> -

<% name = "" %> - <% unless profile.prefix.blank? %> - <% name += profile.prefix.strip + " " %> - <% end %> - <% name += profile.firstname.strip + " " %> - <% unless profile.middlename.blank? %> - <% name += profile.middlename.strip + " " %> - <% end %> - <% name += profile.lastname.strip + " " %> - <% unless profile.suffix.blank? %> - <% name += profile.suffix.strip + " " %> - <% end %> - <% unless profile.firstnamefull.blank? %> - <% name += "(" + profile.firstnamefull.strip + ")" %> - <% end %> +

<% unless profile.external_link.blank? %> - <%= link_to name, profile.external_link %> + <%= link_to profile.fullname, profile.external_link %> <% else%> - <%= name %> + <%= profile.fullname %> <% end %> - (<%=profile.university%><% unless profile.department.blank? %> - <%=profile.department%><% end %>) + (<%=profile.university%><% unless profile.department.blank? %> - <%= profile.department %><% end %>) <% if can? :update, profile %> | <%= link_to "Edit", edit_profile_path(profile) %> <% end %> <% if can? :destroy, profile %> - | <%= link_to "Delete", profile, :confirm => "Are you sure to delete "+name+"?\nThis action cannot be undone!", :method => :delete %> + | <%= link_to "Delete", profile, :confirm => "Are you sure to delete "+profile.fullname+"?\nThis action cannot be undone!", :method => :delete %> <% end %>

<% end %> diff --git a/db/schema.rb b/db/schema.rb index 437960d..ecbcb39 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111014150759) do +ActiveRecord::Schema.define(:version => 20111019142819) do create_table "ckeditor_assets", :force => true do |t| t.string "data_file_name", :null => false @@ -51,6 +51,7 @@ t.string "type" t.string "external_link" t.datetime "date" + t.string "tags" end create_table "profiles", :force => true do |t| @@ -65,6 +66,7 @@ t.string "middlename" t.string "firstnamefull" t.string "department" + t.string "tags" end create_table "users", :force => true do |t|