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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81c723824fb7b4fc26fdffc3fced9bac1977b425
4
- data.tar.gz: 186064cc76b40f3bcf43b5783b7e7153906e55af
3
+ metadata.gz: cc589066445b4257641f73b8bd7d9916ab226f77
4
+ data.tar.gz: 81ea5575b0132159a2bb684f2ca5b2ea69869c9b
5
5
  SHA512:
6
- metadata.gz: c282373169582e752f8b333f638424fe79f33f23a37782e6bf2b21e79f48ea31321bb628828f85dd4b167ca78d71c346ec3466f765c81f66504d5481cf22bbe6
7
- data.tar.gz: 8c8f7d1ffffa25f0ac7788fdb023cfaf21474a1be1b1f986e8a69c03a9d7a9ab29b5f620aa7a828a3afa7a6c4cc43001d43fc3ce8fc456634457434a83c00af2
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! Now you can easily convert your favorite wordpress theme to a small ruby app.
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 a small and
8
- simple sinatra rack application, handling all of the JS and CSS for you.
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
- - Replace & fetch @import declarations in CSS
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
- fail "You must select a supported template engine (erb, haml, or slim)" unless match = answer.match(SUPPORTED_ENGINES)
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'
@@ -24,7 +24,11 @@ module ThemeBandit
24
24
  end
25
25
 
26
26
  def get_document(url)
27
- self.class.get(url, options)
27
+ begin
28
+ self.class.get(url, options)
29
+ rescue => e
30
+ p "request failed for #{url} #{e}"
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -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 "#{url.scheme}://#{url.host}#{src}"
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
@@ -1,3 +1,3 @@
1
1
  module ThemeBandit
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -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.5
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-09-23 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty