Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cook committed Jan 30, 2009
2 parents 6994d6d + 78eaf0a commit 9f9b5a0
Show file tree
Hide file tree
Showing 227 changed files with 4,504 additions and 5,025 deletions.
6 changes: 6 additions & 0 deletions app/controllers/admin/dashboards_controller.rb
@@ -0,0 +1,6 @@
class Admin::DashboardsController < Admin::BaseController
# NOTE: Can grab a user-specific settings collection here, or we could make it site-specific. Should be decided.

def show
end
end
2 changes: 2 additions & 0 deletions app/controllers/admin/pages_controller.rb
Expand Up @@ -31,6 +31,7 @@ def edit
end

def update
@page.settings = params[:settings]
if @page.update_attributes(params[:page])
handle_publishing_workflow
flash.now[:message] = 'Page Updated Successfully'
Expand All @@ -56,6 +57,7 @@ def new

def create
@page.name = @page.name.gsub(' ', '_')
@page.settings = params[:settings]
if @page.save
attach_page_plugins
message = 'Page Added Successfully'
Expand Down
18 changes: 18 additions & 0 deletions app/controllers/comments_controller.rb
@@ -0,0 +1,18 @@
class CommentsController < ApplicationController
before_filter :load_new_comment, :only => [:create]

protected
def load_new_comment
@comment = Comment.new(params[:comment])
end

public
def create
if @comment.save
flash[:notice] = "Comment was submitted successfully."
else
flash[:error] = "There was a problem with your comment."
end
redirect_to params[:return_path]
end
end
2 changes: 0 additions & 2 deletions app/helpers/admin_helper.rb

This file was deleted.

27 changes: 27 additions & 0 deletions app/helpers/comments_helper.rb
@@ -0,0 +1,27 @@
module CommentsHelper
def show_comments_for(commentable)
if commentable.settings["allow_comments"]
render :partial => 'shared/comments', :locals => { :commentable => commentable }
end
end

def show_comment_form_for(commentable, options={})
raise "No return path specified" unless options[:return_path]
if commentable.settings["allow_comments"]
comment = Comment.new
comment.commentable = commentable
render :partial => 'shared/comment_form', :locals => { :comment => comment, :commentable => commentable, :return_path => options[:return_path] }
end
end

def show_comment(comment)
render :partial => 'shared/comment', :locals => { :comment => comment }
end

def show_comment_info_link_for(commentable, options={})
raise "No path specified" unless options[:path]
if commentable.settings["allow_comments"]
render :partial => 'shared/comment_info_link', :locals => { :commentable => commentable, :path => options[:path] }
end
end
end
5 changes: 5 additions & 0 deletions app/helpers/dashboard_helper.rb
@@ -0,0 +1,5 @@
module DashboardHelper
def render_dashboard_box dashboard_box
render :partial => 'shared/render_dashboard_box', :locals => { :dashboard_box => dashboard_box }
end
end
14 changes: 14 additions & 0 deletions app/helpers/gravatar_helper.rb
@@ -0,0 +1,14 @@
# Shamelessly taken from Typo (http://www.typosphere.org)

module GravatarHelper
# Generate the image tag for a commenters gravatar based on their email address
# Valid options are described at http://www.gravatar.com/implement.php
def gravatar_tag(email, options={})
options.update(:gravatar_id => Digest::MD5.hexdigest(email.strip))
options[:default] = CGI::escape(options[:default]) if options.include?(:default)
options[:size] ||= 60

image_tag("http://www.gravatar.com/avatar.php?" <<
options.map { |key,value| "#{key}=#{value}" }.sort.join("&"), :class => "gravatar")
end
end
38 changes: 38 additions & 0 deletions app/models/comment.rb
@@ -0,0 +1,38 @@
# This was copied from the acts_as_commentable plugin, and I'm changing it a bit - JA
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true

# NOTE: install the acts_as_votable plugin if you
# want user to vote on the quality of comments.
#acts_as_voteable

# NOTE: Comments belong to a user
belongs_to :user

named_scope :recent, :limit => 5, :order => "created_at DESC"
named_scope :for, lambda{ |klass| { :conditions => ["commentable_type = ?", klass] } }

# Helper class method to lookup all comments assigned
# to all commentable types for a given user.
def self.find_comments_by_user(user)
find(:all,
:conditions => ["user_id = ?", user.id],
:order => "created_at DESC"
)
end

