multistockphoto 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +33 -0
- data/PostInstall.txt +7 -0
- data/README.txt +48 -0
- data/Rakefile +4 -0
- data/bin/multistockphoto +69 -0
- data/config/hoe.rb +75 -0
- data/config/requirements.rb +15 -0
- data/config.yaml +9 -0
- data/lib/multistockphoto/generic_site.rb +9 -0
- data/lib/multistockphoto/multistockphoto.rb +7 -0
- data/lib/multistockphoto/photo.rb +7 -0
- data/lib/multistockphoto/site_aldi.rb +82 -0
- data/lib/multistockphoto/site_fotolia.rb +58 -0
- data/lib/multistockphoto/site_zoonar.rb +86 -0
- data/lib/multistockphoto/version.rb +9 -0
- data/lib/multistockphoto.rb +15 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +6 -0
- data/test/test_multistockphoto.rb +177 -0
- data/website/index.html +257 -0
- data/website/index.txt +188 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +100 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 FIXME full name
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
config.yaml
|
8
|
+
bin/multistockphoto
|
9
|
+
config/hoe.rb
|
10
|
+
config/requirements.rb
|
11
|
+
lib/multistockphoto.rb
|
12
|
+
lib/multistockphoto/multistockphoto.rb
|
13
|
+
lib/multistockphoto/version.rb
|
14
|
+
lib/multistockphoto/generic_site.rb
|
15
|
+
lib/multistockphoto/site_fotolia.rb
|
16
|
+
lib/multistockphoto/site_zoonar.rb
|
17
|
+
lib/multistockphoto/site_aldi.rb
|
18
|
+
lib/multistockphoto/photo.rb
|
19
|
+
script/console
|
20
|
+
script/destroy
|
21
|
+
script/generate
|
22
|
+
script/txt2html
|
23
|
+
setup.rb
|
24
|
+
tasks/deployment.rake
|
25
|
+
tasks/environment.rake
|
26
|
+
tasks/website.rake
|
27
|
+
test/test_helper.rb
|
28
|
+
test/test_multistockphoto.rb
|
29
|
+
website/index.html
|
30
|
+
website/index.txt
|
31
|
+
website/javascripts/rounded_corners_lite.inc.js
|
32
|
+
website/stylesheets/screen.css
|
33
|
+
website/template.html.erb
|
data/PostInstall.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= multistockphoto
|
2
|
+
|
3
|
+
* FIX (url)
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIX (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIX (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIX (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIX (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIX (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2008 FIX
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/multistockphoto
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'choice'
|
5
|
+
require 'multistockphoto'
|
6
|
+
|
7
|
+
version = Multistockphoto::VERSION::STRING
|
8
|
+
Choice.options do
|
9
|
+
header ''
|
10
|
+
header 'Specific options:'
|
11
|
+
#...
|
12
|
+
separator ''
|
13
|
+
separator 'Common options: '
|
14
|
+
|
15
|
+
option :help do
|
16
|
+
short '-h'
|
17
|
+
long '--help'
|
18
|
+
desc 'Show this message'
|
19
|
+
end
|
20
|
+
|
21
|
+
option :version do
|
22
|
+
short '-v'
|
23
|
+
long '--version'
|
24
|
+
desc 'Show version'
|
25
|
+
action do
|
26
|
+
puts "multistockphoto #{version}"
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
option :send_all do
|
32
|
+
short '-sa'
|
33
|
+
long '--send-all'
|
34
|
+
desc 'Send all files'
|
35
|
+
action do
|
36
|
+
$send_all=true
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def send_all
|
43
|
+
puts 'sending all unsent photos'
|
44
|
+
Dir.glob('upload/*').each {|filename|
|
45
|
+
if filename.upcase =~ /.PNG|.JPG|.GIF|.JPEG/
|
46
|
+
#puts filename
|
47
|
+
# Fotolia
|
48
|
+
site = Fotolia.new("Fotolia")
|
49
|
+
photo = Photo.new(filename)
|
50
|
+
begin
|
51
|
+
site.transfer(photo)
|
52
|
+
rescue Net::FTPTempError
|
53
|
+
puts "FTP-Fehler beim Senden an Fotolia aufgetreten. Ggf. Konfiguration ueberpruefen oder spaeter erneut vesuchen"
|
54
|
+
end
|
55
|
+
# Zoonar
|
56
|
+
site = Zoonar.new("Zoonar")
|
57
|
+
photo = Photo.new(filename)
|
58
|
+
begin
|
59
|
+
site.transfer(photo)
|
60
|
+
rescue
|
61
|
+
puts "Fehler beim Senden an Zoonar aufgetreten"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
if $send_all
|
68
|
+
send_all
|
69
|
+
end
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'multistockphoto/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Thomas Preymesser' # can also be an array of Authors
|
4
|
+
EMAIL = "thopre@gmail.com"
|
5
|
+
DESCRIPTION = "Upload your photos to multiple stock phote sites"
|
6
|
+
GEM_NAME = 'multistockphoto' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'multistockphoto' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
# ['activesupport', '>= 1.3.1']
|
12
|
+
['mechanize', '>= 0.7.5'], # mein aktuelles release
|
13
|
+
['choice', '>= 0.1.2'], # mein aktuelles release
|
14
|
+
] # An array of rubygem dependencies [name, version]
|
15
|
+
|
16
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
17
|
+
@config = nil
|
18
|
+
RUBYFORGE_USERNAME = "unknown"
|
19
|
+
def rubyforge_username
|
20
|
+
unless @config
|
21
|
+
begin
|
22
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
23
|
+
rescue
|
24
|
+
puts <<-EOS
|
25
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
26
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
27
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
28
|
+
EOS
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
REV = nil
|
37
|
+
# UNCOMMENT IF REQUIRED:
|
38
|
+
# REV = YAML.load(`svn info`)['Revision']
|
39
|
+
VERS = Multistockphoto::VERSION::STRING + (REV ? ".#{REV}" : "")
|
40
|
+
RDOC_OPTS = ['--quiet', '--title', 'multistockphoto documentation',
|
41
|
+
"--opname", "index.html",
|
42
|
+
"--line-numbers",
|
43
|
+
"--main", "README",
|
44
|
+
"--inline-source"]
|
45
|
+
|
46
|
+
class Hoe
|
47
|
+
def extra_deps
|
48
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
49
|
+
@extra_deps
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Generate all the Rake tasks
|
54
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
55
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
56
|
+
p.developer(AUTHOR, EMAIL)
|
57
|
+
p.description = DESCRIPTION
|
58
|
+
p.summary = DESCRIPTION
|
59
|
+
p.url = HOMEPATH
|
60
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
61
|
+
p.test_globs = ["test/**/test_*.rb"]
|
62
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
63
|
+
|
64
|
+
# == Optional
|
65
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
66
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
67
|
+
|
68
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
69
|
+
end
|
70
|
+
|
71
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
72
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
73
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
74
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
75
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/config.yaml
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
class Aldi < GenericSite
|
2
|
+
|
3
|
+
def initialize(name)
|
4
|
+
p "creating an ALDI object"
|
5
|
+
super
|
6
|
+
if ENV['MSP_CONFIG']
|
7
|
+
@config = YAML.load_file(ENV['MSP_CONFIG'])
|
8
|
+
p "meine config: #{ENV['MSP_CONFIG']}"
|
9
|
+
else
|
10
|
+
p "standard config"
|
11
|
+
@config = YAML.load_file("config.yaml")
|
12
|
+
end
|
13
|
+
@user = @config[:aldi][:user]
|
14
|
+
@password = @config[:aldi][:password]
|
15
|
+
# kann vom Client ueberschrieben werden
|
16
|
+
end
|
17
|
+
|
18
|
+
def transfer(photo)
|
19
|
+
# falls nicht in config Datei eingetragen dann nicht senden
|
20
|
+
if @user == nil or @password == nil
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
unless photo.class == Photo
|
25
|
+
raise 'not a Photo object'
|
26
|
+
end
|
27
|
+
unless File.exist?(photo.filename)
|
28
|
+
raise "file #{photo.filename} does not exist"
|
29
|
+
end
|
30
|
+
puts "zoonar:#{photo.filename}"
|
31
|
+
g = `grep "zoonar\t#{photo.filename}" sendeliste.dat`
|
32
|
+
if g.size > 0
|
33
|
+
#puts "INFO: already sent to zoonar"
|
34
|
+
return :duplicate
|
35
|
+
end
|
36
|
+
|
37
|
+
agent = WWW::Mechanize.new
|
38
|
+
agent.user_agent_alias = 'Linux Mozilla'
|
39
|
+
page = agent.get 'https://shop.aldi-fotoservice-druck.de/shop/viewLoginForm.do'
|
40
|
+
|
41
|
+
if page.body.include?('Login/Neuanmeldung')
|
42
|
+
p 'bin auf Login-Seite'
|
43
|
+
end
|
44
|
+
form = page.forms.first #TODO: besser nach Name
|
45
|
+
form.username = @config[:aldi][:user]
|
46
|
+
form.password = @config[:aldi][:password]
|
47
|
+
p form.username
|
48
|
+
p form.password
|
49
|
+
page = agent.submit form
|
50
|
+
if page.body.include?('Ihre Benutzerdaten')
|
51
|
+
p 'bin auf Benutzerdaten-Seite'
|
52
|
+
else
|
53
|
+
html_out(page.body,'out.html')
|
54
|
+
end
|
55
|
+
page = agent.click page.links.text('zum Direkt-Upload')
|
56
|
+
# if page.body.include?('Ihr Warenkorb ist leer.')
|
57
|
+
# p 'bin beim leeren Warenkorb'
|
58
|
+
# end
|
59
|
+
# # page = agent.get('https://shop.aldi-fotoservice-druck.de/shop/viewUploadForm.do')
|
60
|
+
# page = agent.click page.links.text(/viewUploadForm/)
|
61
|
+
if page.body.include?('Bilddateien und Zip-Archive einzeln hochladen')
|
62
|
+
p 'bin auf Upload-Seite'
|
63
|
+
end
|
64
|
+
form = page.forms.first #TODO: besser nach Name
|
65
|
+
pp form
|
66
|
+
#form.file_1 = photo.filename
|
67
|
+
pp form.file_uploads.name('file_1').first
|
68
|
+
form.file_uploads.name('file_1').first.file_name = photo.filename
|
69
|
+
pp form.file_uploads.name('file_1').first
|
70
|
+
#pp form
|
71
|
+
##TODO: derzeit sind in diesem Formular bis zu 5 Photos gleichzeitig moeglich
|
72
|
+
page = agent.submit form
|
73
|
+
if page.body.include?('Ihr Auftrag')
|
74
|
+
p "bin auf Auftrag-Anzeigeseite"
|
75
|
+
html_out(page.body,'out.html')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def html_out(body,html_file)
|
80
|
+
File.open(html_file,"w") {|f| f.print body}
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'net/ftp'
|
2
|
+
|
3
|
+
class Fotolia < GenericSite
|
4
|
+
|
5
|
+
attr_accessor :ftp_user, :ftp_password
|
6
|
+
|
7
|
+
FTP_HOST = 'submit.fotolia.com'
|
8
|
+
|
9
|
+
def initialize(name)
|
10
|
+
#p "creating a Fotolia object"
|
11
|
+
super
|
12
|
+
if ENV['MSP_CONFIG']
|
13
|
+
@config = YAML.load_file(ENV['MSP_CONFIG'])
|
14
|
+
#p "meine config: #{ENV['MSP_CONFIG']}"
|
15
|
+
else
|
16
|
+
#p "standard config"
|
17
|
+
@config = YAML.load_file("config.yaml")
|
18
|
+
end
|
19
|
+
@user = @config[:fotolia][:user]
|
20
|
+
@password = @config[:fotolia][:password]
|
21
|
+
@ftp_user = @config[:fotolia][:ftp_user]
|
22
|
+
@ftp_password = @config[:fotolia][:ftp_password]
|
23
|
+
# kann vom Client ueberschrieben werden
|
24
|
+
end
|
25
|
+
|
26
|
+
def transfer(photo)
|
27
|
+
# falls nicht in config Datei eingetragen dann nicht senden
|
28
|
+
if @user == nil or @password == nil
|
29
|
+
return
|
30
|
+
end
|
31
|
+
unless photo.class == Photo
|
32
|
+
raise 'not a Photo object'
|
33
|
+
end
|
34
|
+
unless File.exist?(photo.filename)
|
35
|
+
raise "file #{photo.filename} does not exist"
|
36
|
+
end
|
37
|
+
if @ftp_user == nil or @ftp_password == nil
|
38
|
+
raise "ftp_user/ftp_password not set"
|
39
|
+
end
|
40
|
+
print "fotolia:#{photo.filename} ... "
|
41
|
+
$stdout.flush
|
42
|
+
g = `grep "fotolia\t#{photo.filename}" sendeliste.dat`
|
43
|
+
if g.size > 0
|
44
|
+
puts "already sent"
|
45
|
+
return :duplicate
|
46
|
+
end
|
47
|
+
ftp = Net::FTP.new(FTP_HOST)
|
48
|
+
ftp.login(@ftp_user,@ftp_password)
|
49
|
+
files=ftp.list('*')
|
50
|
+
res = ftp.putbinaryfile(photo.filename)
|
51
|
+
files=ftp.list('*')
|
52
|
+
#p files
|
53
|
+
ftp.close
|
54
|
+
puts 'OK'
|
55
|
+
`echo "fotolia\t#{photo.filename}\t#{Time.now}" >>sendeliste.dat` #TODO:
|
56
|
+
true
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mechanize'
|
3
|
+
|
4
|
+
class Zoonar < GenericSite
|
5
|
+
|
6
|
+
attr_accessor :user, :password
|
7
|
+
|
8
|
+
def initialize(name)
|
9
|
+
super
|
10
|
+
if ENV['MSP_CONFIG']
|
11
|
+
@config = YAML.load_file(ENV['MSP_CONFIG'])
|
12
|
+
else
|
13
|
+
@config = YAML.load_file("config.yaml")
|
14
|
+
end
|
15
|
+
@user = @config[:zoonar][:user]
|
16
|
+
@password = @config[:zoonar][:password]
|
17
|
+
end
|
18
|
+
|
19
|
+
def transfer(photo)
|
20
|
+
# falls nicht in config Datei eingetragen dann nicht senden
|
21
|
+
if @user == nil or @password == nil
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
unless photo.class == Photo
|
26
|
+
raise 'not a Photo object'
|
27
|
+
end
|
28
|
+
unless File.exist?(photo.filename)
|
29
|
+
raise "file #{photo.filename} does not exist"
|
30
|
+
end
|
31
|
+
print "zoonar:#{photo.filename} ... "
|
32
|
+
$stdout.flush
|
33
|
+
g = `grep "zoonar\t#{photo.filename}" sendeliste.dat`
|
34
|
+
if g.size > 0
|
35
|
+
puts 'already sent'
|
36
|
+
return :duplicate
|
37
|
+
end
|
38
|
+
agent = WWW::Mechanize.new
|
39
|
+
agent.user_agent_alias = 'Linux Mozilla'
|
40
|
+
page = agent.get 'http://www.zoonar.de'
|
41
|
+
|
42
|
+
form = page.forms[1] #TODO: besser nach Name
|
43
|
+
form['loginForm[Username]'] = @config[:zoonar][:user]
|
44
|
+
form['loginForm[Password]'] = @config[:zoonar][:password]
|
45
|
+
|
46
|
+
page = agent.submit form
|
47
|
+
raise "login error" if ! page.body.include?("Hallo, #{@config[:zoonar][:user]}!")
|
48
|
+
page = agent.click page.links.text('Bilder hochladen')
|
49
|
+
raise "nicht auf Upload-Seite" if ! page.body.include?('bertragen Sie Ihre Bilder einzeln mit Hilfe Ihres Internet-Browsers,')
|
50
|
+
form = page.form('fUploadResource')
|
51
|
+
form.file_uploads.first.file_name = photo.filename
|
52
|
+
# puts "form abgeschickt ..."
|
53
|
+
page = agent.submit form
|
54
|
+
if page.body.include?("Es ist ein Fehler aufgetreten")
|
55
|
+
if page.body.include?("Das Bild ist zu klein.")
|
56
|
+
raise "Bild zu klein. Muss mind. 6 MP sein"
|
57
|
+
else
|
58
|
+
raise "Fehler beim Upload"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
"Es ist ein Fehler aufgetreten!
|
62
|
+
|
63
|
+
Bei der Übertragung des Bildes ist ein Fehler aufgetreten.
|
64
|
+
|
65
|
+
Das Bild ist zu klein. Bitte übertragen Sie nur Bilder mit mehr als 6,0 MegaPixel.
|
66
|
+
|
67
|
+
Bitte versuchen Sie es erneut.
|
68
|
+
"
|
69
|
+
|
70
|
+
sonstiger_fehler = "<b>Es ist ein Fehler aufgetreten!</b><br/>\n
|
71
|
+
<br/>\n Bei der Übertragung des Bildes ist ein Fehler aufgetreten.<br/>\
|
72
|
+
n <br/>\n Die Datei konnte nicht übertragen werden.<br/> "
|
73
|
+
if page.body.include?("Vielen Dank!")
|
74
|
+
puts "OK"
|
75
|
+
end
|
76
|
+
ok="Vielen Dank!
|
77
|
+
|
78
|
+
Das Bild wurde vollständig übertragen und wird nun von der Zoonar Bildredaktion geprüft.
|
79
|
+
Wenn das Bild angenommen wird, erscheint es umgehend im Zoonar Portal und ist über die Such-Funktion zu finden.
|
80
|
+
Falls wir das Bild ablehnen sollten, werden Sie eine Benachrichtigung per E-Mail erhalten.
|
81
|
+
"
|
82
|
+
|
83
|
+
`echo "zoonar\t#{photo.filename}\t#{Time.now}" >>sendeliste.dat` #TODO:
|
84
|
+
true
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
module Multistockphoto
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'multistockphoto/version'
|
8
|
+
require 'multistockphoto/generic_site'
|
9
|
+
require 'multistockphoto/multistockphoto'
|
10
|
+
require 'multistockphoto/photo'
|
11
|
+
#require 'multistockphoto/config'
|
12
|
+
|
13
|
+
require 'multistockphoto/site_fotolia'
|
14
|
+
require 'multistockphoto/site_zoonar'
|
15
|
+
require 'multistockphoto/site_aldi'
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/multistockphoto.rb'}"
|
9
|
+
puts "Loading multistockphoto gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|