servel 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -8
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +39 -39
- data/Rakefile +2 -2
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/servel.rb +0 -0
- data/lib/servel/app.rb +0 -0
- data/lib/servel/cli.rb +17 -17
- data/lib/servel/entry.rb +26 -26
- data/lib/servel/entry_factory.rb +0 -0
- data/lib/servel/haml_context.rb +53 -53
- data/lib/servel/home_app.rb +0 -0
- data/lib/servel/index.rb +12 -15
- data/lib/servel/instrumentation.rb +26 -26
- data/lib/servel/templates/_gallery.haml +0 -0
- data/lib/servel/templates/_listing.haml +24 -24
- data/lib/servel/templates/css/common.css +0 -0
- data/lib/servel/templates/css/gallery-text.css +0 -0
- data/lib/servel/templates/css/gallery.css +0 -0
- data/lib/servel/templates/css/home.css +0 -0
- data/lib/servel/templates/css/index.css +0 -0
- data/lib/servel/templates/css/listing.css +0 -0
- data/lib/servel/templates/css/normalize.css +0 -0
- data/lib/servel/templates/home.haml +0 -0
- data/lib/servel/templates/index.haml +2 -2
- data/lib/servel/templates/js/gallery.js +0 -0
- data/lib/servel/templates/js/listing.js +25 -25
- data/lib/servel/templates/js/ume.js +0 -0
- data/lib/servel/templates/js/url-search-params.js +0 -0
- data/lib/servel/version.rb +1 -1
- data/servel.gemspec +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdd4343b043f0e31a6f28099e1f2b30853361e57
|
4
|
+
data.tar.gz: a530e4b6f5430f339b0599c8186d9da21d9d918b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20bf86b2fd1a0189296a42797514f31720e386742c8123edd7006f82fd86c86406cd948f72bdb4946a3ac6a98cde365846a6d16561526124d301a4793cd0f6b0
|
7
|
+
data.tar.gz: 94b29d8b4d557bc28a0b5ab1762678474196ba72c6a4b9979b1fa2198bd235e5362a0159b2b93a22d2c29712f82488ed55abb3253284037e3d4852efa28c3a90
|
data/.gitignore
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/_yardoc/
|
4
|
-
/coverage/
|
5
|
-
/doc/
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/tmp/
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
9
|
/Gemfile.lock
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in servel.gemspec
|
6
|
-
gemspec
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in servel.gemspec
|
6
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2017 Brenton "B-Train" Fletcher
|
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
|
13
|
-
all 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
|
21
|
-
THE SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Brenton "B-Train" Fletcher
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
# Servel
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/servel`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'servel'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install servel
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/servel.
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
1
|
+
# Servel
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/servel`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'servel'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install servel
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/servel.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
task :default => :spec
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
task :default => :spec
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "servel"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "servel"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/lib/servel.rb
CHANGED
File without changes
|
data/lib/servel/app.rb
CHANGED
File without changes
|
data/lib/servel/cli.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
class Servel::CLI
|
2
|
-
def initialize(argv)
|
3
|
-
@argv = argv
|
4
|
-
end
|
5
|
-
|
6
|
-
def start
|
7
|
-
Rack::Handler::Puma.run(Servel.build_app(path_map))
|
8
|
-
end
|
9
|
-
|
10
|
-
def path_map
|
11
|
-
@argv.map do |arg|
|
12
|
-
root, url_root = arg.split(":" , 2)
|
13
|
-
root = Pathname.new(root).realpath
|
14
|
-
|
15
|
-
[root, url_root || "/"]
|
16
|
-
end.to_h
|
17
|
-
end
|
1
|
+
class Servel::CLI
|
2
|
+
def initialize(argv)
|
3
|
+
@argv = argv
|
4
|
+
end
|
5
|
+
|
6
|
+
def start
|
7
|
+
Rack::Handler::Puma.run(Servel.build_app(path_map))
|
8
|
+
end
|
9
|
+
|
10
|
+
def path_map
|
11
|
+
@argv.map do |arg|
|
12
|
+
root, url_root = arg.split(":" , 2)
|
13
|
+
root = Pathname.new(root).realpath
|
14
|
+
|
15
|
+
[root, url_root || "/"]
|
16
|
+
end.to_h
|
17
|
+
end
|
18
18
|
end
|
data/lib/servel/entry.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
class Servel::Entry
|
2
|
-
attr_reader :ftype, :type, :media_type, :listing_classes, :icon, :href, :name, :size, :mtime
|
3
|
-
|
4
|
-
def initialize(ftype:, type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil)
|
5
|
-
@ftype = ftype
|
6
|
-
@type = type
|
7
|
-
@media_type = media_type
|
8
|
-
@listing_classes = listing_classes
|
9
|
-
@icon = icon
|
10
|
-
@href = href
|
11
|
-
@name = name
|
12
|
-
@size = size
|
13
|
-
@mtime = mtime
|
14
|
-
end
|
15
|
-
|
16
|
-
def directory?
|
17
|
-
@ftype == :directory
|
18
|
-
end
|
19
|
-
|
20
|
-
def file?
|
21
|
-
@ftype == :file
|
22
|
-
end
|
23
|
-
|
24
|
-
def media?
|
25
|
-
!@media_type.nil?
|
26
|
-
end
|
1
|
+
class Servel::Entry
|
2
|
+
attr_reader :ftype, :type, :media_type, :listing_classes, :icon, :href, :name, :size, :mtime
|
3
|
+
|
4
|
+
def initialize(ftype:, type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil)
|
5
|
+
@ftype = ftype
|
6
|
+
@type = type
|
7
|
+
@media_type = media_type
|
8
|
+
@listing_classes = listing_classes
|
9
|
+
@icon = icon
|
10
|
+
@href = href
|
11
|
+
@name = name
|
12
|
+
@size = size
|
13
|
+
@mtime = mtime
|
14
|
+
end
|
15
|
+
|
16
|
+
def directory?
|
17
|
+
@ftype == :directory
|
18
|
+
end
|
19
|
+
|
20
|
+
def file?
|
21
|
+
@ftype == :file
|
22
|
+
end
|
23
|
+
|
24
|
+
def media?
|
25
|
+
!@media_type.nil?
|
26
|
+
end
|
27
27
|
end
|
data/lib/servel/entry_factory.rb
CHANGED
File without changes
|
data/lib/servel/haml_context.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
class Servel::HamlContext
|
2
|
-
extend Servel::Instrumentation
|
3
|
-
include ActiveSupport::NumberHelper
|
4
|
-
|
5
|
-
LOCK = Mutex.new
|
6
|
-
|
7
|
-
def self.render(template, locals)
|
8
|
-
[200, {}, [new.render(template, locals)]]
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@build_path = Pathname.new(__FILE__).dirname.realpath + 'templates'
|
13
|
-
end
|
14
|
-
|
15
|
-
def render(template, locals = {})
|
16
|
-
haml_engine(template).render(self, locals)
|
17
|
-
end
|
18
|
-
|
19
|
-
def partial(name, locals = {})
|
20
|
-
render("_#{name}.haml", locals)
|
21
|
-
end
|
22
|
-
|
23
|
-
def include(path)
|
24
|
-
(@build_path + path).read
|
25
|
-
end
|
26
|
-
|
27
|
-
def sort_attrs(sort, current_method)
|
28
|
-
data = { sort_method: current_method, sort_direction: "asc" }
|
29
|
-
classes = ["sortable"]
|
30
|
-
if sort[:method] == current_method
|
31
|
-
data[:sort_active] = true
|
32
|
-
data[:sort_direction] = sort[:direction]
|
33
|
-
classes << "sort-active"
|
34
|
-
classes << "sort-#{sort[:direction]}"
|
35
|
-
end
|
36
|
-
|
37
|
-
{
|
38
|
-
data: data,
|
39
|
-
class: classes
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def haml_engine(path)
|
44
|
-
LOCK.synchronize do
|
45
|
-
@@haml_engine_cache ||= {}
|
46
|
-
unless @@haml_engine_cache.key?(path)
|
47
|
-
@@haml_engine_cache[path] = Hamlit::Template.new(filename: path) { include(path) }
|
48
|
-
end
|
49
|
-
@@haml_engine_cache[path]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
instrument :render, :partial, :include
|
1
|
+
class Servel::HamlContext
|
2
|
+
extend Servel::Instrumentation
|
3
|
+
include ActiveSupport::NumberHelper
|
4
|
+
|
5
|
+
LOCK = Mutex.new
|
6
|
+
|
7
|
+
def self.render(template, locals)
|
8
|
+
[200, {}, [new.render(template, locals)]]
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@build_path = Pathname.new(__FILE__).dirname.realpath + 'templates'
|
13
|
+
end
|
14
|
+
|
15
|
+
def render(template, locals = {})
|
16
|
+
haml_engine(template).render(self, locals)
|
17
|
+
end
|
18
|
+
|
19
|
+
def partial(name, locals = {})
|
20
|
+
render("_#{name}.haml", locals)
|
21
|
+
end
|
22
|
+
|
23
|
+
def include(path)
|
24
|
+
(@build_path + path).read
|
25
|
+
end
|
26
|
+
|
27
|
+
def sort_attrs(sort, current_method)
|
28
|
+
data = { sort_method: current_method, sort_direction: "asc" }
|
29
|
+
classes = ["sortable"]
|
30
|
+
if sort[:method] == current_method
|
31
|
+
data[:sort_active] = true
|
32
|
+
data[:sort_direction] = sort[:direction]
|
33
|
+
classes << "sort-active"
|
34
|
+
classes << "sort-#{sort[:direction]}"
|
35
|
+
end
|
36
|
+
|
37
|
+
{
|
38
|
+
data: data,
|
39
|
+
class: classes
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def haml_engine(path)
|
44
|
+
LOCK.synchronize do
|
45
|
+
@@haml_engine_cache ||= {}
|
46
|
+
unless @@haml_engine_cache.key?(path)
|
47
|
+
@@haml_engine_cache[path] = Hamlit::Template.new(filename: path) { include(path) }
|
48
|
+
end
|
49
|
+
@@haml_engine_cache[path]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
instrument :render, :partial, :include
|
54
54
|
end
|
data/lib/servel/home_app.rb
CHANGED
File without changes
|
data/lib/servel/index.rb
CHANGED
@@ -20,13 +20,10 @@ class Servel::Index
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def locals
|
23
|
-
entries = @fs_path.children.map { |path| Servel::EntryFactory.for(path) }.compact
|
24
|
-
|
25
23
|
{
|
26
24
|
url_root: @url_root,
|
27
25
|
url_path: @url_path,
|
28
|
-
|
29
|
-
files: files(entries),
|
26
|
+
entries: entries,
|
30
27
|
sort: {
|
31
28
|
method: sort_method,
|
32
29
|
direction: sort_direction
|
@@ -34,6 +31,11 @@ class Servel::Index
|
|
34
31
|
}
|
35
32
|
end
|
36
33
|
|
34
|
+
def entries
|
35
|
+
children = @fs_path.children.map { |path| Servel::EntryFactory.for(path) }.compact
|
36
|
+
special_entries + apply_sort(children.select(&:directory?)) + apply_sort(children.select(&:file?))
|
37
|
+
end
|
38
|
+
|
37
39
|
def sort_method
|
38
40
|
param = @params["_servel_sort_method"]
|
39
41
|
param = "name" unless SORT_METHODS.include?(param)
|
@@ -46,23 +48,18 @@ class Servel::Index
|
|
46
48
|
param
|
47
49
|
end
|
48
50
|
|
49
|
-
def
|
50
|
-
list =
|
51
|
+
def special_entries
|
52
|
+
list = []
|
53
|
+
list << Servel::EntryFactory.home("/") if @url_root != ""
|
51
54
|
|
52
55
|
unless @url_path == "/"
|
53
|
-
list
|
54
|
-
list
|
56
|
+
list << Servel::EntryFactory.top(@url_root == "" ? "/" : @url_root)
|
57
|
+
list << Servel::EntryFactory.parent("../")
|
55
58
|
end
|
56
59
|
|
57
|
-
list.unshift(Servel::EntryFactory.home("/")) if @url_root != ""
|
58
|
-
|
59
60
|
list
|
60
61
|
end
|
61
62
|
|
62
|
-
def files(entries)
|
63
|
-
apply_sort(entries.select { |entry| entry.file? })
|
64
|
-
end
|
65
|
-
|
66
63
|
def apply_sort(entries)
|
67
64
|
entries = case sort_method
|
68
65
|
when "name"
|
@@ -79,5 +76,5 @@ class Servel::Index
|
|
79
76
|
entries
|
80
77
|
end
|
81
78
|
|
82
|
-
instrument :render, :locals, :
|
79
|
+
instrument :render, :locals, :entries, :apply_sort
|
83
80
|
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
module Servel::Instrumentation
|
2
|
-
def instrument(*method_names)
|
3
|
-
return unless ENV["DEBUG"] == "1"
|
4
|
-
|
5
|
-
Array(method_names).each do |method_name|
|
6
|
-
original_method_name = "#{method_name}_without_instrumentation"
|
7
|
-
|
8
|
-
alias_method original_method_name, method_name
|
9
|
-
|
10
|
-
cumulative_time_spent = 0
|
11
|
-
|
12
|
-
define_method(method_name) do |*args|
|
13
|
-
start = Time.now
|
14
|
-
|
15
|
-
return_value = __send__(original_method_name, *args)
|
16
|
-
|
17
|
-
finish = Time.now
|
18
|
-
time_spent = ((finish - start) * 1000.0)
|
19
|
-
cumulative_time_spent += time_spent
|
20
|
-
puts "Running #{self.class.name}<#{object_id}>##{method_name}: #{time_spent.round(3)}ms (cumulative: #{cumulative_time_spent.round(3)}ms)"
|
21
|
-
|
22
|
-
return_value
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Servel::Instrumentation
|
2
|
+
def instrument(*method_names)
|
3
|
+
return unless ENV["DEBUG"] == "1"
|
4
|
+
|
5
|
+
Array(method_names).each do |method_name|
|
6
|
+
original_method_name = "#{method_name}_without_instrumentation"
|
7
|
+
|
8
|
+
alias_method original_method_name, method_name
|
9
|
+
|
10
|
+
cumulative_time_spent = 0
|
11
|
+
|
12
|
+
define_method(method_name) do |*args|
|
13
|
+
start = Time.now
|
14
|
+
|
15
|
+
return_value = __send__(original_method_name, *args)
|
16
|
+
|
17
|
+
finish = Time.now
|
18
|
+
time_spent = ((finish - start) * 1000.0)
|
19
|
+
cumulative_time_spent += time_spent
|
20
|
+
puts "Running #{self.class.name}<#{object_id}>##{method_name}: #{time_spent.round(3)}ms (cumulative: #{cumulative_time_spent.round(3)}ms)"
|
21
|
+
|
22
|
+
return_value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
File without changes
|
@@ -1,25 +1,25 @@
|
|
1
|
-
%h1 Listing of #{url_root}#{url_path}
|
2
|
-
.table-wrapper
|
3
|
-
%table
|
4
|
-
%thead
|
5
|
-
%tr
|
6
|
-
%th{sort_attrs(sort, "name")}
|
7
|
-
%a{href: "#"} Name
|
8
|
-
%th.new-tab
|
9
|
-
%th.type{sort_attrs(sort, "type")}
|
10
|
-
%a{href: "#"} Type
|
11
|
-
%th.size{sort_attrs(sort, "size")}
|
12
|
-
%a{href: "#"} Size
|
13
|
-
%th.modified{sort_attrs(sort, "mtime")}
|
14
|
-
%a{href: "#"} Modified
|
15
|
-
%tbody
|
16
|
-
-
|
17
|
-
%tr
|
18
|
-
%td
|
19
|
-
%span.icon= file.icon
|
20
|
-
%a.default{href: file.href, class: file.listing_classes, data: { type: file.media_type }}= file.name
|
21
|
-
%td
|
22
|
-
%a.new-tab{href: file.href, class: file.listing_classes, target: "_blank"} (New tab)
|
23
|
-
%td= file.type
|
24
|
-
%td= file.size.nil? ? "-" : number_to_human_size(file.size)
|
1
|
+
%h1 Listing of #{url_root}#{url_path}
|
2
|
+
.table-wrapper
|
3
|
+
%table
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
%th{sort_attrs(sort, "name")}
|
7
|
+
%a{href: "#"} Name
|
8
|
+
%th.new-tab
|
9
|
+
%th.type{sort_attrs(sort, "type")}
|
10
|
+
%a{href: "#"} Type
|
11
|
+
%th.size{sort_attrs(sort, "size")}
|
12
|
+
%a{href: "#"} Size
|
13
|
+
%th.modified{sort_attrs(sort, "mtime")}
|
14
|
+
%a{href: "#"} Modified
|
15
|
+
%tbody
|
16
|
+
- entries.each do |file|
|
17
|
+
%tr
|
18
|
+
%td
|
19
|
+
%span.icon= file.icon
|
20
|
+
%a.default{href: file.href, class: file.listing_classes, data: { type: file.media_type }}= file.name
|
21
|
+
%td
|
22
|
+
%a.new-tab{href: file.href, class: file.listing_classes, target: "_blank"} (New tab)
|
23
|
+
%td= file.type
|
24
|
+
%td= file.size.nil? ? "-" : number_to_human_size(file.size)
|
25
25
|
%td= file.mtime.nil? ? "-" : file.mtime.strftime("%e %b %Y %l:%M %p")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -18,6 +18,6 @@
|
|
18
18
|
#{include('js/ume.js')}
|
19
19
|
#{include('js/gallery.js')}
|
20
20
|
%body
|
21
|
-
- if
|
21
|
+
- if entries.any? { |f| f.media? }
|
22
22
|
#gallery!= partial('gallery')
|
23
|
-
#listing!= partial('listing', { url_root: url_root, url_path: url_path,
|
23
|
+
#listing!= partial('listing', { url_root: url_root, url_path: url_path, entries: entries, sort: sort })
|
File without changes
|
@@ -1,26 +1,26 @@
|
|
1
|
-
function initListing() {
|
2
|
-
$ = document.querySelector.bind(document);
|
3
|
-
|
4
|
-
function applySort(sortable) {
|
5
|
-
var params = new URLSearchParams(location.search.slice(1));
|
6
|
-
params.set("_servel_sort_method", sortable.dataset.sortMethod);
|
7
|
-
params.set("_servel_sort_direction", sortable.dataset.sortDirection);
|
8
|
-
|
9
|
-
if('sortActive' in sortable.dataset) {
|
10
|
-
params.set("_servel_sort_direction", sortable.dataset.sortDirection == "asc" ? "desc" : "asc");
|
11
|
-
}
|
12
|
-
|
13
|
-
location.href = location.pathname + "?" + params.toString();
|
14
|
-
}
|
15
|
-
|
16
|
-
document.body.addEventListener("click", function(e) {
|
17
|
-
if(!e.target) return;
|
18
|
-
|
19
|
-
if(e.target.closest("th.sortable")) {
|
20
|
-
e.preventDefault();
|
21
|
-
applySort(e.target.closest("th.sortable"));
|
22
|
-
}
|
23
|
-
});
|
24
|
-
}
|
25
|
-
|
1
|
+
function initListing() {
|
2
|
+
$ = document.querySelector.bind(document);
|
3
|
+
|
4
|
+
function applySort(sortable) {
|
5
|
+
var params = new URLSearchParams(location.search.slice(1));
|
6
|
+
params.set("_servel_sort_method", sortable.dataset.sortMethod);
|
7
|
+
params.set("_servel_sort_direction", sortable.dataset.sortDirection);
|
8
|
+
|
9
|
+
if('sortActive' in sortable.dataset) {
|
10
|
+
params.set("_servel_sort_direction", sortable.dataset.sortDirection == "asc" ? "desc" : "asc");
|
11
|
+
}
|
12
|
+
|
13
|
+
location.href = location.pathname + "?" + params.toString();
|
14
|
+
}
|
15
|
+
|
16
|
+
document.body.addEventListener("click", function(e) {
|
17
|
+
if(!e.target) return;
|
18
|
+
|
19
|
+
if(e.target.closest("th.sortable")) {
|
20
|
+
e.preventDefault();
|
21
|
+
applySort(e.target.closest("th.sortable"));
|
22
|
+
}
|
23
|
+
});
|
24
|
+
}
|
25
|
+
|
26
26
|
window.addEventListener("DOMContentLoaded", initListing);
|
File without changes
|
File without changes
|
data/lib/servel/version.rb
CHANGED
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.
|
4
|
+
version: 0.14.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-05-
|
11
|
+
date: 2018-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.6.
|
187
|
+
rubygems_version: 2.6.13
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Serves files and directories over HTTP.
|