smooster 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b10f0a4f5608b08c92b1c3a604c47106fe035db5
4
- data.tar.gz: d84635953f0c111cde9a1d1c4838b21b7d96a255
3
+ metadata.gz: 8a20fe62a1bbfd74278fa7d59b3039ad468453ce
4
+ data.tar.gz: aa5e06e14aebc6b643ca085d97a26a08fa8b988c
5
5
  SHA512:
6
- metadata.gz: 82fd0268f1ce3d1d00fc8f1ee52f257e2827516cad8f13df5e6c43de4a15ac731315ccd01fd75c914594c937ef300c7a2d42c017e63665c4e0d4ad9803700d15
7
- data.tar.gz: 35920f7fa2949e2500d5d45293be8e5b2a038efcb4b1a9075fe29e148f1a80b08309ee65436eedc63d51d5a160fba995ca8593762af2d07a8886032b0c478757
6
+ metadata.gz: 1ff1e2b8cfa6b70d1315184e27c15516f65ea8b6900b7ba3fd42a49f4632f17d661de1829c58a99b5f379817bdbcc8fea252ffa94191c8baec2dcb0452ac0b9f
7
+ data.tar.gz: f05da62d75ce563341fb3f7573f1da9a807f050317587bd02cc6e6721077402b7817e29de7aa915f4c18f917427d94779d2eacf159e319e77fc89bc873863729
data/README.md CHANGED
@@ -74,6 +74,10 @@ This is a ruby gem
74
74
 
75
75
  ## Changelog
76
76
 
77
+ ###0.4.2
78
+ * Bugfix: Checking folder names for unsupported characters before upload
79
+ * Bugfix: Checking page titles for unsupported characters before upload
80
+
77
81
  ###0.4.1
78
82
  * Feature: Setting the hosting for the website
79
83
 
@@ -9,6 +9,7 @@ module Smooster
9
9
 
10
10
  desc "test", "Returns test data"
11
11
  def test
12
+ puts "smooster Gem Version: #{Gem.loaded_specs["smooster"].version}"
12
13
  puts Smooster::Application.instance.api_key()
13
14
  puts Dir.pwd
14
15
  end
@@ -91,12 +92,19 @@ module Smooster
91
92
  urls << p.url
92
93
  puts "#{p.filename} #{status}"
93
94
  end
95
+ puts "Starting validation of #{urls.count} pages"
96
+ return if urls.count == 0
94
97
  urls.each do |url|
95
- puts "#{url}"
96
- url_encoded = CGI.escape(url)
97
- if options[:validator]
98
- Launchy.open("http://validator.w3.org/check?uri=#{url_encoded}&charset=%28detect+automatically%29&doctype=Inline&group=0")
99
- sleep 1
98
+ begin
99
+ puts "#{url}"
100
+ url_encoded = CGI.escape(url)
101
+ if options[:validator]
102
+ Launchy.open("http://validator.w3.org/check?uri=#{url_encoded}&charset=%28detect+automatically%29&doctype=Inline&group=0")
103
+ sleep 1
104
+ end
105
+ rescue => e
106
+ Smooster::Application.instance.logger.error "Error in page validation for #{url}!: #{e} / #{e.backtrace.inspect}"
107
+ puts "This url failed to be validated: #{url}".colorize(:red)
100
108
  end
101
109
  end
102
110
  end
@@ -53,6 +53,11 @@ module Smooster
53
53
  def upload
54
54
  return false if self.checksum.to_s == self.load_checksum.to_s
55
55
 
56
+ unless /^[a-zA-Z0-9\/\-]+$/.match(self.folder_path)
57
+ puts "The folder names must contain ONLY letters, numbers and hyphens (-): #{self.folder_path}".colorize(:red)
58
+ return false
59
+ end
60
+
56
61
  if self.smo_id.present?
57
62
  begin
58
63
  response = RestClient.put "#{Smooster::Application.instance.api_url()}/#{Smooster::Application.instance.site_id()}/media_assets/#{self.smo_id}", {:media_asset => {:file => File.new(self.file_path, 'rb'), :folder_path => self.folder_path}}, {"Authorization" => 'Token token="'+ Smooster::Application.instance.api_key() +'"', "Accept" => 'application/vnd.smoosterid.v2'}
@@ -9,8 +9,12 @@ module Smooster
9
9
  template = SiteTemplate.new({:body => body, :path => file, :checksum => Digest::MD5.hexdigest(body)})
10
10
  template.smo_id = template.load_smo_id if template.load_smo_id.present?
11
11
  source = Nokogiri::HTML(body)
12
- template.title = source.css('title').first.inner_html
13
- collection << template
12
+ if /^[a-z0-9\/\-]+$/.match(source.css('title').first)
13
+ template.title = source.css('title').first.inner_html
14
+ collection << template
15
+ else
16
+ puts "Couldn't create page, because the templates title-tag name must contain ONLY lower case letters, numbers and hyphens (-): #{source.css('title').first}".colorize(:red)
17
+ end
14
18
  end
15
19
  collection
16
20
  end
@@ -10,8 +10,12 @@ module Smooster
10
10
  template.smo_id = template.load_smo_id if template.load_smo_id.present?
11
11
  source = Nokogiri::HTML(body)
12
12
  if source.css('title').first
13
- template.title = source.css('title').first.inner_html
14
- collection << template
13
+ if /^[a-z0-9\/\-]+$/.match(source.css('title').first)
14
+ template.title = source.css('title').first.inner_html
15
+ collection << template
16
+ else
17
+ puts "Couldn't create template, because the templates title-tag name must contain ONLY lower case letters, numbers and hyphens (-): #{source.css('title').first}".colorize(:red)
18
+ end
15
19
  else
16
20
  puts "The file #{file} is not a valid HTMl-Document. Also be sure to add a title-tag".colorize(:red)
17
21
  end
@@ -1,3 +1,3 @@
1
1
  module Smooster
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smooster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Maier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-16 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor