go-picasa-go 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +135 -0
- data/Rakefile +16 -0
- data/TODO +10 -0
- data/VERSION +1 -0
- data/bin/go-picasa-go +64 -0
- data/examples/rails-example/README +243 -0
- data/examples/rails-example/Rakefile +10 -0
- data/examples/rails-example/app/controllers/albums_controller.rb +62 -0
- data/examples/rails-example/app/controllers/application_controller.rb +10 -0
- data/examples/rails-example/app/controllers/photos_controller.rb +77 -0
- data/examples/rails-example/app/helpers/albums_helper.rb +9 -0
- data/examples/rails-example/app/helpers/application_helper.rb +3 -0
- data/examples/rails-example/app/models/my_user.rb +9 -0
- data/examples/rails-example/app/views/albums/_form.html.erb +15 -0
- data/examples/rails-example/app/views/albums/edit.html.erb +10 -0
- data/examples/rails-example/app/views/albums/index.html.erb +50 -0
- data/examples/rails-example/app/views/albums/new.html.erb +10 -0
- data/examples/rails-example/app/views/photos/index.html.erb +30 -0
- data/examples/rails-example/app/views/photos/new.html.erb +8 -0
- data/examples/rails-example/app/views/photos/show.html.erb +19 -0
- data/examples/rails-example/config/boot.rb +110 -0
- data/examples/rails-example/config/database.yml +22 -0
- data/examples/rails-example/config/environment.rb +42 -0
- data/examples/rails-example/config/environments/development.rb +17 -0
- data/examples/rails-example/config/environments/production.rb +28 -0
- data/examples/rails-example/config/environments/test.rb +28 -0
- data/examples/rails-example/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/rails-example/config/initializers/inflections.rb +10 -0
- data/examples/rails-example/config/initializers/mime_types.rb +5 -0
- data/examples/rails-example/config/initializers/new_rails_defaults.rb +21 -0
- data/examples/rails-example/config/initializers/session_store.rb +15 -0
- data/examples/rails-example/config/locales/en.yml +5 -0
- data/examples/rails-example/config/routes.rb +49 -0
- data/examples/rails-example/db/seeds.rb +7 -0
- data/examples/rails-example/doc/README_FOR_APP +2 -0
- data/examples/rails-example/log/development.log +6923 -0
- data/examples/rails-example/log/production.log +0 -0
- data/examples/rails-example/log/server.log +0 -0
- data/examples/rails-example/log/test.log +0 -0
- data/examples/rails-example/public/404.html +30 -0
- data/examples/rails-example/public/422.html +30 -0
- data/examples/rails-example/public/500.html +30 -0
- data/examples/rails-example/public/favicon.ico +0 -0
- data/examples/rails-example/public/images/rails.png +0 -0
- data/examples/rails-example/public/index.html +275 -0
- data/examples/rails-example/public/javascripts/application.js +2 -0
- data/examples/rails-example/public/javascripts/controls.js +963 -0
- data/examples/rails-example/public/javascripts/dragdrop.js +973 -0
- data/examples/rails-example/public/javascripts/effects.js +1128 -0
- data/examples/rails-example/public/javascripts/prototype.js +4320 -0
- data/examples/rails-example/public/robots.txt +5 -0
- data/examples/rails-example/script/about +4 -0
- data/examples/rails-example/script/console +3 -0
- data/examples/rails-example/script/dbconsole +3 -0
- data/examples/rails-example/script/destroy +3 -0
- data/examples/rails-example/script/generate +3 -0
- data/examples/rails-example/script/performance/benchmarker +3 -0
- data/examples/rails-example/script/performance/profiler +3 -0
- data/examples/rails-example/script/plugin +3 -0
- data/examples/rails-example/script/runner +3 -0
- data/examples/rails-example/script/server +3 -0
- data/examples/rails-example/test/functional/albums_controller_test.rb +8 -0
- data/examples/rails-example/test/performance/browsing_test.rb +9 -0
- data/examples/rails-example/test/test_helper.rb +38 -0
- data/examples/rails-example/test/unit/helpers/albums_helper_test.rb +4 -0
- data/go_picasa_go.gemspec +184 -0
- data/init.rb +1 -0
- data/lib/generators/authentication_token_generator.rb +12 -0
- data/lib/generators/template/user_class.erb +9 -0
- data/lib/generators/user_class_generator.rb +50 -0
- data/lib/go_picasa_go.rb +26 -0
- data/lib/patchs/object.rb +21 -0
- data/lib/patchs/ssl.rb +9 -0
- data/lib/picasa/album.rb +267 -0
- data/lib/picasa/authentication.rb +19 -0
- data/lib/picasa/default_album.rb +9 -0
- data/lib/picasa/default_photo.rb +6 -0
- data/lib/picasa/default_user.rb +6 -0
- data/lib/picasa/http/album.rb +113 -0
- data/lib/picasa/http/authentication.rb +40 -0
- data/lib/picasa/http/photo.rb +117 -0
- data/lib/picasa/missing.rb +22 -0
- data/lib/picasa/photo.rb +190 -0
- data/lib/picasa/template/album.xml.erb +20 -0
- data/lib/picasa/template/photo.erb +15 -0
- data/lib/picasa/user.rb +57 -0
- data/lib/picasa/util.rb +33 -0
- data/script.rb +46 -0
- data/spec/album_spec.rb +245 -0
- data/spec/authentication_spec.rb +19 -0
- data/spec/default_classes_spec.rb +50 -0
- data/spec/fixture/photo.jpg +0 -0
- data/spec/fixture/photo2.jpg +0 -0
- data/spec/generators/user_class_generator_spec.rb +40 -0
- data/spec/http/album_spec.rb +129 -0
- data/spec/http/authentication_spec.rb +15 -0
- data/spec/http/photo_spec.rb +78 -0
- data/spec/http_response_helper.rb +23 -0
- data/spec/mock_helper.rb +113 -0
- data/spec/photo_spec.rb +201 -0
- data/spec/spec_helper.rb +151 -0
- data/spec/suites/all.rb +14 -0
- data/spec/suites/all_mocked.rb +5 -0
- data/spec/user_spec.rb +74 -0
- metadata +222 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
|
10
|
+
require 'tasks/rails'
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class AlbumsController < ApplicationController
|
2
|
+
|
3
|
+
def index
|
4
|
+
@user = MyUser.new
|
5
|
+
@albums = @user.albums
|
6
|
+
end
|
7
|
+
|
8
|
+
def new
|
9
|
+
@album = Picasa::DefaultAlbum.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
@album = Picasa::DefaultAlbum.new
|
14
|
+
@album.user = MyUser.new
|
15
|
+
@album.title = params[:album][:title]
|
16
|
+
@album.summary = params[:album][:summary]
|
17
|
+
@album.location = params[:album][:location]
|
18
|
+
@album.access = params[:album][:access]
|
19
|
+
|
20
|
+
begin
|
21
|
+
@album.picasa_save!
|
22
|
+
flash[:notice] = "Album created succefully!"
|
23
|
+
rescue Exception => e
|
24
|
+
flash[:error] = "Error while saving the album."
|
25
|
+
render :action => :new
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
redirect_to :action => :new
|
30
|
+
end
|
31
|
+
|
32
|
+
def edit
|
33
|
+
@user = MyUser.new
|
34
|
+
@album = @user.find_album params[:id]
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
@user = MyUser.new
|
39
|
+
@album = @user.find_album params[:id]
|
40
|
+
|
41
|
+
begin
|
42
|
+
@album.picasa_update_attributes! params[:album]
|
43
|
+
flash[:notice] = "Album updated succefully!"
|
44
|
+
rescue Exception => e
|
45
|
+
puts e.inspect
|
46
|
+
flash[:error] = "Error while updating the album."
|
47
|
+
render :action => :edit
|
48
|
+
return
|
49
|
+
end
|
50
|
+
|
51
|
+
redirect_to :action => :edit, :id => @album.picasa_id
|
52
|
+
end
|
53
|
+
|
54
|
+
def destroy
|
55
|
+
@user = MyUser.new
|
56
|
+
@album = @user.find_album params[:id]
|
57
|
+
@album.destroy!
|
58
|
+
|
59
|
+
redirect_to :action => :index
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
+
|
8
|
+
# Scrub sensitive parameters from your log
|
9
|
+
# filter_parameter_logging :password
|
10
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class PhotosController < ApplicationController
|
2
|
+
|
3
|
+
def index
|
4
|
+
@user = MyUser.new
|
5
|
+
@album = @user.find_album params[:album_id]
|
6
|
+
@photos = @album.photos
|
7
|
+
end
|
8
|
+
|
9
|
+
def new
|
10
|
+
@user = MyUser.new
|
11
|
+
@album = @user.find_album params[:album_id]
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
file = params[:photo][:file]
|
16
|
+
|
17
|
+
file_name = File.dirname(file.path)+"/#{file.original_filename}"
|
18
|
+
|
19
|
+
photo_file = File.new file_name, 'w+'
|
20
|
+
photo_file.write file.readlines
|
21
|
+
photo_file.close
|
22
|
+
|
23
|
+
@album = MyUser.new.find_album params[:album_id]
|
24
|
+
|
25
|
+
@photo = Picasa::DefaultPhoto.new
|
26
|
+
@photo.album = @album
|
27
|
+
@photo.file = photo_file
|
28
|
+
|
29
|
+
begin
|
30
|
+
@photo.save!
|
31
|
+
rescue
|
32
|
+
flash[:error] = "Error while trying to save the photo."
|
33
|
+
render :template => :new
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
37
|
+
flash[:notice] = "The photo was uploaded succefully!"
|
38
|
+
redirect_to album_photos_path(params[:album_id])
|
39
|
+
end
|
40
|
+
|
41
|
+
def update
|
42
|
+
@album = MyUser.new.find_album params[:album_id]
|
43
|
+
@photo = @album.find_photo params[:id]
|
44
|
+
@photo.description = params[:photo][:description]
|
45
|
+
|
46
|
+
begin
|
47
|
+
@photo.picasa_update!
|
48
|
+
rescue Exception => e
|
49
|
+
puts e.inspect
|
50
|
+
flash[:error] = "Error while trying to update the photo."
|
51
|
+
render :action => :new
|
52
|
+
puts "Deu pau!"
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
puts "Vamos lá!"
|
57
|
+
redirect_to album_photo_path(params[:album_id], params[:id])
|
58
|
+
end
|
59
|
+
|
60
|
+
def show
|
61
|
+
@user = MyUser.new
|
62
|
+
@album = @user.find_album params[:album_id]
|
63
|
+
@photo = @album.find_photo params[:id]
|
64
|
+
puts @photo.inspect
|
65
|
+
end
|
66
|
+
|
67
|
+
def destroy
|
68
|
+
@user = MyUser.new
|
69
|
+
@album = @user.find_album params[:album_id]
|
70
|
+
@foto = @album.find_photo params[:id]
|
71
|
+
@foto.destroy!
|
72
|
+
|
73
|
+
flash[:notice] = "Photo delete succefully!"
|
74
|
+
redirect_to album_photos_path(@album.picasa_id)
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class MyUser < Picasa::DefaultUser
|
2
|
+
def picasa_id
|
3
|
+
"bandmanagertest"
|
4
|
+
end
|
5
|
+
|
6
|
+
def auth_token
|
7
|
+
"DQAAAHkAAACUuZqOizFjdLoq_Z6i7WnLNN51mNxj46S_CnBkDGEK_NzxcfWVS3iFSaIUv7pLSNxIj0BHRh8Azs2lbxwxmD8C3-wGzT4uT_dUzAr0db9qqXxyZMw3MP05XGiuNXPm7jufB1UL-rsaWECqLnHh8AKX37xN1etPyh0cQs_COTvyfQ"
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Title:<br/>
|
2
|
+
<%= text_field_tag 'album[title]', @album.title %><br/>
|
3
|
+
|
4
|
+
Summary:<br/>
|
5
|
+
<%= text_field_tag 'album[summary]', @album.summary %><br/>
|
6
|
+
|
7
|
+
Location:<br/>
|
8
|
+
<%= text_field_tag 'album[location]', @album.location %><br/>
|
9
|
+
|
10
|
+
Access:<br/>
|
11
|
+
<%= select_tag 'album[access]', options_for_select(access_options, @album.access) %><br/>
|
12
|
+
|
13
|
+
|
14
|
+
<br/>
|
15
|
+
<%= submit_tag 'Salvar' %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= flash[:notice] %>
|
2
|
+
<%= flash[:error] %>
|
3
|
+
|
4
|
+
<h1>Edit album</h1>
|
5
|
+
|
6
|
+
<% form_tag :controller => :albums, :action => :update, :id => @album.picasa_id do %>
|
7
|
+
<%= render :partial => 'form' %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<%= link_to 'Back', :controller => :albums, :action => :index %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<p>
|
2
|
+
<%= link_to 'New album', :controller => :albums, :action => :new %>
|
3
|
+
</p>
|
4
|
+
|
5
|
+
<% if @albums and @albums.size > 0 %>
|
6
|
+
<table>
|
7
|
+
<tr>
|
8
|
+
<th>
|
9
|
+
Title
|
10
|
+
</th>
|
11
|
+
<th>
|
12
|
+
Summary
|
13
|
+
</th>
|
14
|
+
<th>
|
15
|
+
Location
|
16
|
+
</th>
|
17
|
+
<th>
|
18
|
+
Access
|
19
|
+
</th>
|
20
|
+
<th>
|
21
|
+
</th>
|
22
|
+
<th>
|
23
|
+
</th>
|
24
|
+
</tr>
|
25
|
+
<% @albums.each do |album| %>
|
26
|
+
<tr>
|
27
|
+
<td>
|
28
|
+
<%= link_to album.title, album_photos_path(album.picasa_id) %>
|
29
|
+
</td>
|
30
|
+
<td>
|
31
|
+
<%= album.summary %>
|
32
|
+
</td>
|
33
|
+
<td>
|
34
|
+
<%= album.location %>
|
35
|
+
</td>
|
36
|
+
<td>
|
37
|
+
<%= album.access %>
|
38
|
+
</td>
|
39
|
+
<td>
|
40
|
+
<%= link_to 'Edit', edit_album_path(album.picasa_id) %>
|
41
|
+
</td>
|
42
|
+
<td>
|
43
|
+
<%= link_to 'Destroy', album_path(album.picasa_id), :method => :delete, :confirm => 'Are you sure?' %>
|
44
|
+
</td>
|
45
|
+
</tr>
|
46
|
+
<% end%>
|
47
|
+
</table>
|
48
|
+
<% else %>
|
49
|
+
<em>No albums found.</em>
|
50
|
+
<% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<div>
|
2
|
+
<%= flash[:notice] %>
|
3
|
+
<%= flash[:error] %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div>
|
7
|
+
<%= link_to 'Upload new photo', new_album_photo_path(@album.picasa_id) %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<% if @photos and @photos.size > 0 %>
|
11
|
+
<% @photos.each_with_index do |photo, index| %>
|
12
|
+
<div style="text-align: center; float: left; height: 120px; width: 120px; background: #CCCCCC; margin: 5px; padding: 5px;">
|
13
|
+
<div style="height: 80px;">
|
14
|
+
<%= link_to image_tag(photo.media_thumbnail_url1),
|
15
|
+
album_photo_path(photo.album.picasa_id, photo.picasa_id)
|
16
|
+
%>
|
17
|
+
<br/>
|
18
|
+
</div>
|
19
|
+
<%= link_to photo.media_title, album_photo_path(photo.album.picasa_id, photo.picasa_id) %>
|
20
|
+
|
21
|
+
</br>
|
22
|
+
|
23
|
+
<%= link_to 'Delete', album_photo_path(photo.album.picasa_id, photo.picasa_id),
|
24
|
+
:method => :delete, :confirm => 'Are you sure?'
|
25
|
+
%>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
<% else %>
|
29
|
+
<em>No photos found on this album.</em>
|
30
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div>
|
2
|
+
<%= flash[:notice] %>
|
3
|
+
<%= flash[:notice] %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div style="text-align: center;">
|
7
|
+
<%= image_tag @photo.media_thumbnail_url3 %><br/>
|
8
|
+
<%= @photo.description %>
|
9
|
+
<% form_tag album_photo_path(@album.picasa_id, @photo.picasa_id), :method => :put do %>
|
10
|
+
<%= hidden_field_tag 'album_id', @album.picasa_id %>
|
11
|
+
<%= hidden_field_tag 'id', @photo.picasa_id %>
|
12
|
+
<%= text_field_tag 'photo[description]', @photo.description %>
|
13
|
+
|
14
|
+
<br/><br/>
|
15
|
+
<%= submit_tag 'Save' %>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
def preinitialize
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitializer_path
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
Rails::Initializer.run(:set_load_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class VendorBoot < Boot
|
44
|
+
def load_initializer
|
45
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
+
Rails::GemDependency.add_frozen_gem_path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class GemBoot < Boot
|
52
|
+
def load_initializer
|
53
|
+
self.class.load_rubygems
|
54
|
+
load_rails_gem
|
55
|
+
require 'initializer'
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_rails_gem
|
59
|
+
if version = self.class.gem_version
|
60
|
+
gem 'rails', version
|
61
|
+
else
|
62
|
+
gem 'rails'
|
63
|
+
end
|
64
|
+
rescue Gem::LoadError => load_error
|
65
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
|
69
|
+
class << self
|
70
|
+
def rubygems_version
|
71
|
+
Gem::RubyGemsVersion rescue nil
|
72
|
+
end
|
73
|
+
|
74
|
+
def gem_version
|
75
|
+
if defined? RAILS_GEM_VERSION
|
76
|
+
RAILS_GEM_VERSION
|
77
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
78
|
+
ENV['RAILS_GEM_VERSION']
|
79
|
+
else
|
80
|
+
parse_gem_version(read_environment_rb)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def load_rubygems
|
85
|
+
min_version = '1.3.2'
|
86
|
+
require 'rubygems'
|
87
|
+
unless rubygems_version >= min_version
|
88
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
89
|
+
exit 1
|
90
|
+
end
|
91
|
+
|
92
|
+
rescue LoadError
|
93
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_gem_version(text)
|
98
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
def read_environment_rb
|
103
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# All that for this:
|
110
|
+
Rails.boot!
|