Permalink
Browse files

Initial Checkin

  • Loading branch information...
0 parents commit 0bf99063320e1131230657c15a39b1512c48facd @pjb3 pjb3 committed Apr 9, 2009
Showing 639 changed files with 63,575 additions and 0 deletions.
@@ -0,0 +1,11 @@
+coverage/**/*
+.DS_Store
+log/*.log
+tmp/**/*
+db/*.sqlite3
+db/schema.rb
+config/database.yml
+*.gem
+.dotest
+tmp/restart.txt
+public/cache
4 README
@@ -0,0 +1,4 @@
+BrowserCMS News Module
+======================
+
+This is the BrowserCMS News Module. This includes...
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
@@ -0,0 +1,10 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
+
+ # Scrub sensitive parameters from your log
+ # filter_parameter_logging :password
+end
@@ -0,0 +1,2 @@
+class Cms::NewsArticlesController < Cms::ContentBlockController
+end
@@ -0,0 +1,3 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end
@@ -0,0 +1,63 @@
+class NewsArticle < ActiveRecord::Base
+
+ acts_as_content_block :belongs_to_attachment => true, :taggable => true
+
+ belongs_to :category
+
+ validates_presence_of :name, :release_date
+
+ before_validation :set_slug
+
+ def category_name
+ category ? category.name : nil
+ end
+
+ def set_slug
+ self.slug = name.to_slug unless name.blank?
+ end
+
+ def self.prepare_params_for_details!(params)
+ release_date_string = "#{params[:month]}/#{params[:day]}/#{params[:year]}"
+ release_date = Date.parse(release_date_string)
+ news_article = NewsArticle.first(:conditions => ["release_date = ? and slug = ?", release_date, params[:slug]])
+ params[:news_article_id] = news_article.id if news_article
+ end
+
+ def details_params
+ {:year => release_date.strftime("%Y"), :month => release_date.strftime("%m"), :day => release_date.strftime("%d"), :slug => slug}
+ end
+
+ def year
+ release_date ? release_date.year : nil
+ end
+
+ def month
+ release_date ? release_date.month : nil
+ end
+
+ def set_attachment_section
+ if new_record? && !attachment_file.blank?
+ attachment.section = Section.first(:conditions => {:name => 'News'})
+ end
+ end
+
+ def set_attachment_file_path
+ if new_record? && !attachment_file.blank?
+ attachment.file_path = "/news/articles/attachment/#{Time.now.to_s(:year_month_day)}/#{name.to_slug}.#{attachment_file.original_filename.split('.').last.to_s.downcase}"
+ end
+ end
+
+ def renderer(news_article)
+ lambda do
+ buf = ""
+ buf += "<p><b>Name:</b> #{news_article.name}</p>"
+ buf += "<p><b>Release Date:</b> #{news_article.release_date}</p>"
+ buf += "<p><b>Category:</b> #{news_article.category_name}</p>"
+ buf += "<p><b>Attachment:</b> <a href=\"#{news_article.attachment_link}\">#{news_article.attachment_file_path}</a></p>"
+ buf += "<p><b>Summary:</b> #{news_article.summary}</p>"
+ buf += "<p><b>Body:</b> #{news_article.body}</p>"
+ end
+
+ end
+
+end
@@ -0,0 +1,21 @@
+class NewsArchivePortlet < Portlet
+
+ def self.default_template
+ open(File.join(File.dirname(__FILE__),
+ "..", "views", "portlets", "news_archive", "render.html.erb")) {|f| f.read}
+ end
+
+ def render
+ if category_id.blank?
+ @articles = NewsArticle.all(:order => "release_date desc", :limit => limit)
+ else
+ @category = Category.find(category_id)
+ @articles = NewsArticle.all(:conditions => ["category_id = ?", @category.id], :order => "release_date desc", :limit => limit)
+ end
+ end
+
+ def inline_options
+ {:inline => template}
+ end
+
+end
@@ -0,0 +1,17 @@
+class NewsArticlePortlet < Portlet
+
+ def self.default_template
+ open(File.join(File.dirname(__FILE__),
+ "..", "views", "portlets", "news_article", "render.html.erb")) {|f| f.read}
+ end
+
+ def inline_options
+ if params[:news_article_id]
+ @article = NewsArticle.find(params[:news_article_id])
+ {:inline => template}
+ else
+ {:inline => "<b>Missing required parameter</b><br/>This portlet expects a request parameter 'news_article_id'. Be sure the calling page provides it."}
+ end
+ end
+
+end
@@ -0,0 +1,21 @@
+class NewsRssPortlet < Portlet
+
+ def self.default_template
+ open(File.join(File.dirname(__FILE__),
+ "..", "views", "portlets", "news_rss", "render.xml.erb")) {|f| f.read}
+ end
+
+ def render
+ if category_id.blank?
+ @articles = NewsArticle.all(:order => "release_date desc", :limit => limit)
+ else
+ @category = Category.find(category_id)
+ @articles = NewsArticle.all(:conditions => ["category_id = ?", @category.id], :order => "release_date desc", :limit => limit)
+ end
+ end
+
+ def inline_options
+ {:inline => template}
+ end
+
+end
@@ -0,0 +1,18 @@
+class RecentNewsPortlet < Portlet
+
+ def self.default_template
+ open(File.join(File.dirname(__FILE__),
+ "..", "views", "portlets", "recent_news", "render.html.erb")) {|f| f.read}
+ end
+
+ def inline_options
+ if portlet.category_id.blank?
+ @articles = NewsArticle.all(:order => "release_date desc", :limit => limit)
+ else
+ @category = Category.find(category_id)
+ @articles = NewsArticle.all(:conditions => ["category_id = ?", @category.id], :order => "release_date desc", :limit => limit)
+ end
+ {:inline => portlet.template}
+ end
+
+end
@@ -0,0 +1,7 @@
+<%= f.cms_text_field :name %>
+<%= f.cms_date_picker :release_date %>
+<%= f.cms_drop_down :category_id, categories_for('News Article').map{|c| [c.path, c.id]} %>
+<%= f.cms_text_area :summary, :style => "height: 100px" %>
+<%= f.cms_text_editor :body %>
+<%= f.cms_file_field :attachment_file, :label => "File" %>
+<%= f.cms_tag_list %>
@@ -0,0 +1,3 @@
+<%= f.cms_text_field :name %>
+<%= f.cms_drop_down :category_id, categories_for('News Article').map{|c| [c.path, c.id]}, :include_blank => true %>
+<%= f.cms_text_area :template, :default_value => @block.class.default_template %>
@@ -0,0 +1,20 @@
+<div>
+ <% @articles.group_by(&:year).sort_by(&:first).reverse.each do |year, year_articles| %>
+ <!-- <%= year %> -->
+ <% year_articles.group_by(&:month).sort_by(&:first).reverse.each do |month, month_articles| %>
+ <b class="month"><%= Date::MONTHNAMES[month] %></b>
+ <% for article in month_articles.sort_by(&:release_date).reverse %>
+ <div class="news-item">
+ <% unless article.release_date.blank? -%>
+ <span class="release-date"><b><%= article.release_date.to_s(:long) %></b></span><br/>
+ <% end %>
+
+ <%= link_to "<b>#{h(article.name)}</b>", news_articles_path(article.details_params) %><br/>
+ <% unless article.summary.blank? -%>
+ <p><%=h article.summary %></p>
+ <% end %>
+ </div>
+ <% end %>
+ <% end %>
+ <% end %>
+</div>
@@ -0,0 +1,2 @@
+<%= f.cms_text_field :name %>
+<%= f.cms_text_area :template, :default_value => @block.class.default_template %>
@@ -0,0 +1,3 @@
+<% @page_title = @article.name %>
+<h2><%=h @article.name %></h2>
+<p><%= @article.body %></p>
@@ -0,0 +1,5 @@
+<%= f.cms_text_field :name %>
+<%= f.cms_text_field :limit, :label => "Number to show", :size => 2 %>
+<%= f.cms_drop_down :category_id, categories_for('News Article').map{|c| [c.path, c.id]}, :include_blank => true %>
+<%= f.cms_text_field :more_link %>
+<%= f.cms_text_area :template, :default_value => @block.class.default_template %>
@@ -0,0 +1,18 @@
+xml.instruct! :xml, :version=>"1.0"
+xml.rss(:version=>"2.0") do
+ xml.channel do
+ xml.title("Articles")
+ xml.link("/news/rss")
+ xml.description("")
+ xml.language('en-us')
+ for article in @articles
+ xml.item do
+ xml.title(article.name)
+ xml.description(article.summary) unless article.summary.blank?
+ xml.pubDate(article.release_date.strftime("%a, %d %b %Y %H:%M:%S %z")) unless article.release_date.blank?
+ xml.link(news_articles_path(article.details_params))
+ xml.guid(news_articles_path(article.details_params))
+ end
+ end
+ end
+end
@@ -0,0 +1,5 @@
+<%= f.cms_text_field :name %>
+<%= f.cms_text_field :limit, :label => "Number to show", :size => 2 %>
+<%= f.cms_drop_down :category_id, categories_for('News Article').map{|c| [c.path, c.id]}, :include_blank => true %>
+<%= f.cms_text_field :more_link %>
+<%= f.cms_text_area :template, :default_value => @block.class.default_template %>
@@ -0,0 +1,21 @@
+<b>Latest News</b>
+<br/>
+<br/>
+
+<% for article in @articles %>
+ <div class="news-item-browser">
+ <% if article.release_date -%>
+ <b><%= article.release_date.to_date.to_s(:long) %></b>
+ <br/>
+ <% end %>
+
+ <%= link_to h(article.name), news_articles_path(article.details_params) %>
+
+ </div>
+<% end %>
+
+<% unless @portlet.more_link.blank? -%>
+ <div class="news-item-browser">
+ <%= link_to "MORE", @portlet.more_link %>
+ </div>
+<% end %>
@@ -0,0 +1,21 @@
+SPEC = Gem::Specification.new do |spec|
+ spec.name = "browser_cms_news_module"
+ spec.rubyforge_project = spec.name
+ spec.version = "3.0.0"
+ spec.summary = "The News Module for BrowserCMS"
+ spec.author = "BrowserMedia"
+ spec.email = "github@browsermedia.com"
+ spec.homepage = "http://www.browsercms.org"
+ spec.files += Dir["app/controllers/cms/news_articles_controller.rb"]
+ spec.files += Dir["app/models/news_article.rb"]
+ spec.files += Dir["app/portlets/*"]
+ spec.files += Dir["app/views/cms/news_articles/*"]
+ spec.files += Dir["app/views/portlets/**/*"]
+ spec.files += Dir["db/migrate/[0-9]*_create_news_articles.rb"]
+ spec.files += Dir["lib/browser_cms_news_module.rb"]
+ spec.files += Dir["lib/browser_cms_news_module/*"]
+ spec.files += Dir["rails/init.rb"]
+ spec.has_rdoc = true
+ spec.extra_rdoc_files = ["README"]
+ #spec.require_path "lib"
+end
Oops, something went wrong.

0 comments on commit 0bf9906

Please sign in to comment.