Permalink
Browse files

Merge branch 'master' of git://github.com/juafrlo/communityengine int…

…o juafrlo/master

Conflicts:
	CHANGELOG
	about.yml
	app/views/events/edit.html.haml
	app/views/events/new.html.haml
	app/views/photos/index.html.haml
	app/views/photos/new.html.haml
	app/views/photos/show.html.haml
	app/views/shared/_box.html.haml
	test/functional/messages_controller_test.rb
  • Loading branch information...
2 parents ef85c54 + fe06735 commit fb5094f2a72be9d9d5c5b1f17487a0e9e672f1c9 @bborn bborn committed Jul 10, 2009
Showing 1,738 changed files with 1,175 additions and 59 deletions.
View
4 CHANGELOG 100644 → 100755
@@ -6,6 +6,10 @@
* complete private messages integration, allow sending messages to multiple recipients
* upgrades to Event functionality (eksatx)
+= 1.0.3
+* Photo albums
+* Static pages
+
= 1.0.2
* Rails 2.3 compatibility
* RedCloth no longer required
View
0 LICENSE 100644 → 100755
No changes.
View
0 README.markdown 100644 → 100755
No changes.
View
0 Rakefile 100644 → 100755
No changes.
View
0 UPGRADING.markdown 100644 → 100755
No changes.
View
0 about.yml 100644 → 100755
No changes.
View
No changes.
View
No changes.
View
0 app/controllers/ads_controller.rb 100644 → 100755
No changes.
@@ -0,0 +1,110 @@
+class AlbumsController < BaseController
+ include Viewable
+ before_filter :login_required, :except => [:show]
+ before_filter :find_user, :only => [:new, :edit, :index]
+ before_filter :require_current_user, :only => [:new, :edit, :update, :destroy]
+ # GET /albums/1
+ # GET /albums/1.xml
+ def show
+ @album = Album.find(params[:id])
+ update_view_count(@album) if current_user && current_user.id != @album.user_id
+ @album_photos = Photo.find(:all, :page => { :start => 1, :current => params[:page], :size => 8 },
+ :conditions => ['album_id = ? AND parent_id IS NULL', params[:id]])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @album }
+ end
+ end
+
+
+
+ # GET /albums/new
+ # GET /albums/new.xml
+ def new
+ @album = Album.new(params[:album])
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @album }
+ end
+ end
+
+ # GET /albums/1/edit
+ def edit
+ @album = Album.find(params[:id])
+ end
+
+ # POST /albums
+ # POST /albums.xml
+ def create
+ @album = Album.new(params[:album])
+ @album.user_id = current_user.id
+
+ respond_to do |format|
+ if @album.save
+ if params[:go_to] == 'only_create'
+ flash[:notice] = :album_was_successfully_created.l
+ format.html { redirect_to(user_photo_manager_index_path(current_user)) }
+ else
+ format.html { redirect_to(new_user_album_photo_path(current_user,@album)) }
+ end
+ else
+ format.html { render :action => 'new' }
+ end
+ end
+ end
+
+ # PUT /albums/1
+ # PUT /albums/1.xml
+ def update
+ @album = Album.find(params[:id])
+
+ respond_to do |format|
+ if @album.update_attributes(params[:album])
+ flash[:notice] = :album_updated.l
+ format.html { redirect_to(user_album_path(current_user, @album)) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @album.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /albums/1
+ # DELETE /albums/1.xml
+ def destroy
+ @album = Album.find(params[:id])
+ @album.destroy
+
+ respond_to do |format|
+ format.html { redirect_to user_photo_manager_index_path(current_user) }
+ format.xml { head :ok }
+ end
+ end
+
+ def add_photos
+ @album = Album.find(params[:id])
+ #@photos_no_albums = current_user.photos_no_albums
+ #@user_albums = Album.find(:all, :conditions => ['id != ?', params[:id]])
+ end
+
+ def photos_added
+ @album = Album.find(params[:id])
+ @album.photo_ids = params[:album][:photos_ids].uniq
+ redirect_to user_albums_path(current_user)
+ flash[:notice] = :album_added_photos.l
+ end
+
+ def paginate_photos
+ @album = Album.find(params[:id])
+ @page = params[:next_page]
+ album_type = params[:album_type]
+ case album_type
+ when 'no_album'
+ @photos = current_user.photos_no_albums(@page)
+ @next_page = @photos.next_page
+ end
+ end
+end
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
@@ -0,0 +1,13 @@
+class PhotoManagerController < BaseController
+ include Viewable
+ before_filter :login_required
+ before_filter :find_user
+ before_filter :require_current_user
+
+ def index
+ @albums = Album.find(:all, :conditions => ['user_id = ?', current_user], :order => 'id DESC')
+ @photos_no_albums = Photo.find(:all, :page => { :start => 1, :current => params[:page], :size => 9 },
+ :conditions => ['album_id IS NULL AND parent_id IS NULL AND user_id = ?', current_user],
+ :order => 'id DESC')
+ end
+end
View
@@ -70,6 +70,7 @@ def manage_photos
# GET /photos/1.xml
def show
@photo = @user.photos.find(params[:id])
+ update_view_count(@photo) if current_user && current_user.id != @photo.user_id
@is_current_user = @user.eql?(current_user)
@comment = Comment.new(params[:comment])
@@ -103,20 +104,27 @@ def edit
# POST /photos.xml
def create
@user = current_user
-
@photo = Photo.new(params[:photo])
@photo.user = @user
@photo.tag_list = params[:tag_list] || ''
+
+ @photo.album_id = params[:album_id] || ''
+ @photo.album_id = params[:album_selected] unless params[:album_selected].blank?
+
respond_to do |format|
if @photo.save
#start the garbage collector
GC.start
flash[:notice] = :photo_was_successfully_created.l
- format.html {
+ format.html {
render :action => 'inline_new', :layout => false and return if params[:inline]
- redirect_to user_photo_url(:id => @photo, :user_id => @photo.user)
+ if params[:album_id]
+ redirect_to user_album_path(current_user,params[:album_id])
+ else
+ redirect_to user_photo_url(:id => @photo, :user_id => @photo.user)
+ end
}
format.js {
responds_to_parent do
@@ -145,6 +153,8 @@ def swfupload
# swfupload action set in routes.rb
@photo = Photo.new :uploaded_data => params[:Filedata]
@photo.user = current_user
+ @photo.album_id = params[:album_id] if params[:album_id]
+ @photo.album_id = params[:album_selected] unless params[:album_selected].blank?
@photo.save!
# This returns the thumbnail url for handlers.js to use to display the thumbnail
@@ -159,6 +169,7 @@ def update
@photo = Photo.find(params[:id])
@user = @photo.user
@photo.tag_list = params[:tag_list] || ''
+ @photo.album_id = params[:photo][:album_id]
respond_to do |format|
if @photo.update_attributes(params[:photo])
@@ -169,6 +180,7 @@ def update
end
end
+
# DELETE /photos/1
# DELETE /photos/1.xml
def destroy
View
0 app/controllers/post_sweeper.rb 100644 → 100755
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
@@ -0,0 +1,86 @@
+class StaticPagesController < BaseController
+ uses_tiny_mce(:options => AppConfig.default_mce_options, :only => [:new, :edit ])
+ before_filter :admin_required, :except => [:show_web]
+
+ def index
+ @static_pages = StaticPage.all
+ end
+
+ def show
+ @static_page = StaticPage.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @static_page }
+ end
+ end
+
+ def new
+ @static_page = StaticPage.new
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @static_page }
+ end
+ end
+
+ def edit
+ @static_page = StaticPage.find(params[:id])
+ end
+
+ def create
+ @static_page = StaticPage.new(params[:static_page])
+
+ respond_to do |format|
+ if @static_page.save
+ flash[:notice] = 'Static page was successfully created.'
+ format.html { redirect_to(@static_page) }
+ format.xml { render :xml => @static_page, :status => :created, :location => @static_page }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @static_page.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ def update
+ @static_page = StaticPage.find(params[:id])
+
+ respond_to do |format|
+ if @static_page.update_attributes(params[:static_page])
+ flash[:notice] = 'Static page was successfully updated.'
+ format.html { redirect_to(@static_page) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @static_page.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ def destroy
+ @static_page = StaticPage.find(params[:id])
+ @static_page.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(static_pages_url) }
+ format.xml { head :ok }
+ end
+ end
+
+ def show_web
+ @static_page = StaticPage.find_by_url(params[:url])
+ if @static_page.active == false
+ redirect_to ('/')
+ return
+ end
+ case @static_page.visibility
+ when 'Users'
+ login_required
+ return
+ when 'Admin'
+ admin_required
+ return
+ end
+
+ end
+end
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
0 app/controllers/vote_sweeper.rb 100644 → 100755
No changes.
View
No changes.
View
0 app/helpers/ads_helper.rb 100644 → 100755
No changes.
@@ -0,0 +1,2 @@
+module AlbumsHelper
+end
View
0 app/helpers/base_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/categories_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/clippings_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/comments_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/contests_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/forums_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/friendships_helper.rb 100644 → 100755
No changes.
View
No changes.
View
0 app/helpers/invitations_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/metro_areas_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/moderators_helper.rb 100644 → 100755
No changes.
View
No changes.
View
0 app/helpers/offerings_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/photos_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/posts_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/sb_posts_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/sessions_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/sitemap_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/skills_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/statistics_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/tags_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/topics_helper.rb 100644 → 100755
No changes.
View
0 app/helpers/users_helper.rb 100644 → 100755
No changes.
View
0 app/models/ad.rb 100644 → 100755
No changes.
View
@@ -0,0 +1,7 @@
+class Album < ActiveRecord::Base
+ has_many :photos, :dependent => :destroy
+ belongs_to :user
+ validates_presence_of :user_id
+ acts_as_activity :user
+ validates_presence_of :title
+end
View
0 app/models/asset.rb 100644 → 100755
No changes.
View
0 app/models/category.rb 100644 → 100755
No changes.
View
0 app/models/choice.rb 100644 → 100755
No changes.
View
0 app/models/clipping.rb 100644 → 100755
No changes.
View
0 app/models/clipping_image.rb 100644 → 100755
No changes.
View
0 app/models/comment.rb 100644 → 100755
No changes.
View
0 app/models/contest.rb 100644 → 100755
No changes.
View
0 app/models/country.rb 100644 → 100755
No changes.
View
0 app/models/event.rb 100644 → 100755
No changes.
View
0 app/models/favorite.rb 100644 → 100755
No changes.
View
0 app/models/forum.rb 100644 → 100755
No changes.
View
0 app/models/friendship.rb 100644 → 100755
No changes.
View
0 app/models/friendship_status.rb 100644 → 100755
No changes.
View
0 app/models/homepage_feature.rb 100644 → 100755
No changes.
View
0 app/models/invitation.rb 100644 → 100755
No changes.
View
0 app/models/message.rb 100644 → 100755
No changes.
View
0 app/models/metro_area.rb 100644 → 100755
No changes.
View
0 app/models/moderatorship.rb 100644 → 100755
No changes.
View
0 app/models/monitorship.rb 100644 → 100755
No changes.
View
0 app/models/offering.rb 100644 → 100755
No changes.
View
15 app/models/photo.rb 100644 → 100755
@@ -1,5 +1,6 @@
class Photo < ActiveRecord::Base
acts_as_commentable
+ belongs_to :album
has_attachment prepare_options_for_attachment_fu(AppConfig.photo['attachment_fu_options'])
# attr_accessor :cropped_size
@@ -20,8 +21,8 @@ class Photo < ActiveRecord::Base
acts_as_taggable
- acts_as_activity :user, :if => Proc.new{|record| record.parent.nil?}
-
+ acts_as_activity :user, :if => Proc.new{|record| record.parent.nil? && record.album_id.nil?}
+
validates_presence_of :size
validates_presence_of :content_type
validates_presence_of :filename
@@ -60,6 +61,16 @@ def next_photo
self.user.photos.find(:first, :conditions => ['created_at > ?', created_at], :order => 'created_at ASC')
end
+ def previous_in_album
+ return nil unless self.album
+ self.user.photos.find(:first, :conditions => ['created_at < ? and album_id = ?', created_at, self.album.id], :order => 'created_at DESC')
+ end
+ def next_in_album
+ return nil unless self.album
+ self.user.photos.find(:first, :conditions => ['created_at > ? and album_id = ?', created_at, self.album_id], :order => 'created_at ASC')
+ end
+
+
def self.find_recent(options = {:limit => 3})
self.new_this_week.find(:all, :limit => options[:limit])
end
View
0 app/models/poll.rb 100644 → 100755
No changes.
View
0 app/models/post.rb 100644 → 100755
No changes.
View
0 app/models/role.rb 100644 → 100755
No changes.
View
0 app/models/sb_post.rb 100644 → 100755
No changes.
View
0 app/models/skill.rb 100644 → 100755
No changes.
View
0 app/models/state.rb 100644 → 100755
No changes.
@@ -0,0 +1,4 @@
+class StaticPage < ActiveRecord::Base
+ validates_presence_of :url, :visibility
+ validates_uniqueness_of :url
+end
View
0 app/models/tag.rb 100644 → 100755
No changes.
View
0 app/models/topic.rb 100644 → 100755
No changes.
View
2 app/models/user.rb 100644 → 100755
@@ -1,6 +1,8 @@
require 'digest/sha1'
class User < ActiveRecord::Base
+ has_many :albums
+
MALE = 'M'
FEMALE = 'F'
attr_accessor :password
View
0 app/models/user_notifier.rb 100644 → 100755
No changes.
View
0 app/models/user_observer.rb 100644 → 100755
No changes.
View
0 app/models/vote.rb 100644 → 100755
No changes.
View
@@ -14,6 +14,9 @@
- when 'Photo'
=:uploaded_a_photo.l
= link_to image_tag(activity.item.public_filename(:thumb), :width => '50px'), user_photo_path(activity.item.user, activity.item)
+ - when 'Album'
+ =:created_an_album.l
+ = link_to activity.item.title, user_album_path(activity.item.user, activity.item)
- when 'Topic'
=:started_a_topic.l
-topic = activity.item
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
0 app/views/admin/users.html.haml 100644 → 100755
No changes.
View
0 app/views/ads/edit.html.haml 100644 → 100755
No changes.
View
0 app/views/ads/index.html.haml 100644 → 100755
No changes.
View
0 app/views/ads/new.html.haml 100644 → 100755
No changes.
View
0 app/views/ads/show.html.haml 100644 → 100755
No changes.
@@ -0,0 +1,19 @@
+<%= f.error_messages %>
+<p>
+ <%= f.label :title.l %><br />
+ <%= f.text_field :title %>
+</p>
+<p>
+ <%= f.label :description.l %><br />
+ <%= f.text_area :description %>
+</p>
+
+ <%= hidden_field_tag :go_to %>
+<p>
+ <%= f.submit :create_and_add_photos.l %>
+</p>
+
+<p>
+ <%= f.submit :create_album.l, :onclick => "Form.getInputs(this.form, null, 'go_to')[0].value = 'only_create'" %>
+</p>
+
@@ -0,0 +1,5 @@
+<% form_for @album, :url => user_album_path(current_user, @album) do |f| %>
+ <%= render :partial => 'form', :locals => {:f => f} %>
+<% end %>
+
+<%= link_to :back_to_photo_manager.l, user_photo_manager_index_path(@album.user) %>
@@ -0,0 +1,5 @@
+<% form_for @album, :url => user_albums_path(current_user) , :method => :post do |f| %>
+ <%= render :partial => 'form', :locals => {:f => f} %>
+<% end %>
+
+<%= link_to :back_to_photo_manager.l, user_photo_manager_index_path(@album.user) %>
Oops, something went wrong.

0 comments on commit fb5094f

Please sign in to comment.