theme_bandit 0.0.5 → 0.0.6
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 +4 -4
- data/README.md +9 -6
- data/bin/bandit +7 -4
- data/lib/theme_bandit/downloader.rb +5 -1
- data/lib/theme_bandit/parser/css.rb +5 -1
- data/lib/theme_bandit/parser/js.rb +3 -1
- data/lib/theme_bandit/url_formatter.rb +13 -0
- data/lib/theme_bandit/util/version.rb +1 -1
- data/test/test_url_formatter.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc589066445b4257641f73b8bd7d9916ab226f77
|
4
|
+
data.tar.gz: 81ea5575b0132159a2bb684f2ca5b2ea69869c9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef26a8702620eb23ec1841a993dff3761e0a9d2c5ec5ac93bb6a230ae87d69a97b1aaf6df8c374a5ef303b8e7f308364e0317ad14e804561b63d8c56bccdc85
|
7
|
+
data.tar.gz: 43475a0b29b2f3cee58c5257157801c0d5b3a426de15cd6c601303f3726aee891aadadbf76590bcd8c51a99e7231b0abf766a8b0cf80087fdc1ff1979d5cf754
|
data/README.md
CHANGED
@@ -2,21 +2,24 @@
|
|
2
2
|
|
3
3
|
Enjoy rapid prototyping with theme bandit :heart:
|
4
4
|
|
5
|
-
Wordpress themes are beautiful
|
5
|
+
Wordpress themes are beautiful - now you can easily convert your favorite themes to a small ruby app
|
6
6
|
|
7
|
-
This gem converts any site template (Wordpress, Joomla, HTML) into
|
8
|
-
simple sinatra rack application,
|
7
|
+
This gem converts any site template (Wordpress, Joomla, HTML) into
|
8
|
+
simple sinatra rack application, resolving both javascript and css.
|
9
9
|
|
10
10
|
Usage from the command line: `bandit`
|
11
|
+
|
11
12
|
- Select a url to download
|
12
13
|
- Select a templating engine (erb, haml, slim)
|
13
14
|
- Start your rack app!
|
14
15
|
|
16
|
+
You wouldn't download a website ... would you?!
|
17
|
+
|
15
18
|
## Installation
|
16
19
|
|
17
20
|
Add this line to your application's Gemfile:
|
18
21
|
|
19
|
-
gem 'theme_bandit'
|
22
|
+
gem 'theme_bandit', '~> 0.0.5'
|
20
23
|
|
21
24
|
And then execute:
|
22
25
|
|
@@ -40,10 +43,10 @@ Sometimes the html for page A is messy and in turn produces bad slim,
|
|
40
43
|
which can cause the application to blow up until corrected.
|
41
44
|
|
42
45
|
## TODO / Coming Soon
|
43
|
-
-
|
46
|
+
- _Replace & fetch @import declarations in CSS_ added in v0.0.5
|
47
|
+
- Support for binaries (images + fonts + embeds)
|
44
48
|
- Fetch ajax resources
|
45
49
|
- HTML Sanitization
|
46
|
-
- Support for binaries (images + fonts + embeds)
|
47
50
|
- Support for multiple pages
|
48
51
|
- HTML Formatting
|
49
52
|
- Verfiy inline tags
|
data/bin/bandit
CHANGED
@@ -45,7 +45,7 @@ end
|
|
45
45
|
|
46
46
|
def ask_user_for_domain
|
47
47
|
puts 'Enter the URL of the theme you wish to download (example: http://www.google.com)'
|
48
|
-
url = gets.chomp
|
48
|
+
url = $stdin.gets.chomp
|
49
49
|
if url == ''
|
50
50
|
raise 'Invalid url'
|
51
51
|
else
|
@@ -55,14 +55,17 @@ end
|
|
55
55
|
|
56
56
|
def ask_user_for_language
|
57
57
|
puts 'Select your favorite template engine (erb, haml, slim)'
|
58
|
-
answer = gets.chomp
|
59
|
-
|
58
|
+
answer = $stdin.gets.chomp
|
59
|
+
answer = 'erb' if answer == ''
|
60
|
+
unless match = answer.match(SUPPORTED_ENGINES)
|
61
|
+
fail "You must select a supported template engine (erb, haml, or slim)"
|
62
|
+
end
|
60
63
|
match[0]
|
61
64
|
end
|
62
65
|
|
63
66
|
def ask_user_to_start_rack_app
|
64
67
|
puts 'Do you want to start your new rack app? y/n'
|
65
|
-
answer = gets.chomp
|
68
|
+
answer = $stdin.gets.chomp
|
66
69
|
if answer == 'y'
|
67
70
|
app_message
|
68
71
|
puts 'changing directory to ./theme'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pry'
|
1
2
|
module ThemeBandit
|
2
3
|
module CSSParser
|
3
4
|
|
@@ -21,7 +22,10 @@ module ThemeBandit
|
|
21
22
|
if href.absolute?
|
22
23
|
strip_query_string href.to_s
|
23
24
|
else
|
24
|
-
strip_query_string "#{url.scheme}://#{url.host}#{href}"
|
25
|
+
# strip_query_string "#{url.scheme}://#{url.host}#{href}"
|
26
|
+
new_href = strip_query_string(href.to_s)
|
27
|
+
absolute = resolve_dot_dots "#{@url.host}#{@url.path}", new_href
|
28
|
+
"#{url.scheme}://#{absolute}"
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -18,7 +18,9 @@ module ThemeBandit
|
|
18
18
|
if src.absolute?
|
19
19
|
strip_query_string src.to_s
|
20
20
|
else
|
21
|
-
strip_query_string
|
21
|
+
new_src = strip_query_string(src.to_s)
|
22
|
+
absolute = resolve_dot_dots "#{@url.host}#{@url.path}", new_src
|
23
|
+
"#{url.scheme}://#{absolute}"
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -3,5 +3,18 @@ module ThemeBandit
|
|
3
3
|
def strip_query_string(str)
|
4
4
|
str.split('?').first
|
5
5
|
end
|
6
|
+
|
7
|
+
# returns an aboslute url with dot dot syntax removed
|
8
|
+
def resolve_dot_dots(host, path)
|
9
|
+
number_of_dot_dots = path.split('/').select { |v| v == '..' }.length
|
10
|
+
if number_of_dot_dots > 0
|
11
|
+
new_path = path.gsub('../', '')
|
12
|
+
new_host = host.split('/')
|
13
|
+
new_host.pop(number_of_dot_dots + 1)
|
14
|
+
new_host.push(new_path).join('/')
|
15
|
+
else
|
16
|
+
"#{host}#{path}"
|
17
|
+
end
|
18
|
+
end
|
6
19
|
end
|
7
20
|
end
|
data/test/test_url_formatter.rb
CHANGED
@@ -9,4 +9,10 @@ describe ThemeBandit::URLFormatter do
|
|
9
9
|
assert_equal(strip_query_string(url), 'http://www.example.com')
|
10
10
|
end
|
11
11
|
|
12
|
+
it '#resolve_dot_dots' do
|
13
|
+
host = 'www.example.com/demo/abc/test.html'
|
14
|
+
path = '../doc/docs.css'
|
15
|
+
assert_equal(resolve_dot_dots(host, path), 'www.example.com/demo/doc/docs.css')
|
16
|
+
end
|
17
|
+
|
12
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theme_bandit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Fender
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|