servel 0.7.0 → 0.8.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
2
  SHA1:
3
- metadata.gz: d4a27247e6a018f755e9ace67a1135b4a324702a
4
- data.tar.gz: d812976aaa161dc23b9fea1d661db77b7b81d5af
3
+ metadata.gz: 110f9b74c9c900dfe2febfde8eb58d671831b549
4
+ data.tar.gz: 0e2acd5f66b547f9ccfb53d52896ba3c3ce4184b
5
5
  SHA512:
6
- metadata.gz: 37bd1b9749d58c39d15c97165f07ee3bc49795d68cc7bdaf89aaccbbfa70baa71295b92faa5f23f53fe120515d2abde5bf020618651b8a179fca845bf30a0635
7
- data.tar.gz: 96af2ce748d56880f872f12e1af2841010d9aa959553883480de01ffdbc19af6f8ef4e3a62ad71b75fef24115b28fa538b27a4fec12c4bdd5a2af8a8053cdc07
6
+ metadata.gz: f1d8a384505b7b707e484adbb3e5238ebce1eca1c0e451839a6ad99751521799216e4b65e8ba5bfbf5a12c883a8e9b30e6c66366251eacfe39ae1f3fbe2ac554
7
+ data.tar.gz: 95a5fb8d8ae8e43642a70291bba5b2c2c9e231c81c1cc4e044857efb8333fafabbb59e5b84e7e47d4417452c27770938f749e9c2d408a6723b572d143d1a8cc6
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/lib/servel.rb CHANGED
File without changes
data/lib/servel/app.rb CHANGED
@@ -16,6 +16,8 @@ class Servel::App
16
16
 
17
17
  return redirect("#{url_root}#{url_path}/") unless env["PATH_INFO"].end_with?("/")
18
18
 
19
+ return [404, {}, []] unless fs_path.exist?
20
+
19
21
  index(Servel::Locals.new(url_root: url_root, url_path: url_path, fs_path: fs_path))
20
22
  end
21
23
 
data/lib/servel/cli.rb CHANGED
File without changes
File without changes
File without changes
data/lib/servel/locals.rb CHANGED
@@ -20,7 +20,7 @@ class Servel::Locals
20
20
 
21
21
  unless @url_path == "/"
22
22
  list.unshift(Servel::Path.parent("../"))
23
- list.unshift(Servel::Path.top(@url_root))
23
+ list.unshift(Servel::Path.top(@url_root == "" ? "/" : @url_root))
24
24
  end
25
25
 
26
26
  list
data/lib/servel/path.rb CHANGED
@@ -1,38 +1,38 @@
1
- class Servel::Path
2
- attr_reader :type, :media_type, :listing_classes, :icon, :href, :name, :size, :mtime
3
-
4
- def initialize(type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil)
5
- @type = type
6
- @media_type = media_type
7
- @listing_classes = listing_classes
8
- @icon = icon
9
- @href = href
10
- @name = name
11
- @size = size
12
- @mtime = mtime
13
- end
14
-
15
- def media?
16
- !@media_type.nil?
17
- end
18
-
19
- def self.top(href)
20
- Servel::Path.new(
21
- type: "Dir",
22
- listing_classes: "top directory",
23
- icon: "🔝",
24
- href: href,
25
- name: "Top Directory"
26
- )
27
- end
28
-
29
- def self.parent(href)
30
- Servel::Path.new(
31
- type: "Dir",
32
- listing_classes: "parent directory",
33
- icon: "⬆️",
34
- href: href,
35
- name: "Parent Directory"
36
- )
37
- end
1
+ class Servel::Path
2
+ attr_reader :type, :media_type, :listing_classes, :icon, :href, :name, :size, :mtime
3
+
4
+ def initialize(type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil)
5
+ @type = type
6
+ @media_type = media_type
7
+ @listing_classes = listing_classes
8
+ @icon = icon
9
+ @href = href
10
+ @name = name
11
+ @size = size
12
+ @mtime = mtime
13
+ end
14
+
15
+ def media?
16
+ !@media_type.nil?
17
+ end
18
+
19
+ def self.top(href)
20
+ Servel::Path.new(
21
+ type: "Dir",
22
+ listing_classes: "top directory",
23
+ icon: "🔝",
24
+ href: href,
25
+ name: "Top Directory"
26
+ )
27
+ end
28
+
29
+ def self.parent(href)
30
+ Servel::Path.new(
31
+ type: "Dir",
32
+ listing_classes: "parent directory",
33
+ icon: "⬆️",
34
+ href: href,
35
+ name: "Parent Directory"
36
+ )
37
+ end
38
38
  end