# Helper class method to look up all comments for
# commentable class name and commentable id.
def self.find_comments_for_commentable(commentable_str, commentable_id)
find(:all,
:conditions => ["commentable_type = ? and commentable_id = ?", commentable_str, commentable_id],
:order => "created_at DESC"
)
end

# Helper class method to look up a commentable object
# given the commentable class name and id
def self.find_commentable(commentable_str, commentable_id)
commentable_str.constantize.find(commentable_id)
end
end
9 changes: 8 additions & 1 deletion app/models/page.rb
Expand Up @@ -22,6 +22,9 @@
class Page < ActiveRecord::Base
include AASM
include ActionView::Helpers::DateHelper
acts_as_commentable
has_settings

named_scope :visible, :conditions => ["(expires_on > ? OR expires_on IS NULL) AND published = ? AND (publish_at <= ? OR publish_at IS NULL )", Time.now.getgm, true, Time.now.getgm]
named_scope :self_and_siblings, lambda {|page| {:conditions => ["parent_id = ?", page.parent_id], :order => 'page_order'}}
named_scope :expired, lambda {|p| { :conditions => ["expires_on < ?", Time.now.getgm] } }
Expand Down Expand Up @@ -177,7 +180,7 @@ def find_child(child_name)
def self.find_page_by_path(path)
#logger.error("==> find_page_by_path: path = [ #{path.join("/")} ]")
page = Page.root
return nil if Page.root.nil?
return nil if page.nil?

# Not DRY. This piece of code handles multipage root
return page.split_page! if path.length < 1 or page.name == path[0]
Expand Down Expand Up @@ -235,6 +238,10 @@ def is_draft?
status == 'draft'
end

def permalinkable_title
title.downcase.gsub(/ /, '-')
end

protected
def check_page_type
self.page_type = "page" and return if self.body.blank? || (@split_pages = self.body.split(/\{pagebreak\}/i)).length == 1
Expand Down
12 changes: 12 additions & 0 deletions app/views/admin/dashboards/show.html.erb
@@ -0,0 +1,12 @@
<%= title "Dashboard" %>

