| |   |
| 20 | 20 | out << %Q{<div class='articlebox #{article.article_type.to_s}'><div class='formattedtext'>} |
| 21 | 21 | # |
| 22 | 22 | # title |
| 23 | | if use_permalink then |
| 23 | if use_permalink |
| 24 | 24 | out << %Q{<h2 class='blacklink'>} |
| 25 | 25 | out << %Q{#{article.project.title}: } if article.project.id > 1 |
| 26 | 26 | out << %Q{#{link_to_article(article)}</h2>} |
| … | … | |
| 36 | 36 | # date by user |
| 37 | 37 | out << %Q{<h5>#{format_datetime_article(article.created_at)} by #{link_to(article.user.fullname, user_path(article.user))}} |
| 38 | 38 | # |
| 39 | | if article.category.id > 1 then |
| 39 | if article.category.id > 1 |
| 40 | 40 | out << %Q{ in <a href='/archives/category/#{to_slug(article.category.name)}'>#{article.category.name}</a>} |
| 41 | 41 | else |
| 42 | 42 | # if no category, show a project link (if available) |
| … | … | |
| 49 | 49 | out << %Q{, #{0} comments</h5>} |
| 50 | 50 | # |
| 51 | 51 | # body |
| 52 | | if short then |
| 52 | if short |
| 53 | 53 | article.body_summary.length > 0 ? out << article.body_summary : out << article.body |
| 54 | 54 | else |
| 55 | 55 | out << article.body |
| … | … | |
| 68 | 68 | out = %Q{<div id='archive'>} |
| 69 | 69 | for article in articles |
| 70 | 70 | #FIXME can remove the .to_s from the temp year/month variables |
| 71 | | if year != article.created_at.year.to_s then |
| 72 | | if year_started then |
| 71 | if year != article.created_at.year.to_s |
| 72 | if year_started |
| 73 | 73 | out << %Q{</ul>} if month_started |
| 74 | 74 | out << %Q{</li></ul>} |
| 75 | 75 | end |
| … | … | |
| 79 | 79 | out << %Q{<h2>#{year}</h2><ul><li>} |
| 80 | 80 | end |
| 81 | 81 | # |
| 82 | | if month != article.created_at.month.to_s then |
| 82 | if month != article.created_at.month.to_s |
| 83 | 83 | out << %Q{</ul>} if month_started |
| 84 | 84 | month_started = true |
| 85 | 85 | month = article.created_at.month.to_s |
| … | … | |
| 110 | 110 | out << %Q{<td width=90>#{get_article_bullet(article.article_type)} #{article.article_type.to_s.capitalize}</td>} |
| 111 | 111 | out << %Q{<td>#{link_to_article(article)}</td>} |
| 112 | 112 | out << %Q{<td width=140>} |
| 113 | | if article.project.id > 1 then |
| 113 | if article.project.id > 1 |
| 114 | 114 | out << link_to(article.project.title, article_project_path(article.project.slug)) |
| 115 | 115 | else |
| 116 | 116 | #FIXME sitename/domainname aren't clear, using domainname mostly |
| … | … | |
| 129 | 129 | end |
| 130 | 130 | |
| 131 | 131 | def apg_cell (col, a, u) |
| 132 | | if a != nil then |
| 132 | if a != nil |
| 133 | 133 | @c = @c + a.type_count.to_i |
| 134 | 134 | out = %Q{<td style='border-top: 1px solid #ccc; background-color: #{col}'>} |
| 135 | | if a.type_count.to_i > 0 then |
| 135 | if a.type_count.to_i > 0 |
| 136 | 136 | # if sitename row, use a different slug |
| 137 | | if u == "" then |
| 137 | if u == "" |
| 138 | 138 | #FIXME this is wrong, it should only show SiteName articles |
| 139 | 139 | out << %Q{<a href='/archives/#{SITENAME}/#{a.article_type.to_s}'>#{a.type_count.to_s}</a>} |
| 140 | 140 | else |
| … | … | |
| 154 | 154 | # project or sitename td |
| 155 | 155 | out = %Q{<tr><th style='border-top: 1px solid #ccc;'>} |
| 156 | 156 | # sitename or project name |
| 157 | | if p == "Other" then |
| 157 | if p == "Other" |
| 158 | 158 | out << %Q{#{link_to("Other", article_sitename_path)}} |
| 159 | 159 | else |
| 160 | 160 | #FIXME had to frig this until project routes merged |
| … | … | |
| 169 | 169 | out << apg_cell('#fff8ee', a[4], u) |
| 170 | 170 | out << apg_cell('#eee', a[5], u) |
| 171 | 171 | # total column |
| 172 | | # out << %Q{<td style='border-top: 1px solid #ccc;'>} |
| 173 | | # if @c.to_i > 0 then |
| 174 | | # out << %Q{<a href='/archives/} |
| 175 | | # # if sitename row, use a different slug |
| 176 | | # u == "" ? out << %Q{#{SITENAME}'>} : out << %Q{project/#{u}'>} |
| 177 | | # out << %Q{#{@c.to_s}</a>} |
| 178 | | # else |
| 179 | | # out << %Q{0} |
| 180 | | # end |
| 181 | 172 | out << %Q{</td></tr>} |
| 182 | 173 | out |
| 183 | 174 | end |
| … | … | |
| 199 | 199 | out << rapg_row("issue", "12", "42") |
| 200 | 200 | out << rapg_row("howto", "12", "55") |
| 201 | 201 | out << rapg_row("other", "13", "45") |
| 202 | | #out << %Q{<td style='padding-top: 4px'></td>} |
| 203 | 202 | out << %Q{</tr>} |
| 204 | 203 | out << %Q{</table>} |
| 205 | 204 | out |
| toggle raw diff |
--- a/app/helpers/articles_helper.rb
+++ b/app/helpers/articles_helper.rb
@@ -20,7 +20,7 @@ module ArticlesHelper
out << %Q{<div class='articlebox #{article.article_type.to_s}'><div class='formattedtext'>}
#
# title
- if use_permalink then
+ if use_permalink
out << %Q{<h2 class='blacklink'>}
out << %Q{#{article.project.title}: } if article.project.id > 1
out << %Q{#{link_to_article(article)}</h2>}
@@ -36,7 +36,7 @@ module ArticlesHelper
# date by user
out << %Q{<h5>#{format_datetime_article(article.created_at)} by #{link_to(article.user.fullname, user_path(article.user))}}
#
- if article.category.id > 1 then
+ if article.category.id > 1
out << %Q{ in <a href='/archives/category/#{to_slug(article.category.name)}'>#{article.category.name}</a>}
else
# if no category, show a project link (if available)
@@ -49,7 +49,7 @@ module ArticlesHelper
out << %Q{, #{0} comments</h5>}
#
# body
- if short then
+ if short
article.body_summary.length > 0 ? out << article.body_summary : out << article.body
else
out << article.body
@@ -68,8 +68,8 @@ module ArticlesHelper
out = %Q{<div id='archive'>}
for article in articles
#FIXME can remove the .to_s from the temp year/month variables
- if year != article.created_at.year.to_s then
- if year_started then
+ if year != article.created_at.year.to_s
+ if year_started
out << %Q{</ul>} if month_started
out << %Q{</li></ul>}
end
@@ -79,7 +79,7 @@ module ArticlesHelper
out << %Q{<h2>#{year}</h2><ul><li>}
end
#
- if month != article.created_at.month.to_s then
+ if month != article.created_at.month.to_s
out << %Q{</ul>} if month_started
month_started = true
month = article.created_at.month.to_s
@@ -110,7 +110,7 @@ module ArticlesHelper
out << %Q{<td width=90>#{get_article_bullet(article.article_type)} #{article.article_type.to_s.capitalize}</td>}
out << %Q{<td>#{link_to_article(article)}</td>}
out << %Q{<td width=140>}
- if article.project.id > 1 then
+ if article.project.id > 1
out << link_to(article.project.title, article_project_path(article.project.slug))
else
#FIXME sitename/domainname aren't clear, using domainname mostly
@@ -129,12 +129,12 @@ module ArticlesHelper
end
def apg_cell (col, a, u)
- if a != nil then
+ if a != nil
@c = @c + a.type_count.to_i
out = %Q{<td style='border-top: 1px solid #ccc; background-color: #{col}'>}
- if a.type_count.to_i > 0 then
+ if a.type_count.to_i > 0
# if sitename row, use a different slug
- if u == "" then
+ if u == ""
#FIXME this is wrong, it should only show SiteName articles
out << %Q{<a href='/archives/#{SITENAME}/#{a.article_type.to_s}'>#{a.type_count.to_s}</a>}
else
@@ -154,7 +154,7 @@ module ArticlesHelper
# project or sitename td
out = %Q{<tr><th style='border-top: 1px solid #ccc;'>}
# sitename or project name
- if p == "Other" then
+ if p == "Other"
out << %Q{#{link_to("Other", article_sitename_path)}}
else
#FIXME had to frig this until project routes merged
@@ -169,15 +169,6 @@ module ArticlesHelper
out << apg_cell('#fff8ee', a[4], u)
out << apg_cell('#eee', a[5], u)
# total column
-# out << %Q{<td style='border-top: 1px solid #ccc;'>}
-# if @c.to_i > 0 then
-# out << %Q{<a href='/archives/}
-# # if sitename row, use a different slug
-# u == "" ? out << %Q{#{SITENAME}'>} : out << %Q{project/#{u}'>}
-# out << %Q{#{@c.to_s}</a>}
-# else
-# out << %Q{0}
-# end
out << %Q{</td></tr>}
out
end
@@ -208,7 +199,6 @@ module ArticlesHelper
out << rapg_row("issue", "12", "42")
out << rapg_row("howto", "12", "55")
out << rapg_row("other", "13", "45")
- #out << %Q{<td style='padding-top: 4px'></td>}
out << %Q{</tr>}
out << %Q{</table>}
out |
| |   |
| 153 | 153 | # |
| 154 | 154 | def self.allowed_access (project_id, curruser) |
| 155 | 155 | projects_allowed = Project.list_for_user(curruser) |
| 156 | | p = find(:first, :conditions => ["status = '#{:active}' AND projects.id = '" << project_id.to_s << "' AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"]) |
| 157 | | if p != nil then |
| 158 | | return true |
| 159 | | else |
| 160 | | return false |
| 161 | | end |
| 156 | find(:first, :conditions => ["status = '#{:active}' AND projects.id = '" << project_id.to_s << "' AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"]) |
| 162 | 157 | end |
| 163 | 158 | |
| 164 | 159 | # |
| … | … | |
| 199 | 199 | # Get a list of project_ids of a user is a members of in the format '1','2','3' |
| 200 | 200 | # |
| 201 | 201 | def self.list_for_user(user) |
| 202 | | if user != nil then |
| 202 | if user |
| 203 | 203 | list = "" |
| 204 | 204 | projects = Member.find_by_user(user.id) |
| 205 | 205 | unless projects.empty? |
| 206 | 206 | start = true |
| 207 | 207 | for project in projects |
| 208 | | if not start then |
| 209 | | list = list << "," |
| 210 | | else |
| 211 | | start = false |
| 212 | | end |
| 208 | !start ? list = list << "," : start = false |
| 213 | 209 | list = list << "'" << project.project_id.to_s << "'" |
| 214 | 210 | end |
| 215 | | return list |
| 211 | list |
| 216 | 212 | else |
| 217 | | return "'1'" # see below |
| 213 | "'1'" # see below |
| 218 | 214 | end |
| 219 | 215 | else |
| 220 | | return "'1'" # Project.id 1 is no project (this is a bit of a frig really, without it 2 queries will be needed for all finds) |
| 216 | "'1'" # Project.id 1 is no project (this is a bit of a frig really, without it 2 queries will be needed for all finds) |
| 221 | 217 | end |
| 222 | 218 | end |
| 223 | 219 | |
| toggle raw diff |
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -153,12 +153,7 @@ class Project < ActiveRecord::Base
#
def self.allowed_access (project_id, curruser)
projects_allowed = Project.list_for_user(curruser)
- p = find(:first, :conditions => ["status = '#{:active}' AND projects.id = '" << project_id.to_s << "' AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"])
- if p != nil then
- return true
- else
- return false
- end
+ find(:first, :conditions => ["status = '#{:active}' AND projects.id = '" << project_id.to_s << "' AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"])
end
#
@@ -204,25 +199,21 @@ class Project < ActiveRecord::Base
# Get a list of project_ids of a user is a members of in the format '1','2','3'
#
def self.list_for_user(user)
- if user != nil then
+ if user
list = ""
projects = Member.find_by_user(user.id)
unless projects.empty?
start = true
for project in projects
- if not start then
- list = list << ","
- else
- start = false
- end
+ !start ? list = list << "," : start = false
list = list << "'" << project.project_id.to_s << "'"
end
- return list
+ list
else
- return "'1'" # see below
+ "'1'" # see below
end
else
- return "'1'" # Project.id 1 is no project (this is a bit of a frig really, without it 2 queries will be needed for all finds)
+ "'1'" # Project.id 1 is no project (this is a bit of a frig really, without it 2 queries will be needed for all finds)
end
end
|