httpit 0.4.8 → 0.5.0

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
- SHA1:
3
- metadata.gz: 69512fe962e7c56e5780206561979552a4b7f64c
4
- data.tar.gz: b466438f481cbf0de8630092139ccade86fb1fae
2
+ SHA256:
3
+ metadata.gz: 7a8232c3298cb4d225a367020e450aea8ebe1f56793b9970289fc47188e7b073
4
+ data.tar.gz: 0437b12ca4d642f709713816cf8147333bfd658f6d0a6c258153d19dee12cd07
5
5
  SHA512:
6
- metadata.gz: 6a29ad9e6f31b40bfe83b1521dfe8f0162a0f6e3b92d092e3aca55dfde19d0b563445fb04591e66a40178c7a258824f38104e8617e9875a80c232add23abcd97
7
- data.tar.gz: 5b9753f954cfe6bf8fd5a05313028a8be3c4e1672537673337fe17b01bf9299d2fbe68f16c0a20174bd0103326b0980ea609465fe91ba6290dba29d4b39be4e0
6
+ metadata.gz: f7f33910df8f3c7c3e116c28e081009d279f687547ccb405caf84682bb93fcf64637c41803406a0a94ff9ba40c0702d42920bb3ad8431b4aa85a767cb8a92af9
7
+ data.tar.gz: 1f6296dc8d278859b9138a685e0a990059466ee15c8aa7973bf9150f3143a8e2c3474e16e07800cbb34a494b44c7384209ae23dff96c56929126127b52671633
data/README.md CHANGED
@@ -28,4 +28,4 @@ See `example` folder
28
28
 
29
29
  * Develop websites with HAML & SASS but without backend
30
30
  * Share files to mobile devices (if we access over Wi-Fi)
31
- * Try some 3rd-party examples what requires absolute urls (src="/files/...")
31
+ * Try some 3rd-party examples what requires absolute urls (src="/files/...")
data/bin/httpit CHANGED
@@ -7,14 +7,14 @@ require "pathname"
7
7
  require 'shellwords'
8
8
 
9
9
  GEM_ROOT = Pathname.new(__FILE__).dirname.join("..").expand_path
10
- ENV['BUNDLE_GEMFILE'] ||= GEM_ROOT.join("Gemfile").to_s
11
10
 
12
- require "bundler/setup"
11
+ # ENV['BUNDLE_GEMFILE'] ||= GEM_ROOT.join("Gemfile").to_s
12
+ # require "bundler/setup"
13
+
13
14
  require 'sinatra/base'
14
15
  require 'haml'
15
16
  require 'sass'
16
17
  require 'sass/plugin'
17
- require 'redcloth'
18
18
 
19
19
  ROOT = Pathname.pwd
20
20
 
@@ -40,12 +40,12 @@ class << ROOT
40
40
  end
41
41
  end
42
42
 
43
- # only one parametr - port number
44
- if ARGV.size > 0
45
- set :port, ARGV.first.to_i
46
- end
47
-
48
43
  class HttpIt < Sinatra::Base
44
+ # only one parametr - port number
45
+ if ARGV.size > 0
46
+ set :port, ARGV.first.to_i
47
+ end
48
+
49
49
  set :views, ROOT
50
50
  set :public_folder, ROOT
51
51
  set :app_file, $0
@@ -128,7 +128,13 @@ class HttpIt < Sinatra::Base
128
128
  get '/__img_preview' do
129
129
  params[:file] = params[:file].shellescape
130
130
  tmppath = "/tmp/httpit_preview_#{Time.now.to_i}.jpeg"
131
- `convert #{ROOT + params[:file]} -resize 1024 -quality 100% #{tmppath}`
131
+ begin
132
+ puts `convert #{ROOT + params[:file]} -resize 1024 -quality 100% #{tmppath}`
133
+ rescue => error
134
+ status 500
135
+ return "<b>CAN NOT RESIZE!</b><br>Command like utility 'convert' not found in your system (part of ImageMagick)"
136
+ end
137
+
132
138
  content_type "image/jpeg"
133
139
  content = File.open(tmppath, 'rb') { |f| f.read }
134
140
  File.delete(tmppath)
@@ -160,14 +166,17 @@ class HttpIt < Sinatra::Base
160
166
  if @path =~ /.+\.sass\.css/