<div class='twocol'>
<% Ansuz::PluginManagerInstance.admin_dashboard_boxes.in_groups(2).each_with_index do |half, i| %>
<div class='col <%= "left" if i==0 %>'>
<% half.compact.each do |dashboard_box| %>
<%= render_dashboard_box dashboard_box %>
<% end %>
</div>
<% end %>
<div class='clear'></div>
</div>
13 changes: 13 additions & 0 deletions app/views/admin/default_dashboard_boxes/_at_a_glance.html.erb
@@ -0,0 +1,13 @@
<ul class='at-a-glance'>
<% Ansuz::PluginManagerInstance.at_a_glance_entries.each do |entry| %>
<li>
<em><%= entry[2].call %></em>
<% if entry[1] # they provided an url
%>
<%= link_to entry[0], entry[1] %>
<% else %>
<%= entry[0] %>
<% end %>
</li>
<% end %>
</ul>
1 change: 1 addition & 0 deletions app/views/admin/pages/_form.html.erb
Expand Up @@ -8,6 +8,7 @@
<%= form_row "Publish On", calendar_date_select_tag('page[publish_at]', Time.now.strftime("%Y-%m-%d %I:%M %P"), :time => true, :minute_interval => 5) %>
<%= form_row "Expires On", calendar_date_select_tag('page[expires_on]', @page.expires_on, :time => true, :minute_interval => 5) %>
<%= form_row "Status", @page.status, :field_options => { :id => 'status' } %>
<%= form_row "Allow Comments", check_box_tag("settings[allow_comments]", "on", @page.settings["allow_comments"] == "on") %>
</table>
<div class="advanced_options">
<% toggle_content_box "Advanced Options" do %>
Expand Down
30 changes: 16 additions & 14 deletions app/views/content/_page.html.erb
@@ -1,16 +1,18 @@
<% if page.page_plugins.any? -%>
<% page.page_plugins.each_with_index do |plugin, i| -%>
<%# render :partial => plugin.module_class.view_partial, :locals => { :plugin_module => plugin.module } -%>
<div class='page-plugin page-plugin-<%= i -%>'>
<%= render :partial => plugin.module.view_partial, :locals => { :plugin_module => plugin.module } -%>
<% if logged_in? && get_setting('show_inline_edit_links') %>
<div class='clear'></div>
<% if current_user.can_author_content? %>
<%= link_to "[Edit]", edit_admin_page_path(:id => page.id, :anchor => "page-plugin-#{plugin.id}") %>
<% elsif current_user.can_approve_content? %>
<%= link_to "[Manage Content]", edit_admin_page_path(:id => page.id, :anchor => "page-plugin-#{plugin.id}") %>
<div class='page <%= page.permalinkable_title %>'>
<% if page.page_plugins.any? -%>
<% page.page_plugins.each_with_index do |plugin, i| -%>
<%# render :partial => plugin.module_class.view_partial, :locals => { :plugin_module => plugin.module } -%>
<div class='page-plugin page-plugin-<%= i -%>'>
<%= render :partial => plugin.module.view_partial, :locals => { :plugin_module => plugin.module } -%>
<% if logged_in? && get_setting('show_inline_edit_links') %>
<div class='clear'></div>
<% if current_user.can_author_content? %>
<%= link_to "[Edit]", edit_admin_page_path(:id => page.id, :anchor => "page-plugin-#{plugin.id}") %>
<% elsif current_user.can_approve_content? %>
<%= link_to "[Manage Content]", edit_admin_page_path(:id => page.id, :anchor => "page-plugin-#{plugin.id}") %>
<% end %>
<% end %>
<% end %>
</div>
</div>
<% end -%>
<% end -%>
<% end -%>
</div>
2 changes: 2 additions & 0 deletions app/views/content/page.html.erb
Expand Up @@ -2,3 +2,5 @@
<h2><%= @page.full_title %></h2>
<% end %>
<%= render :partial => 'content/page', :object => @page %>
<%= show_comments_for(@page) %>
<%= show_comment_form_for(@page, :return_path => @page.ancestor_path) %>
1 change: 1 addition & 0 deletions app/views/layouts/admin.html.erb
Expand Up @@ -19,6 +19,7 @@
<%= stylesheet_link_tag 'form-tables' %>
<%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>
<%= stylesheet_link_tag 'ui.tabs.css' %>
<%= stylesheet_link_tag 'comments' %>
<%= javascript_include_tag 'jquery' -%>
<%= javascript_tag "jQuery.noConflict();" -%>
<%= javascript_include_tag :defaults -%>
Expand Down
14 changes: 14 additions & 0 deletions app/views/shared/_comment.html.erb
@@ -0,0 +1,14 @@
<div class='comment <%= cycle('odd', 'even') -%>'>
<div class='grav'>
<%= content_tag(:div, gravatar_tag(comment.email)) if comment.email %>
</div>
<div class='contents'>
<div class='supplemental'>
<cite><strong><%= comment.website.blank? ? comment.name : link_to(comment.name, comment.website) -%></cite></strong>
said <%= distance_of_time_in_words(Time.now, comment.created_at) %>
</div>
<%= sanitize(comment.comments) %>
</div>
<div class='clear'></div>
</div>
<div class='clear'></div>
13 changes: 13 additions & 0 deletions app/views/shared/_comment_form.html.erb
@@ -0,0 +1,13 @@
<% form_for comment do |f| %>
<h3>Post a Comment</h3>
<table class='subdued'>
<%= f.hidden_field(:commentable_type) %>
<%= f.hidden_field(:commentable_id) %>
<%= hidden_field_tag(:return_path, return_path) %>
<%= form_row "Name:", f.text_field(:name) %>
<%= form_row "Email:", f.text_field(:email) %>
<%= form_row "Website:", f.text_field(:website) %>
<%= form_row "Comments:", f.text_area(:comments) %>
<%= form_row "", submit_tag("Post Comment") %>
</table>
<% end %>
1 change: 1 addition & 0 deletions app/views/shared/_comment_info_link.html.erb
@@ -0,0 +1 @@
<%= link_to pluralize(commentable.comments.count, "comment"), path + "#comments" %>
8 changes: 8 additions & 0 deletions app/views/shared/_comments.html.erb
@@ -0,0 +1,8 @@
<div class='comments' id='comments'>
<% if commentable.comments.any? %>
<h3>Comments</h3>
<% commentable.comments.find(:all, :order => 'created_at DESC').each do |comment| %>
<%= show_comment(comment) %>
<% end %>
<% end %>
</div>
6 changes: 6 additions & 0 deletions app/views/shared/_dashboard_box.html.erb
@@ -0,0 +1,6 @@
<div class='dashboard_box'>
<h3><%= title -%></h3>
<div class='subdued contents'>
<%= yield -%>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/shared/_javascripts.html.erb
@@ -1,4 +1,4 @@
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery', 'jquery.scrollable.js', 'jquery.cycle.all.pack.js', 'fckeditor/fckeditor', 'jquery.jsgal.js', 'jquery.popeye-0.2.1.js' -%>
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery', 'jquery.scrollable.js', 'jquery.cycle.all.pack.js', 'fckeditor/fckeditor', 'jquery.jsgal.js', 'jquery.popeye-0.2.1.js' -%>
<%= javascript_include_tag "jquery.lightbox-0.5.js", "jquery.lightbox.handler.js" %>
<%= javascript_tag "jQuery.noConflict();" -%>
<%= javascript_include_tag 'jqModal', 'jquery.growl.js', 'ansuz/growls', 'jquery.feedreader.js', 'jquery.cycle.all.pack.js' -%>
Expand Down
3 changes: 3 additions & 0 deletions app/views/shared/_render_dashboard_box.html.erb
@@ -0,0 +1,3 @@
<% render :layout => 'shared/dashboard_box', :locals => { :title => dashboard_box[0] } do %>
<%= render :partial => dashboard_box[1] %>
<% end %>
1 change: 1 addition & 0 deletions app/views/shared/_stylesheets.html.erb
Expand Up @@ -6,6 +6,7 @@
<%= stylesheet_link_tag 'jquery.lightbox-0.5.css' %>
<%= stylesheet_link_tag 'jquery.popeye.css' %>
<%= stylesheet_link_tag 'galimg' %>
<%= stylesheet_link_tag 'comments' %>
<style type='text/css'>
<%= get_setting(:custom_css) %>
</style>
23 changes: 23 additions & 0 deletions config/database.yml.bak
@@ -0,0 +1,23 @@
# Linux example follows:
development:
adapter: mysql
database: ansuz_development
username: root
password:
host: localhost
#socket: /tmp/mysql.sock
socket: /var/run/mysqld/mysqld.sock

test:
database: ansuz_test
adapter: mysql
username: root
host: localhost
socket: /var/run/mysqld/mysqld.sock

production:
adapter: mysql
database: ansuz_production
username: root
password:
host: localhost
4 changes: 2 additions & 2 deletions config/environment.rb
Expand Up @@ -10,7 +10,6 @@
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')


# Create log directory if it doesn't exist
unless( File.directory?( File.join(RAILS_ROOT, "log") ) )
STDOUT.puts "Creating log directory.."
Expand Down Expand Up @@ -60,12 +59,13 @@
:source => 'http://gems.github.com'

config.gem 'rubyist-aasm', :version => '~> 2.0.2', :lib => 'aasm', :source => "http://gems.github.com"
config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice', :source => "http://gems.github.com"
config.gem 'mocha'

# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
# :all can be used as a placeholder for all plugins not explicitly named
config.plugins = [ :has_settings, :stringex, :userstamp, :all ]
config.plugins = [ :has_settings, :stringex, :userstamp, :paperclip, :all ]

# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Expand Up @@ -22,4 +22,4 @@
# FIXME: Once that bug is fixed this can all go away. -ja
# It has to be in every environment.
require 'isotope11/active_record_extensions'
require 'ansuz/setup_admin_menu_entries'
require 'ansuz/setup'
2 changes: 1 addition & 1 deletion config/environments/production.rb
Expand Up @@ -31,4 +31,4 @@
# FIXME: Once that bug is fixed this can all go away. -ja
# It has to be in every environment.
require 'isotope11/active_record_extensions'
require 'ansuz/setup_admin_menu_entries'
require 'ansuz/setup'
2 changes: 1 addition & 1 deletion config/environments/test.rb
Expand Up @@ -27,4 +27,4 @@
# FIXME: Once that bug is fixed this can all go away. -ja
# It has to be in every environment.
require 'isotope11/active_record_extensions'
require 'ansuz/setup_admin_menu_entries'
require 'ansuz/setup'
4 changes: 4 additions & 0 deletions config/routes.rb
Expand Up @@ -15,9 +15,12 @@
map.from_plugin :ansuz_twitterati
map.from_plugin :ansuz_database_dumper
map.from_plugin :ansuz_user_system
#map.from_plugin :ansuz_plugin_media_player
map.from_plugin :ansuz_mephisto_xmlrpc

map.resources :tags
map.resources :users
map.resources :comments

# <admin routes>
map.namespace :admin do |admin|
Expand All @@ -28,6 +31,7 @@
admin.resources :tags
admin.resources :roles
admin.resource :account
admin.resource :dashboard
admin.resource :site_settings, :collection => [:choose_theme]
admin.connect 'account/:action/:id', :controller => 'account'
end
Expand Down

0 comments on commit 9f9b5a0

Please sign in to comment.