@@ -1,74 +1,74 @@
1
- class Servel::PathBuilder
2
- IMAGE_EXTS = %w(.jpg .jpeg .png .gif)
3
- VIDEO_EXTS = %w(.webm .mp4)
4
- AUDIO_EXTS = %w(.mp3 .m4a .wav)
5
-
6
- def initialize(path)
7
- @path = Pathname.new(path)
8
- end
9
-
10
- def build
11
- Servel::Path.new(
12
- type: type,
13
- media_type: media_type,
14
- listing_classes: listing_classes,
15
- icon: icon,
16
- href: @path.basename,
17
- name: @path.basename,
18
- size: size,
19
- mtime: @path.mtime
20
- )
21
- end
22
-
23
- def type
24
- if @path.directory?
25
- "Dir"
26
- elsif @path.file?
27
- @path.extname.sub(/^\./, "")
28
- else
29
- ""
30
- end
31
- end
32
-
33
- def media_type
34
- return nil unless @path.file? && @path.extname
35
-
36
- case @path.extname.downcase
37
- when *IMAGE_EXTS
38
- :image
39
- when *VIDEO_EXTS
40
- :video
41
- when *AUDIO_EXTS
42
- :audio
43
- else
44
- nil
45
- end
46
- end
47
-
48
- def listing_classes
49
- klasses = []
50
- klasses << "file" if @path.file?
51
- klasses << "directory" if @path.directory?
52
- klasses << "media" if media_type
53
- klasses << media_type if media_type
54
- klasses.join(" ")
55
- end
56
-
57
- def icon
58
- return "📁" if @path.directory?
59
- case media_type
60
- when :video
61
- "🎞️"
62
- when :image
63
- "🖼️"
64
- when :audio
65
- "🔊"
66
- else
67
- "📝"
68
- end
69
- end
70
-
71
- def size
72
- @path.directory? ? nil : @path.size
73
- end
1
+ class Servel::PathBuilder
2
+ IMAGE_EXTS = %w(.jpg .jpeg .png .gif)
3
+ VIDEO_EXTS = %w(.webm .mp4)
4
+ AUDIO_EXTS = %w(.mp3 .m4a .wav)
5
+
6
+ def initialize(path)
7
+ @path = Pathname.new(path)
8
+ end
9
+
10
+ def build
11
+ Servel::Path.new(
12
+ type: type,
13
+ media_type: media_type,
14
+ listing_classes: listing_classes,
15
+ icon: icon,
16
+ href: @path.basename,
17
+ name: @path.basename,
18
+ size: size,
19
+ mtime: @path.mtime
20
+ )
21
+ end
22
+
23
+ def type
24
+ if @path.directory?
25
+ "Dir"
26
+ elsif @path.file?
27
+ @path.extname.sub(/^\./, "")
28
+ else
29
+ ""
30
+ end
31
+ end
32
+
33
+ def media_type
34
+ return nil unless @path.file? && @path.extname
35
+
36
+ case @path.extname.downcase
37
+ when *IMAGE_EXTS
38
+ :image
39
+ when *VIDEO_EXTS
40
+ :video
41
+ when *AUDIO_EXTS
42
+ :audio
43
+ else
44
+ nil
45
+ end
46
+ end
47
+
48
+ def listing_classes
49
+ klasses = []
50
+ klasses << "file" if @path.file?
51
+ klasses << "directory" if @path.directory?
52
+ klasses << "media" if media_type
53
+ klasses << media_type if media_type
54
+ klasses.join(" ")
55
+ end
56
+
57
+ def icon
58
+ return "📁" if @path.directory?
59
+ case media_type
60
+ when :video
61
+ "🎞️"
62
+ when :image
63
+ "🖼️"
64
+ when :audio
65
+ "🔊"
66
+ else
67
+ "📝"
68
+ end
69
+ end
70
+
71
+ def size
72
+ @path.directory? ? nil : @path.size
73
+ end
74
74
  end
File without changes
File without changes
File without changes
File without changes
@@ -67,7 +67,7 @@ var Gallery = (function() {
67
67
  document.body.addEventListener("click", function(e) {
68
68
  if(!e.target) return;
69
69
 
70
- if(e.target.matches("a.media")) {
70
+ if(e.target.matches("a.media:not(.new-tab)")) {
71
71
  e.preventDefault();
72
72
  jump(e.target.href);
73
73
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module Servel
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/servel.gemspec CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brenton "B-Train" Fletcher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-13 00:00:00.000000000 Z
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler