quotifier 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/LICENSE +21 -0
  4. data/lib/quotifier.rb +29 -6
  5. metadata +18 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7beb980438956fc78ab8538fb84ddcae844b038
4
- data.tar.gz: 1632feea4e5f6180ed2f06db44c466f72e020673
3
+ metadata.gz: a50747c7119fc28c55262ff0ede105da9b625de2
4
+ data.tar.gz: eaaf483ee7d68c4c00cf8338cf4d9082d1096a13
5
5
  SHA512:
6
- metadata.gz: 60947d7901115d0de07dff4a75931604371c4d2bc099177249fbaf9b73dc214792f2895f0915361f981a2ed5a62bbd9e5b57622d9abf55f7f4c15cfeaa95afba
7
- data.tar.gz: 8957ba76e2e0835cfa54d471f2d85a7508fcb53cd5e46f4c3da0c6c7087d1ff2a0c9ffb84c2d731da64b8594ef596d416cd5171e80a5206af60556584d065d3f
6
+ metadata.gz: adc4a04b08e3513d8a2224dee238fb771af23062d3e27a17de63a9314956ab4898fcd36336c57b9069f16ffb7e6383989115c7afdc91afeba1c86611f1b328fd
7
+ data.tar.gz: 93069128b7f871aa9399da5788d80f5b98154c9577caff109d975af94884b2a663c61e0f06a69f96f06fec285ce27c12c785f94c1a2e3c21c5ab603b00033302
@@ -0,0 +1,11 @@
1
+ ## Version 0.0.5
2
+
3
+ This release now makes it so that all quotifier quotes are in comments in the html and not visible on to the user. As such it is much less obtrusive and much more in ine with the philosophy of the original Quotifier project.
4
+
5
+ For those who miss the old approach of displaying the quotes to the user fear not for this has now become an optional feature you can enable. Take a look at the [readme](https://github.com/almiche/quotifier_as_middleware/blob/master/README.md#optional-features) for more info.
6
+
7
+ ## Version 0.0.3
8
+
9
+ Implemented the quotify gem by famingo instead of in house solution in previous release 0.0.2 code name "Quantico". Added support for inline javascript and css scripts within a file.
10
+
11
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Famingo Labs Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,11 +1,13 @@
1
1
  require 'json'
2
2
  require 'net/http'
3
3
  require 'quotify'
4
+ require 'faraday'
4
5
 
5
6
  class Quotifier
6
7
 
7
- def initialize(app)
8
+ def initialize(app,css = false)
8
9
  @app = app
10
+ @css = css
9
11
  end
10
12
 
11
13
  def call(env)
@@ -29,7 +31,8 @@ class Quotifier
29
31
  js_open: /[<]{1}script[>]{1}/,
30
32
  js_closed: /[<]{1}\/script[>]{1}/,
31
33
  style_open: /[<]{1}style[>]{1}/,
32
- style_closed: /[<]{1}\/style[>]{1}/
34
+ style_closed: /[<]{1}\/style[>]{1}/,
35
+ head_close:/[<]{1}\/head[>]{1}/
33
36
  }
34
37
 
35
38
  string_html.split(/[\n\r]+/).each do |line|
@@ -41,6 +44,8 @@ class Quotifier
41
44
  css_flag = true
42
45
  elsif regex[:style_closed].match(line)
43
46
  css_flag = false
47
+ elsif regex[:head_close].match(line) && @css
48
+ line = "#{line}\n#{insert_css}"
44
49
  end
45
50
 
46
51
  random_mod = rand(1..10)
@@ -49,10 +54,13 @@ class Quotifier
49
54
  line = line + "\n\t \\\\" + Quotify.generate
50
55
  elsif css_flag
51
56
  line = line + "\n\t #" + Quotify.generate
52
- elsif !js_flag
53
- line = line + "\n\t" + Quotify.generate
54
- elsif !css_flag
55
- line = line + "\n\t" + Quotify.generate
57
+ else
58
+ if(@css)
59
+ quote = Quotify.generate
60
+ line = "#{line} #{keyvahnify(quote.quote,quote.author)}"
61
+ else
62
+ line = line + "\n\t <!--" + Quotify.generate + "-->"
63
+ end
56
64
  end
57
65
  end
58
66
  fresh_output << line + "\n"
@@ -65,6 +73,21 @@ class Quotifier
65
73
  html
66
74
  end
67
75
 
76
+ def keyvahnify (quote,author)
77
+
78
+ html ="\n<div id=\"box\">\n
79
+ <p id=\"quote\">\"#{quote}\"</p>\n
80
+ <brp />\n
81
+ <p id=\"author\">#{author}</p>\n
82
+ </div>\n"
83
+
84
+ end
85
+
86
+ def insert_css
87
+ stylesheet = Faraday.get 'https://raw.githubusercontent.com/almiche/quotifier_as_middleware/master/lib/static/shawarma.css'
88
+ return "<style>\n#{stylesheet.body}\n</style>"
89
+ end
90
+
68
91
  #This will be used for the next release
69
92
  def single_line_js_or_css? (line)
70
93
  single_line_js = /[<]{1}script[>]{1} .* [<]{1}\/script[>]{1}/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quotifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Chatmajian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-06 00:00:00.000000000 Z
11
+ date: 2018-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: 'Rack Middleware that inserts random quotes into outbound html being
42
56
  served from any Rack webserver '
43
57
  email: chamich196@hotmail.com
@@ -45,6 +59,8 @@ executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
62
+ - CHANGELOG.md
63
+ - LICENSE
48
64
  - lib/quotifier.rb
49
65
  homepage: http://rubygems.org/gems/quotifier
50
66
  licenses: