Skip to content

Commit

Permalink
UI improved, add guide page, editor redesign, admin page added, new f…
Browse files Browse the repository at this point in the history
…eatures
  • Loading branch information
mekhovov committed Oct 14, 2011
1 parent bbfc973 commit 077772a
Show file tree
Hide file tree
Showing 60 changed files with 650 additions and 276 deletions.
10 changes: 7 additions & 3 deletions Gemfile
@@ -1,12 +1,16 @@
source 'http://rubygems.org'

gem 'rails', '3.0.3'
gem 'rails', '3.0.10'

gem 'mysql2', '0.2.6'
#gem 'sqlite3'

gem 'haml'
gem 'devise' # Devise must be required before RailsAdmin
gem 'rails_admin'#, :git => 'http://github.com/sferik/rails_admin.git'
gem 'rails_admin', :git => 'http://github.com/sferik/rails_admin.git', :branch => 'rails-3.0'

gem 'hpricot'
gem "will_paginate", "~> 3.0.pre2"
gem "will_paginate", "> 3.0"
gem 'paperclip'

group :development do
Expand Down
119 changes: 69 additions & 50 deletions Gemfile.lock
@@ -1,86 +1,105 @@
GIT
remote: http://github.com/sferik/rails_admin.git
revision: 1d1622a192786f416b35cc0e9e047806710e4888
branch: rails-3.0
specs:
rails_admin (0.0.1)
builder (~> 2.1.0)
haml (>= 3.1.0, < 3.3.0)
rails (~> 3.0.10)

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
actionmailer (3.0.10)
actionpack (= 3.0.10)
mail (~> 2.2.19)
actionpack (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
activemodel (3.0.10)
activesupport (= 3.0.10)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
i18n (~> 0.5.0)
activerecord (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.9)
bcrypt-ruby (2.1.4)
activeresource (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
activesupport (3.0.10)
arel (2.0.10)
bcrypt-ruby (3.0.1)
builder (2.1.2)
devise (1.3.3)
bcrypt-ruby (~> 2.1.2)
cocaine (0.2.0)
devise (1.4.8)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
erubis (2.6.6)
abstract (>= 1.0.0)
haml (3.1.1)
haml (3.1.3)
hpricot (0.8.4)
i18n (0.5.0)
json (1.6.1)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.16)
mocha (0.9.12)
mocha (0.10.0)
metaclass (~> 0.0.1)
mysql2 (0.2.6)
nifty-generators (0.4.6)
orm_adapter (0.0.4)
paperclip (2.3.11)
orm_adapter (0.0.5)
paperclip (2.4.3)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
polyglot (0.3.1)
rack (1.2.2)
cocaine (>= 0.0.2)
mime-types
polyglot (0.3.2)
rack (1.2.4)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
rails (3.0.10)
actionmailer (= 3.0.10)
actionpack (= 3.0.10)
activerecord (= 3.0.10)
activeresource (= 3.0.10)
activesupport (= 3.0.10)
bundler (~> 1.0)
railties (= 3.0.3)
rails_admin (0.0.0)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
railties (= 3.0.10)
railties (3.0.10)
actionpack (= 3.0.10)
activesupport (= 3.0.10)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.8.7)
rake (0.9.2)
rdoc (3.10)
json (~> 1.4)
thor (0.14.6)
treetop (1.4.9)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.27)
warden (1.0.3)
rack (>= 1.0.0)
will_paginate (3.0.pre2)
tzinfo (0.3.30)
warden (1.0.6)
rack (>= 1.0)
will_paginate (3.0.2)

PLATFORMS
ruby
Expand All @@ -94,6 +113,6 @@ DEPENDENCIES
mysql2 (= 0.2.6)
nifty-generators
paperclip
rails (= 3.0.3)
rails_admin
will_paginate (~> 3.0.pre2)
rails (= 3.0.10)
rails_admin!
will_paginate (> 3.0)
2 changes: 1 addition & 1 deletion README.textile
@@ -1,4 +1,4 @@
h1. YaHoPicaso: Yet Another Pictures Hosting
h1. ImHo: Images Hosting

comming soon..

2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -4,4 +4,4 @@
require File.expand_path('../config/application', __FILE__)
require 'rake'

YaHoPicaso::Application.load_tasks
ImHo::Application.load_tasks
31 changes: 30 additions & 1 deletion app/controllers/attaches_controller.rb
@@ -1,6 +1,35 @@
class AttachesController < ApplicationController


def edit
# render :partial => 'edit'
@edit_photo = Attach.find_by_id(params[:id])
end

def show
redirect_to :controller => :users, :action => :show, :id => Attach.find_by_id(params[:id]).user.id, :photo => params[:id]
end

def raw

edit_photo = Attach.find_by_id(params[:edited_photo][:photo_id])
name = edit_photo.photo_file_name
data = params[:edited_photo][:photo]

@file_content = File.open("#{Rails.root.to_s}/tmp/#{name}", "wb") do |f|
f.write(Base64.decode64(data))
end

if params[:edited_photo][:new_img] == "true"
@image = Attach.new(:photo => File.new("#{Rails.root.to_s}/tmp/#{name}"))
@image.user_id = params[:edited_photo][:user_id]
@image.save
else
edit_photo.update_attributes(:photo => File.new("#{Rails.root.to_s}/tmp/#{name}"))
edit_photo.save
end


File.unlink("#{Rails.root.to_s}/tmp/#{name}")

end
end
18 changes: 15 additions & 3 deletions app/controllers/users_controller.rb
Expand Up @@ -3,8 +3,8 @@ class UsersController < ApplicationController

def index
@top_rated = Attach.all.sort_by {|att| att.likes.count}.reverse.paginate :page => params[:page], :per_page => 6
@new_added = Attach.order('updated_at DESC').limit(6)
@new_comments = Comment.order('updated_at DESC').limit(4)
@new_added = Attach.order('updated_at DESC').limit(12)
@new_comments = Comment.order('updated_at DESC').limit(5)
get_index_view_type
end

Expand All @@ -23,7 +23,14 @@ def create

def show
@user = User.find(params[:id])
@user_photos = @user.attaches.paginate :page => params[:page], :per_page => 9, :order => 'created_at DESC'
if params[:photo]
@user_photos = @user.attaches.all(:conditions => ["id NOT IN (?)", params[:photo]])
@user_photos = @user.attaches.all(:conditions => ["id IN (?)", params[:photo]]) + @user_photos
else
@user_photos = @user.attaches
end
@user_photos = @user_photos.paginate :page => params[:page], :per_page => 9, :order => 'created_at DESC'

@user.attaches.build
get_view_type
end
Expand All @@ -42,4 +49,9 @@ def update
render :action => 'edit'
end
end

def guide
@new_comments = Comment.order('updated_at DESC').limit(5)
render :partial => "guide"
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -39,7 +39,7 @@ def gravatar_url(size = 200)
end

def full_name
name.blank? ? email : name
name.blank? ? email[/^[\w\.]*/] : name
end

end
4 changes: 2 additions & 2 deletions app/views/attaches/_attach.haml
@@ -1,11 +1,11 @@
%span.photo_thumb
= link_to image_tag( attach.photo.url(:thumb), {:alt => attach.photo.url, :id => attach.id}), user_path(attach.user)
= link_to image_tag( attach.photo.url(:thumb), {:alt => attach.photo.url, :id => attach.id}), attach_path(attach.id)
%span.comment-count= attach.comments.count
= form_for Like.new(:attach => attach), :html => {:id => "new_like_#{attach.id}"} do |f|
= f.hidden_field :attach_id
%span.like-count{:class => like_class(attach.id)}= attach.likes.count
%span.user-name
= link_to attach.user.full_name, user_path(attach.user)
= link_to (attach.user.name.blank? ? attach.user.email[/^[\w\.]*/] : attach.user.name), user_path(attach.user)
- if current_user && current_user.id == attach.user.id
%span.photo-edit
%a{:class => "small green awesome", :href => edit_attach_path(attach.id) }
Expand Down
3 changes: 2 additions & 1 deletion app/views/attaches/_images_block.haml
@@ -1,7 +1,8 @@
%article.article_top_photos
%header.title
%h2
= link_to title, root_url
%span
= title
%br/
%br/
.article_content
Expand Down
80 changes: 25 additions & 55 deletions app/views/attaches/edit.haml
@@ -1,63 +1,29 @@
/ Stylesheets
%link{:href => "/stylesheets/editor_common.css", :rel => "stylesheet", :type => "text/css"}/
%link{:href => "/stylesheets/gui.css", :rel => "stylesheet", :type => "text/css"}/

