tumbleweed 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/bin/tumbleweed +5 -0
- data/lib/tumbleweed.rb +31 -0
- data/lib/tumbleweed/version.rb +3 -0
- data/tumbleweed.gemspec +22 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/tumbleweed
ADDED
data/lib/tumbleweed.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "tumbleweed/version"
|
2
|
+
|
3
|
+
module Tumbleweed
|
4
|
+
def self.upload_theme blog, user, password, theme_file, config_file
|
5
|
+
url = 'https://www.tumblr.com'
|
6
|
+
|
7
|
+
agent = Mechanize.new
|
8
|
+
page = agent.get(url)
|
9
|
+
|
10
|
+
# Login
|
11
|
+
login_form = page.forms[1]
|
12
|
+
login_form.email = email
|
13
|
+
login_form.password = password
|
14
|
+
agent.submit(login_form)
|
15
|
+
|
16
|
+
page = agent.get("http://www.tumblr.com/customize/#{blog}")
|
17
|
+
user_form_key = page.body.scan(/Tumblr\.Customize\.user_form_key\s*=\s*'([^']+)';/).flatten.first
|
18
|
+
|
19
|
+
theme = File.read(theme_file)
|
20
|
+
config = YAML.load_file(config_file)
|
21
|
+
|
22
|
+
json = config.merge(
|
23
|
+
'user_form_key' => user_form_key,
|
24
|
+
'id' => blog,
|
25
|
+
'custom_theme' => theme,
|
26
|
+
'name' => blog
|
27
|
+
)
|
28
|
+
|
29
|
+
agent.post("http://www.tumblr.com/customize_api/blog/#{blog}", json.to_json)
|
30
|
+
end
|
31
|
+
end
|
data/tumbleweed.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path('../lib/tumbleweed/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Elia Schito']
|
6
|
+
gem.email = ['elia@schito.me']
|
7
|
+
gem.description = %q{Mechanized tumblr theme uploads}
|
8
|
+
gem.summary = %q{Mechanized tumblr theme uploads}
|
9
|
+
gem.homepage = ''
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = 'tumbleweed'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = Tumbleweed::VERSION
|
17
|
+
gem.license = 'MIT'
|
18
|
+
|
19
|
+
gem.add_development_dependency 'rake'
|
20
|
+
gem.add_runtime_dependency 'mechanize', '~> 2.1'
|
21
|
+
gem.add_runtime_dependency 'json', '~> 1.6.3'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tumbleweed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Elia Schito
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70120051394340 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70120051394340
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mechanize
|
27
|
+
requirement: &70120051390720 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.1'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70120051390720
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
requirement: &70120051407120 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.6.3
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70120051407120
|
47
|
+
description: Mechanized tumblr theme uploads
|
48
|
+
email:
|
49
|
+
- elia@schito.me
|
50
|
+
executables:
|
51
|
+
- tumbleweed
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- Gemfile
|
57
|
+
- Rakefile
|
58
|
+
- bin/tumbleweed
|
59
|
+
- lib/tumbleweed.rb
|
60
|
+
- lib/tumbleweed/version.rb
|
61
|
+
- tumbleweed.gemspec
|
62
|
+
homepage: ''
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
hash: 1298329411217325956
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>'
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.3.1
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.17
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Mechanized tumblr theme uploads
|
90
|
+
test_files: []
|