commons_upload 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cae81aeb8399d8af09c70adf53565264b490b3e3
4
+ data.tar.gz: 83fdf34f730820611a852d20d85641a26a57d67a
5
+ SHA512:
6
+ metadata.gz: 17d336bad5f662f258f7cc63877371871f7bbb1400f8b974b78af85b5f26503d0184013626b3cffd61a181ea793627f28262b22856f3739889dc9fe9052b1158
7
+ data.tar.gz: 05e7621ef1dac9950bf76c9bb905359479437fc6ee351f9db34593fd1bf6c947d830c19740eb0b507f50253ba8181888c23d7a0080bd27b20e050ccc9a7bb9a5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in commons_upload.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2014-2015 Vikas Yaligar, Željko Filipin and Amir E. Aharoni
2
+ under the terms of The MIT License (MIT), as follows:
3
+
4
+ This software consists of voluntary contributions made by many
5
+ individuals (AUTHORS.txt) For exact contribution history, see the
6
+ revision history and logs, available at https://gerrit.wikimedia.org
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ "Software"), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # commons_upload
2
+
3
+ This is a gem for uploading images to Wikimedia Commons.
4
+ It uses the MediaWiki API and the mediawiki-api Ruby gem.
5
+ It is currently intended for uploading auto-translated
6
+ screenshots created using the screenshot gem, for documenting
7
+ different MediaWiki features and extensions.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'commons_upload'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install commons_upload
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'commons_upload/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "commons_upload"
8
+ spec.version = CommonsUpload::VERSION
9
+ spec.authors = ['Vikas Yaligar', 'Željko Filipin', 'Amir E. Aharoni']
10
+ spec.email = ['amir.aharoni@mail.huji.ac.il']
11
+ spec.description = %q{Upload images to Wikimedia Commons. This is intended for uploading auto-translated screenshots for MediaWiki documentation.}
12
+ spec.summary = %q{Upload images to Wikimedia Commons.}
13
+ spec.homepage = "https://github.com/amire80/commons_upload"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = '~> 2.0'
21
+
22
+ spec.add_runtime_dependency 'mediawiki_api', '~> 0.3.0'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,45 @@
1
+ require "commons_upload/version"
2
+
3
+ module CommonsUpload
4
+
5
+ def self.license(language_code, file_name)
6
+ require 'date'
7
+ date = Date.today.to_s
8
+ "=={{int:filedesc}}==
9
+ {{Information
10
+ |description={{en|1=#{file_name}}}
11
+ |date=#{date}
12
+ |source=[[User:LanguageScreenshotBot|Automatically created by LanguageScreenshotBot]]
13
+ |author=[[User:LanguageScreenshotBot|Automatically created by LanguageScreenshotBot]]
14
+ |permission=
15
+ |other_versions=
16
+ |other_fields=
17
+ }}
18
+
19
+ =={{int:license-header}}==
20
+ {{Wikipedia-screenshot}}
21
+
22
+ [[Category:VisualEditor automatic screenshots/#{language_code}]]"
23
+ end
24
+
25
+ def self.image(file_path, client)
26
+ language_code = ENV['LANGUAGE_SCREENSHOT_CODE']
27
+ file_name = File.basename(file_path, '')
28
+ file_license = license(language_code, file_name)
29
+
30
+ client.upload_image(file_name, file_path, file_license, true)
31
+ sleep 5 # Restriction in bot speed: https://commons.wikimedia.org/wiki/Commons:Bots#Bot_speed
32
+ end
33
+
34
+ def self.images
35
+ screenshot_directory = ENV['LANGUAGE_SCREENSHOT_PATH'] || './screenshots'
36
+ require 'mediawiki_api'
37
+ client = MediawikiApi::Client.new ENV['MEDIAWIKI_API_UPLOAD_URL']
38
+ client.log_in ENV['MEDIAWIKI_USER'], ENV['MEDIAWIKI_PASSWORD']
39
+ Dir["#{screenshot_directory}/*.png"].each do |file_path|
40
+ puts "Uploading #{file_path}"
41
+ image file_path, client
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,3 @@
1
+ module CommonsUpload
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commons_upload
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vikas Yaligar
8
+ - Željko Filipin
9
+ - Amir E. Aharoni
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-02-19 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mediawiki_api
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: 0.3.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '1.3'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: '1.3'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ description: Upload images to Wikimedia Commons. This is intended for uploading auto-translated
58
+ screenshots for MediaWiki documentation.
59
+ email:
60
+ - amir.aharoni@mail.huji.ac.il
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - commons_upload.gemspec
71
+ - lib/commons_upload.rb
72
+ - lib/commons_upload/version.rb
73
+ homepage: https://github.com/amire80/commons_upload
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '2.0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Upload images to Wikimedia Commons.
97
+ test_files: []