= stylesheet_link_tag "editor_common.css", "gui.css"
/ Libraries
%script{:src => "/libs/jquery.js", :type => "text/javascript"}
%script{:src => "/libs/jquery.ui.js", :type => "text/javascript"}
%script{:src => "/libs/jquery.router.js", :type => "text/javascript"}
%script{:src => "/libs/jquery.shortcuts.js", :type => "text/javascript"}
%script{:src => "/libs/raphael.js", :type => "text/javascript"}
= javascript_include_tag "/libs/jquery.js", "/libs/jquery.ui.js", "/libs/jquery.router.js", "/libs/jquery.shortcuts.js", "/libs/raphael.js "
/ Engine
%script{:src => "/javascripts/icore/tools/brush.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/tools/eraser.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/tools/resize.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/tools/rotate.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/icore_canvas.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/icore_mouse.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/icore_tool.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/icore_file.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/icore_history.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/icore_helper.js", :type => "text/javascript"}
%script{:src => "/javascripts/icore/icore.js", :type => "text/javascript"}
= javascript_include_tag "icore/tools/brush", "icore/tools/eraser", "icore/tools/resize", "icore/tools/rotate", "icore/icore_mouse.js", "icore/icore_canvas", "icore/icore_tool", "icore/icore_file", "icore/icore_history", "icore/icore_helper", "icore/icore"
/ GUI
%script{:src => "/javascripts/gui/controls/window.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/controls/button.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/controls/trackbar.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/controls/textbox.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/controls/colorpicker_a.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/toolbar/button_brush.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/toolbar/button_eraser.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/transformation/button_resize.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/transformation/button_rotate.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/colorpicker/colorpicker.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/file/button_save.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/history/button_undo.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/panel/panel_brush.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/panel/panel_eraser.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/panel/panel_resize.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/panel/panel_rotate.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/gui_canvas.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/gui_toolbar.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/gui_transformation.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/gui_colorpicker.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/gui_file.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/gui_history.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/gui_panel.js", :type => "text/javascript"}
%script{:src => "/javascripts/gui/gui.js", :type => "text/javascript"}
= javascript_include_tag "gui/controls/window", "gui/controls/button", "gui/controls/trackbar", "gui/controls/textbox", "gui/controls/colorpicker_a" , "gui/toolbar/button_brush", "gui/toolbar/button_eraser", "gui/transformation/button_resize", "gui/transformation/button_rotate", "gui/colorpicker/colorpicker"
= javascript_include_tag "gui/file/button_save", "gui/file/button_save_new", "gui/history/button_undo", "gui/panel/panel_brush", "gui/panel/panel_eraser", "gui/panel/panel_resize", "gui/panel/panel_rotate"
= javascript_include_tag "gui/gui_canvas", "gui/gui_toolbar", "gui/gui_transformation", "gui/gui_colorpicker", "gui/gui_file", "gui/gui_history", "gui/gui_panel", "gui/gui"
/ Router
%script{:src => "/javascripts/router.js", :type => "text/javascript"}
= javascript_include_tag "router"

/ Canvas
%section.img_editor
%canvas#canvas{:height => "500", :width => "600"}
/ Toolbars left
%section#toolbar.img_editor{:style => "position: absolute; margin-top: 20px; margin-left: 20px"}
%section#file.img_editor{:style => "position: absolute; margin-top: 80px; margin-left: 20px"}
%section#history.img_editor{:style => "position: absolute; margin-top: 140px; margin-left: 20px"}
%section#transformation.img_editor{:style => "position: absolute; margin-top: 200px; margin-left: 20px"}

/ Toolbars
%section#toolbar.img_editor
%section#transformation.img_editor
%section#colorpicker.img_editor
%section#file.img_editor
%section#history.img_editor
%section#panel.img_editor
/ Toolbars right
%section#colorpicker.img_editor{:style => "position: absolute; margin-top: 20px; margin-left: 960px"}
%section#panel.img_editor{:style => "position: absolute; margin-top: 290px; margin-left: 960px"}

/ Canvas
%section.img_editor{:style => "position: absolute; margin-top: 20px; margin-left: 140px"}
%canvas#canvas{:height => "600", :width => "800"}

/ Constructor
:javascript
Expand All @@ -74,8 +40,12 @@
new ICore();
new GUI();
new Router();
ICore.openImage("#{@edit_photo.photo.url(:original)}");
ICore.openImage("#{@edit_photo.photo.url(:large)}");
}

#photo_id{:style => "display:none"}=@edit_photo.id
#user_id{:style => "display:none"}=@edit_photo.user.id

%section.save_msg{:style => "position: absolute; margin-top: 700px; margin-left: 140px; background:transparent;"}


0 comments on commit 077772a

Please sign in to comment.