servel 0.27.0 → 0.32.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/_gallery.haml +7 -6
- data/app/css/common.css +8 -0
- data/app/css/gallery.css +63 -39
- data/app/js/gallery.js +46 -15
- data/app/js/index.js +1 -45
- data/app/js/listing.js +1 -1
- data/bin/servel +1 -1
- data/lib/servel.rb +7 -0
- data/lib/servel/cli.rb +24 -18
- data/lib/servel/config_parser.rb +43 -0
- data/lib/servel/version.rb +1 -1
- data/servel.gemspec +1 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 283ef8ff838b1a149aee4379a02233d006d5dfec7887de4791e20c2e61cbe86e
|
4
|
+
data.tar.gz: b6fa99503294d5bba7b338c86fd0eb9bb46b06944de3fe2b10b225a6120b6794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d44b0fef9dac7e95483e13856f4b030813019c26ed7676a8154cdad88eef8b9db9b5075c4a463dc374353c0e73a09b9c408aa069b79f80da58c221451a227bc3
|
7
|
+
data.tar.gz: d7a4126762ab129714b328aaf1dd492a17d1354870f4f943f799e2816f490de1ef85af253f8f4fcb96bd1d879fff5a134a7043f48112f2fe00bce7eac4af237a
|
data/app/_gallery.haml
CHANGED
@@ -6,9 +6,10 @@
|
|
6
6
|
#page-back.paginator ◀
|
7
7
|
#page-next.paginator ▶
|
8
8
|
#content
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
#scroller
|
10
|
+
%img#image
|
11
|
+
%video#video{controls: false, loop: true}
|
12
|
+
%audio#audio{controls: true}
|
13
|
+
#text
|
14
|
+
%a#text-anchor{href: '#'}
|
15
|
+
#text-content
|
data/app/css/common.css
CHANGED
data/app/css/gallery.css
CHANGED
@@ -1,25 +1,85 @@
|
|
1
1
|
#gallery {
|
2
2
|
background: #333;
|
3
3
|
display: none;
|
4
|
-
flex-direction: column;
|
5
4
|
}
|
6
5
|
|
7
6
|
body.has-gallery.gallery #gallery {
|
8
7
|
display: flex;
|
9
8
|
}
|
10
9
|
|
10
|
+
#controls {
|
11
|
+
display: flex;
|
12
|
+
}
|
13
|
+
|
14
|
+
#page-jump-listing {
|
15
|
+
flex-grow: 1;
|
16
|
+
}
|
17
|
+
|
18
|
+
.paginator {
|
19
|
+
display: flex;
|
20
|
+
align-items: center;
|
21
|
+
justify-content: center;
|
22
|
+
height: 75px;
|
23
|
+
|
24
|
+
font-size: 2em;
|
25
|
+
font-weight: bold;
|
26
|
+
text-align: center;
|
27
|
+
background-color: #1f1f1f;
|
28
|
+
color: #858585;
|
29
|
+
|
30
|
+
cursor: pointer;
|
31
|
+
}
|
32
|
+
|
33
|
+
.paginator:hover {
|
34
|
+
background-color: #0f0f0f;
|
35
|
+
color: #c1c1c1;
|
36
|
+
}
|
37
|
+
|
11
38
|
#content {
|
12
39
|
display: flex;
|
13
40
|
align-items: center;
|
14
41
|
justify-content: center;
|
15
42
|
flex-grow: 1;
|
43
|
+
min-width: 0;
|
44
|
+
min-height: 0;
|
45
|
+
}
|
46
|
+
|
47
|
+
#scroller {
|
48
|
+
width: 100%;
|
49
|
+
max-height: 100%;
|
50
|
+
overflow: auto;
|
51
|
+
}
|
52
|
+
|
53
|
+
body.portrait #gallery {
|
54
|
+
flex-direction: column;
|
55
|
+
}
|
56
|
+
|
57
|
+
body.portrait .paginator {
|
58
|
+
width: 100px;
|
59
|
+
}
|
60
|
+
|
61
|
+
body.portrait #page-jump-listing {
|
62
|
+
width: auto;
|
63
|
+
}
|
64
|
+
|
65
|
+
body.landscape #gallery {
|
66
|
+
flex-direction: row;
|
67
|
+
}
|
68
|
+
|
69
|
+
body.landscape #controls {
|
70
|
+
flex-direction: column;
|
71
|
+
flex-shrink: 0;
|
72
|
+
width: 100px;
|
73
|
+
}
|
74
|
+
|
75
|
+
body.landscape #page-jump-listing {
|
76
|
+
writing-mode: vertical-rl;
|
77
|
+
transform: rotate(180deg);
|
16
78
|
}
|
17
79
|
|
18
80
|
#image, #video, #audio, #text {
|
19
81
|
display: none;
|
20
|
-
max-width: 100%;
|
21
82
|
margin: 0 auto 0 auto;
|
22
|
-
padding-top: 75px;
|
23
83
|
}
|
24
84
|
|
25
85
|
#video:focus, #audio:focus {
|
@@ -51,36 +111,6 @@ body.has-gallery.gallery #gallery {
|
|
51
111
|
display: block;
|
52
112
|
}
|
53
113
|
|
54
|
-
#controls {
|
55
|
-
position: fixed;
|
56
|
-
left: 0;
|
57
|
-
right: 0;
|
58
|
-
display: flex;
|
59
|
-
z-index: 10;
|
60
|
-
}
|
61
|
-
|
62
|
-
.paginator {
|
63
|
-
display: flex;
|
64
|
-
align-items: center;
|
65
|
-
justify-content: center;
|
66
|
-
width: 100px;
|
67
|
-
height: 75px;
|
68
|
-
|
69
|
-
font-size: 2em;
|
70
|
-
font-weight: bold;
|
71
|
-
text-align: center;
|
72
|
-
background-color: #000000;
|
73
|
-
color: #ffffff;
|
74
|
-
|
75
|
-
opacity: 0.4;
|
76
|
-
cursor: pointer;
|
77
|
-
}
|
78
|
-
|
79
|
-
#page-jump-listing {
|
80
|
-
flex-grow: 1;
|
81
|
-
width: auto;
|
82
|
-
}
|
83
|
-
|
84
114
|
@media screen and (max-width: 767px) {
|
85
115
|
#gallery.video, #gallery.audio, #gallery.text {
|
86
116
|
padding: 0;
|
@@ -101,9 +131,3 @@ body.has-gallery.gallery #gallery {
|
|
101
131
|
display: none;
|
102
132
|
}
|
103
133
|
}
|
104
|
-
|
105
|
-
@media screen and (min-width: 768px) {
|
106
|
-
.paginator:hover {
|
107
|
-
opacity: 0.7;
|
108
|
-
}
|
109
|
-
}
|
data/app/js/gallery.js
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var Gallery = (function() {
|
4
|
-
var LAYOUT_MODES = ["fit-both", "fit-width", "clamp-width"];
|
4
|
+
var LAYOUT_MODES = ["fit-both", "fit-width", "clamp-width", "full-size"];
|
5
5
|
|
6
|
+
var $body;
|
6
7
|
var $gallery;
|
8
|
+
var $image;
|
9
|
+
var $video;
|
10
|
+
var $audio;
|
7
11
|
var currentIndex;
|
8
12
|
var layoutModeIndex = 0;
|
9
13
|
|
@@ -20,9 +24,10 @@ var Gallery = (function() {
|
|
20
24
|
|
21
25
|
function clearContent() {
|
22
26
|
$gallery.classList.remove("image", "video", "audio", "text");
|
23
|
-
$
|
24
|
-
$
|
25
|
-
$
|
27
|
+
$video.removeAttribute('src');
|
28
|
+
$video.pause();
|
29
|
+
$audio.removeAttribute('src');
|
30
|
+
$audio.pause();
|
26
31
|
$("#text-content").innerHTML = "";
|
27
32
|
}
|
28
33
|
|
@@ -98,7 +103,6 @@ var Gallery = (function() {
|
|
98
103
|
}
|
99
104
|
|
100
105
|
function playPauseVideo() {
|
101
|
-
var $video = $("#video");
|
102
106
|
if ($video.paused || $video.ended) $video.play();
|
103
107
|
else $video.pause();
|
104
108
|
}
|
@@ -153,19 +157,42 @@ var Gallery = (function() {
|
|
153
157
|
}
|
154
158
|
|
155
159
|
function layout() {
|
156
|
-
var
|
157
|
-
|
160
|
+
var vw = document.documentElement.clientWidth;
|
161
|
+
var vh = document.documentElement.clientHeight;
|
162
|
+
|
163
|
+
var viewportOrientation = vw > vh ? "landscape" : "portrait";
|
164
|
+
$body.classList.remove("landscape", "portrait");
|
165
|
+
$body.classList.add(viewportOrientation);
|
166
|
+
|
167
|
+
$gallery.style.height = vh + "px";
|
168
|
+
|
169
|
+
var scrollerMaxHeight = viewportOrientation == "landscape" ? vh : vh - 75;
|
158
170
|
|
159
171
|
var layoutMode = LAYOUT_MODES[layoutModeIndex];
|
160
|
-
var maxHeight = layoutMode == "fit-both" ? viewportHeight : "none";
|
161
|
-
var maxWidth = layoutMode == "clamp-width" ? "1000px" : "100%";
|
162
172
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
173
|
+
if(layoutMode == "fit-both") {
|
174
|
+
var maxWidth = "100%";
|
175
|
+
var maxHeight = (scrollerMaxHeight + "px");
|
176
|
+
}
|
177
|
+
else if(layoutMode == "fit-width") {
|
178
|
+
var maxWidth = "100%";
|
179
|
+
var maxHeight = "none";
|
180
|
+
}
|
181
|
+
else if(layoutMode == "clamp-width") {
|
182
|
+
var maxWidth = "1000px";
|
183
|
+
var maxHeight = "none";
|
184
|
+
}
|
185
|
+
else if(layoutMode == "full-size") {
|
186
|
+
var maxWidth = "none";
|
187
|
+
var maxHeight = "none";
|
188
|
+
}
|
189
|
+
|
190
|
+
$image.style.maxWidth = maxWidth;
|
191
|
+
$image.style.maxHeight = maxHeight;
|
192
|
+
$video.style.maxWidth = maxWidth;
|
193
|
+
$video.style.maxHeight = maxHeight;
|
194
|
+
$audio.style.maxWidth = maxWidth;
|
195
|
+
$audio.style.maxHeight = maxHeight;
|
169
196
|
}
|
170
197
|
|
171
198
|
function initLayout() {
|
@@ -179,7 +206,11 @@ var Gallery = (function() {
|
|
179
206
|
}
|
180
207
|
|
181
208
|
function init() {
|
209
|
+
$body = $("body");
|
182
210
|
$gallery = $("#gallery");
|
211
|
+
$image = $("#image");
|
212
|
+
$video = $("#video");
|
213
|
+
$audio = $("#audio");
|
183
214
|
|
184
215
|
onEntriesUpdate();
|
185
216
|
|
data/app/js/index.js
CHANGED
@@ -19,52 +19,8 @@ var Index = (function() {
|
|
19
19
|
document.body.classList.add("gallery");
|
20
20
|
}
|
21
21
|
|
22
|
-
function jumpScroll() {
|
23
|
-
if(galleryVisible()) {
|
24
|
-
jumpListing();
|
25
|
-
window.scrollTo(0, 0);
|
26
|
-
}
|
27
|
-
else {
|
28
|
-
jumpGallery();
|
29
|
-
window.scrollTo(0, document.body.scrollHeight);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
function atTop() {
|
34
|
-
return window.scrollY == 0;
|
35
|
-
}
|
36
|
-
|
37
|
-
function bottomScrollDown(event) {
|
38
|
-
return galleryVisible() && atBottom() && event.deltaY > 0;
|
39
|
-
}
|
40
|
-
|
41
|
-
function topScrollUp(event) {
|
42
|
-
return listingVisible() && atTop() && event.deltaY < 0;
|
43
|
-
}
|
44
|
-
|
45
|
-
function initEvents() {
|
46
|
-
var scrollSize = 0;
|
47
|
-
|
48
|
-
window.addEventListener("wheel", function(event) {
|
49
|
-
if(bottomScrollDown(event) || topScrollUp(event)) {
|
50
|
-
scrollSize += Math.abs(event.deltaY);
|
51
|
-
|
52
|
-
if(scrollSize >= 1500) {
|
53
|
-
scrollSize = 0;
|
54
|
-
jumpScroll();
|
55
|
-
}
|
56
|
-
}
|
57
|
-
else {
|
58
|
-
scrollSize = 0;
|
59
|
-
}
|
60
|
-
});
|
61
|
-
}
|
62
|
-
|
63
22
|
function init() {
|
64
|
-
|
65
|
-
else jumpListing();
|
66
|
-
|
67
|
-
initEvents();
|
23
|
+
jumpListing();
|
68
24
|
}
|
69
25
|
|
70
26
|
return {
|
data/app/js/listing.js
CHANGED
@@ -27,7 +27,7 @@ var Listing = (function() {
|
|
27
27
|
function renderRow(file) {
|
28
28
|
return HTMLSafe`
|
29
29
|
<tr>
|
30
|
-
<td class="name">
|
30
|
+
<td class="name text-selectable">
|
31
31
|
<span class="icon">${file.icon}</span>
|
32
32
|
<a href="${file.href}" class="default ${file.class}" data-url="${file.href}" data-type="${file.mediaType}">${file.name}</a>
|
33
33
|
</td>
|
data/bin/servel
CHANGED
data/lib/servel.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'rack'
|
2
2
|
require 'rack/handler/puma'
|
3
|
+
require 'puma/configuration'
|
3
4
|
require 'hamlit'
|
4
5
|
require 'active_support/all'
|
5
6
|
require 'lru_redux'
|
7
|
+
require 'tty-config'
|
6
8
|
|
7
9
|
require 'thread'
|
8
10
|
require 'pathname'
|
@@ -15,6 +17,10 @@ module Servel
|
|
15
17
|
|
16
18
|
Rack::URLMap.new(url_map)
|
17
19
|
end
|
20
|
+
|
21
|
+
def self.config
|
22
|
+
@config ||= Servel::ConfigParser.new.config
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
require "servel/version"
|
@@ -25,4 +31,5 @@ require "servel/haml_context"
|
|
25
31
|
require "servel/index"
|
26
32
|
require "servel/app"
|
27
33
|
require "servel/home_app"
|
34
|
+
require "servel/config_parser"
|
28
35
|
require "servel/cli"
|
data/lib/servel/cli.rb
CHANGED
@@ -1,18 +1,24 @@
|
|
1
|
-
class Servel::CLI
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
1
|
+
class Servel::CLI
|
2
|
+
ALLOWED_PUMA_OPTIONS = [
|
3
|
+
:Host,
|
4
|
+
:Port,
|
5
|
+
:binds
|
6
|
+
]
|
7
|
+
|
8
|
+
def start
|
9
|
+
Rack::Handler::Puma.run(Servel.build_app(path_map), **puma_options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path_map
|
13
|
+
Servel.config.fetch(:listings).map do |listing|
|
14
|
+
listing = { listing => nil } if listing.is_a?(String)
|
15
|
+
|
16
|
+
root, url_root = listing.keys.first, listing.values.first || "/"
|
17
|
+
[Pathname.new(root).realpath, url_root]
|
18
|
+
end.to_h
|
19
|
+
end
|
20
|
+
|
21
|
+
def puma_options
|
22
|
+
Servel.config.to_h.transform_keys(&:to_sym).slice(*ALLOWED_PUMA_OPTIONS)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Servel::ConfigParser
|
2
|
+
attr_reader :config
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@config = TTY::Config.new
|
6
|
+
@config.filename = "servel"
|
7
|
+
@config.append_path(Dir.pwd)
|
8
|
+
@config.append_path((Pathname.new(Dir.home) + ".servel").to_s)
|
9
|
+
@config.append_path(Dir.home)
|
10
|
+
@config.env_prefix = "servel"
|
11
|
+
@config.autoload_env
|
12
|
+
@config.read if @config.exist?
|
13
|
+
|
14
|
+
@config.append(*parse_argv, to: :listings)
|
15
|
+
parse_binds
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse_argv
|
19
|
+
ARGV.map do |arg|
|
20
|
+
root, url_root = arg.split(":" , 2)
|
21
|
+
{ root => url_root }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse_binds
|
26
|
+
return parse_ssl_bind if @config.fetch(:cert) && @config.fetch(:key)
|
27
|
+
|
28
|
+
host = @config.fetch(:host)
|
29
|
+
port = @config.fetch(:port)
|
30
|
+
@config.set(:Host, value: host) if host
|
31
|
+
@config.set(:Port, value: port) if port
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse_ssl_bind
|
35
|
+
host = @config.fetch(:host, default: ::Puma::ConfigDefault::DefaultTCPHost)
|
36
|
+
port = @config.fetch(:port, default: ::Puma::ConfigDefault::DefaultTCPPort)
|
37
|
+
key = Pathname.new(@config.fetch(:key)).expand_path
|
38
|
+
cert = Pathname.new(@config.fetch(:cert)).expand_path
|
39
|
+
|
40
|
+
query = URI.encode_www_form(key: key, cert: cert)
|
41
|
+
@config.append("ssl://#{host}:#{port}?#{query}", to: :binds)
|
42
|
+
end
|
43
|
+
end
|
data/lib/servel/version.rb
CHANGED
data/servel.gemspec
CHANGED
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.
|
4
|
+
version: 0.32.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:
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: tty-config
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Serves files and directories over HTTP.
|
112
126
|
email:
|
113
127
|
- i@bloople.net
|
@@ -143,6 +157,7 @@ files:
|
|
143
157
|
- lib/servel.rb
|
144
158
|
- lib/servel/app.rb
|
145
159
|
- lib/servel/cli.rb
|
160
|
+
- lib/servel/config_parser.rb
|
146
161
|
- lib/servel/entry.rb
|
147
162
|
- lib/servel/entry_factory.rb
|
148
163
|
- lib/servel/haml_context.rb
|
@@ -170,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
185
|
- !ruby/object:Gem::Version
|
171
186
|
version: '0'
|
172
187
|
requirements: []
|
173
|
-
|
174
|
-
rubygems_version: 2.7.6
|
188
|
+
rubygems_version: 3.0.3
|
175
189
|
signing_key:
|
176
190
|
specification_version: 4
|
177
191
|
summary: Serves files and directories over HTTP.
|