161
167
  return halt(404) unless File.file?(abs_path.to_s.chomp('.css'))
162
168
  content_type :css
163
- sass @path.chomp('.sass.css').to_sym
169
+
170
+ template = Tilt.new(abs_path.to_s.chomp('.css'))
171
+ template.render
164
172
 
165
173
  elsif !abs_path.file? && !abs_path.directory?
166
174
  halt 404
167
175
 
168
176
  elsif @path =~ /.+\.md/
177
+ require 'kramdown' unless defined?(Kramdown::Document)
169
178
  content_type :html
170
- return RedCloth.new(abs_path.read).to_html
179
+ return Kramdown::Document.new(File.open(abs_path, 'r:utf8', &:read)).to_html
171
180
 
172
181
  elsif @path =~ /.+\.haml/
173
182
  haml @path.chomp('.haml').to_sym
@@ -196,4 +205,4 @@ class HttpIt < Sinatra::Base
196
205
  end
197
206
 
198
207
  HttpIt.run!
199
- at_exit { FileUtils.rm_rf(TMP_DIR) if File.exists?(TMP_DIR) }
208
+ at_exit { FileUtils.rm_rf(TMP_DIR) if File.directory?(TMP_DIR) }
data/example/readme.md CHANGED
@@ -1,9 +1,9 @@
1
- h1. This is a Heading 1
1
+ # This is a Heading 1
2
2
 
3
3
  This might be an introductory paragraph on the general topic.
4
4
 
5
- h2. Heading 2 gets more specific
5
+ # Heading 2 gets more specific
6
6
 
7
7
  Now we're getting into the details.
8
8
 
9
- !images/bird.jpg(This page is valid HTML)!
9
+ ![This page is valid HTML](images/bird.jpg)
@@ -1,3 +1,3 @@
1
1
  %header
2
2
  %h1 Math in design
3
- %h2 Fibonacci Sequence
3
+ %h2 Fibonacci Sequence
@@ -7,10 +7,10 @@
7
7
 
8
8
  %body
9
9
  #wrapper
10
- = haml :"#{@dirname}/_header"
10
+ != haml :"#{@dirname}/_header"
11
11
  .content
12
12
  .top-line
13
- This is example layout to show how gem "#{"<b>httpit</b>"}" in action
13
+ This is example layout to show how gem <b>httpit</b> in action
14
14
 
15
15
  %aside>
16
16
  %h4 For example:
@@ -28,8 +28,7 @@
28
28
  %h3 The Fibonacci Sequence
29
29
  %p
30
30
  The mathematics behind the golden ratio is heavily connected to the
31
- = succeed "." do
32
- %a{:href => "http://en.wikipedia.org/wiki/Fibonacci_sequence"} Fibonacci Sequence
31
+ %a{:href => "http://en.wikipedia.org/wiki/Fibonacci_sequence"} Fibonacci Sequence
33
32
  If you’re unfamiliar with the fibonacci sequence,
34
33
  it begins by definition with the numbers 0, 1 and then each successive number
35
34
  in the sequence is the sum of the previous two numbers.
@@ -39,8 +38,7 @@
39
38
  %p
40
39
  I’ll spare you the deep mathematics talk (we’ll just do a bit of division),
41
40
  since what we’re mainly interested in is how the sequence relates to the
42
- = succeed "." do
43
- %a{:href => "http://freemasonry.bcy.ca/symbolism/golden_ratio/index.html"} golden section
41
+ %a{:href => "http://freemasonry.bcy.ca/symbolism/golden_ratio/index.html"} golden section
44
42
 
45
43
  %p
46
44
  If you take any number in the sequence and divide it by the previous
data/httpit.gemspec CHANGED
@@ -1,21 +1,19 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "httpit"
3
- s.version = "0.4.8"
3
+ s.version = "0.5.0"
4
4
  s.summary = "Web server for static files"
5
5
  s.description = "HTTP sever for directory index with extra features"
6
6
  s.author = "Pavel Evstigneev"
7
7
  s.email = "pavel.evst@gmail.com"
8
8
  s.homepage = "http://github.com/Paxa/httpit"
9
- s.has_rdoc = false
10
9
  s.executables = ["httpit"]
11
- s.rubyforge_project = "httpit"
12
- s.files = File.read(__FILE__).match(/__#{'END'}__(.+)\z/m)[1].strip.split("\n")
13
- s.licenses = ['MIT', 'GPL-2']
14
-
15
- s.add_runtime_dependency 'sinatra', "~> 1.4.2"
16
- s.add_runtime_dependency 'haml', '~> 4.0.2'
17
- s.add_runtime_dependency 'RedCloth', "~> 4.2.9"
18
- s.add_runtime_dependency 'sass', "~> 3.2.8"
10
+ s.files = File.read(__FILE__).match(/__#{'END'}__(.+)\z/m)[1].strip.split("\n") - ['Gemfile.lock']
11
+ s.licenses = ['MIT', 'GPL-2.0']
12
+
13
+ s.add_runtime_dependency 'sinatra', "~> 3.0.6"
14
+ s.add_runtime_dependency 'haml', '~> 6.1.1'
15
+ s.add_runtime_dependency 'kramdown', "~> 2.4.0"
16
+ s.add_runtime_dependency 'sass', "~> 3.7.4"
19
17
  end
20
18
 
21
19
  # git ls-files
data/views/listing.haml CHANGED
@@ -51,11 +51,11 @@
51
51
  - for file in @files
52
52
  %li
53
53
  - if file[1] == :file
54
- %span= "&ndash;"
54
+ %span &ndash;
55
55
  - elsif file[1] == :dir
56
- %span= "+"
56
+ %span +
57
57
  - elsif file[1] == :link
58
- %span= "&rarr;"
58
+ %span &rarr;
59
59
 
60
60
  %a{:href => file_url(@path, file[0], file[1])}= file[0]
61
61
 
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Evstigneev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-25 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.2
19
+ version: 3.0.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.2
26
+ version: 3.0.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: haml
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 4.0.2
33
+ version: 6.1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 4.0.2
40
+ version: 6.1.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: RedCloth
42
+ name: kramdown
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 4.2.9
47
+ version: 2.4.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 4.2.9
54
+ version: 2.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sass
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.2.8
61
+ version: 3.7.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.2.8
68
+ version: 3.7.4
69
69
  description: HTTP sever for directory index with extra features
70
70
  email: pavel.evst@gmail.com
71
71
  executables:
@@ -73,9 +73,8 @@ executables:
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
76
+ - ".gitignore"
77
77
  - Gemfile
78
- - Gemfile.lock
79
78
  - LICENSE
80
79
  - README.md
81
80
  - bin/httpit
@@ -94,27 +93,25 @@ files:
94
93
  homepage: http://github.com/Paxa/httpit
95
94
  licenses:
96
95
  - MIT
97
- - GPL-2
96
+ - GPL-2.0
98
97
  metadata: {}
99
- post_install_message:
98
+ post_install_message:
100
99
  rdoc_options: []
101
100
  require_paths:
102
101
  - lib
103
102
  required_ruby_version: !ruby/object:Gem::Requirement
104
103
  requirements:
105
- - - '>='
104
+ - - ">="
106
105
  - !ruby/object:Gem::Version
107
106
  version: '0'
108
107
  required_rubygems_version: !ruby/object:Gem::Requirement
109
108
  requirements:
110
- - - '>='
109
+ - - ">="
111
110
  - !ruby/object:Gem::Version
112
111
  version: '0'
113
112
  requirements: []
114
- rubyforge_project: httpit
115
- rubygems_version: 2.0.6
116
- signing_key:
113
+ rubygems_version: 3.4.10
114
+ signing_key:
117
115
  specification_version: 4
118
116
  summary: Web server for static files
119
117
  test_files: []
120
- has_rdoc: false
data/Gemfile.lock DELETED
@@ -1,30 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- httpit (0.4.6)
5
- RedCloth (~> 4.2.9)
6
- haml (~> 4.0.2)
7
- sass (~> 3.2.8)
8
- sinatra (~> 1.4.2)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- RedCloth (4.2.9)
14
- haml (4.0.3)
15
- tilt
16
- rack (1.5.2)
17
- rack-protection (1.5.0)
18
- rack
19
- sass (3.2.12)
20
- sinatra (1.4.3)
21
- rack (~> 1.4)
22
- rack-protection (~> 1.4)
23
- tilt (~> 1.3, >= 1.3.4)
24
- tilt (1.4.1)
25
-
26
- PLATFORMS
27
- ruby
28
-
29
- DEPENDENCIES
30
- httpit!