synful 1.0.0 → 1.0.2
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 +4 -4
- data/README.md +3 -1
- data/bin/synful +90 -68
- data/synful.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37beb91e8a78a71b6bdbbfb1833b664a5d2cbf8d260cfb8bfe4aa3c1366ebacf
|
4
|
+
data.tar.gz: eeb2fafa7499da63f9484609c624bfbcea4ef2c29048942e5aaeeee2cedceecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37af9ab3ba9e38bf792d7a46aea3ec7c0621524d6393c2cf52998fdf6e789957d03c5cb5dbdc2a0192899ccd24e54913e39aec37370c7e076eef20f1bd9cc881
|
7
|
+
data.tar.gz: 4fa79294450f004e253e37fac1da593a25520b8261ae61132a43c1eeaa76a72e82c1567b80bcede2bb2704eb99e44e0b5426042dd09117d36bfcc324b258ffd8
|
data/README.md
CHANGED
@@ -25,6 +25,8 @@ is made possible by the amazing Rouge library.
|
|
25
25
|
$ synful winr/bin/winr censive/lib/censive.rb
|
26
26
|
```
|
27
27
|
|
28
|
+
<img src="https://user-images.githubusercontent.com/142875/219864590-482cb060-465c-4fbb-9fe0-3de34dea703e.png" width="900">
|
29
|
+
|
28
30
|
A more complicated example is:
|
29
31
|
|
30
32
|
```
|
@@ -36,7 +38,7 @@ exclude all files with the `.spec` or `.ru` extensions. It will also
|
|
36
38
|
include files from the `lib/` and `test/` directories as well as the
|
37
39
|
`/tmp/example.rb` file. Even though the `test/boring-results.txt` file
|
38
40
|
should be rendered, we have disabled it via the `-` (minus sign or dash)
|
39
|
-
in front of
|
41
|
+
in front of its filename. Note that to use this type of negation, we
|
40
42
|
need to precede it with a "double-dash" `--` to tell `synful` that we
|
41
43
|
are done with the normal command options.
|
42
44
|
|
data/bin/synful
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# synful - Ruby utility that shows syntax highlighted code in your browser
|
5
5
|
#
|
6
6
|
# Author: Steve Shreeve (steve.shreeve@gmail.com)
|
7
|
-
# Date: Feb
|
7
|
+
# Date: Feb 22, 2023
|
8
8
|
#
|
9
9
|
# Thanks to Julie Evans for creating the amazing rouge library!
|
10
10
|
# ============================================================================
|
@@ -68,62 +68,67 @@ Rouge::Lexers::ERB.filenames "*.eco"
|
|
68
68
|
|
69
69
|
require "find"
|
70
70
|
require "set"
|
71
|
-
require "sinatra"
|
71
|
+
require "sinatra/base"
|
72
72
|
|
73
73
|
$stderr = $stderr.dup.reopen File.new("/dev/null", "w") # turn off logger
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
75
|
+
class Synful < Sinatra::Application
|
76
|
+
enable :inline_templates
|
77
|
+
set :server, "webrick"
|
78
|
+
|
79
|
+
get "*" do
|
80
|
+
skip, want, fore, keep, deny = [$skip, $want, $fore, $keep, $deny]
|
81
|
+
|
82
|
+
init = Time.now.to_f
|
83
|
+
|
84
|
+
@list = want.inject([]) do |list, path|
|
85
|
+
if !File.readable?(path)
|
86
|
+
warn "unreadable '#{path}'"
|
87
|
+
elsif File.directory?(path)
|
88
|
+
Find.find(path) do |path|
|
89
|
+
path.delete_prefix!("./") #!# TODO: is this working as expected?
|
90
|
+
if !File.readable?(path) || path == "."
|
91
|
+
next
|
92
|
+
elsif File.directory?(path)
|
93
|
+
Find.prune if File.basename(path).start_with?(".") or skip&.include?(path)
|
94
|
+
elsif File.file?(path)
|
95
|
+
next if skip&.include?(path)
|
96
|
+
type = path[/(?<=\.)[^.\/]+\z/].to_s.downcase
|
97
|
+
list << path if keep ? keep.include?(type) : !deny.include?(type)
|
98
|
+
else
|
99
|
+
warn "unknown '#{path}'"
|
100
|
+
end
|
98
101
|
end
|
102
|
+
elsif File.file?(path)
|
103
|
+
list << path # requested explicitly
|
99
104
|
end
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
headers "Connection" => "close"
|
119
|
-
body
|
105
|
+
list
|
106
|
+
end.sort.uniq
|
107
|
+
|
108
|
+
# show filenames
|
109
|
+
time = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
110
|
+
STDERR.puts "\n[#{time}]\n\n", @list.map {|item| " • #{item}"}
|
111
|
+
|
112
|
+
# generate content and generation time
|
113
|
+
$err = false
|
114
|
+
body = erb :page
|
115
|
+
wait = Time.now.to_f - init
|
116
|
+
STDERR.puts "\nTime elapsed: %.2f" % wait
|
117
|
+
|
118
|
+
# send response
|
119
|
+
$fore or Thread.new { sleep wait; exit! } # how can we know when the request is "done?"
|
120
|
+
headers "Connection" => "close"
|
121
|
+
body
|
122
|
+
end
|
120
123
|
end
|
121
124
|
|
122
125
|
Thread.new do
|
123
|
-
sleep 0.1 until
|
124
|
-
fork or exec "open 'http://localhost:#{
|
126
|
+
sleep 0.1 until Synful.running?
|
127
|
+
fork or exec "open 'http://localhost:#{Synful.port}/'"
|
125
128
|
end
|
126
129
|
|
130
|
+
Synful.run!
|
131
|
+
|
127
132
|
__END__
|
128
133
|
|
129
134
|
@@ layout
|
@@ -134,15 +139,28 @@ __END__
|
|
134
139
|
<title>Synful</title>
|
135
140
|
<link rel="icon" href="data:,">
|
136
141
|
<style type="text/css">
|
137
|
-
|
138
|
-
|
139
|
-
a { text-decoration: none; }
|
140
|
-
|
141
|
-
|
142
|
-
|
142
|
+
body { margin: 0; padding: 0; font-family: Verdana; font-size: 14px; }
|
143
|
+
pre { margin: 0; font-family: Consolas, Menlo, monospace; }
|
144
|
+
a { text-decoration: none; scroll-margin-top: 0.5em; }
|
145
|
+
|
146
|
+
.cap {
|
147
|
+
background: black;
|
148
|
+
color: white;
|
149
|
+
font-weight: bold;
|
150
|
+
line-height: 30px;
|
151
|
+
display: grid;
|
152
|
+
grid-template-columns: 1fr 10em;
|
153
|
+
align-items: stretch;
|
154
|
+
}
|
155
|
+
.cap > div:nth-child(1) { padding-left: 1em; }
|
156
|
+
.cap > div:nth-child(2) { display: grid; grid-template-columns: 1fr 1fr 1fr; place-content: stretch; }
|
157
|
+
.cap a { text-align: center; color: white; }
|
158
|
+
.cap a:hover { background: rgba(255,255,255,0.5); }
|
159
|
+
|
160
|
+
@media print { .cap > div:nth-child(2) { display: none; } }
|
161
|
+
|
143
162
|
li a { color: #000; }
|
144
163
|
li a:hover { text-decoration: underline; color: #666; }
|
145
|
-
pre { margin: 0; font-family: Consolas, Menlo, monospace; }
|
146
164
|
|
147
165
|
.rouge-table { padding: 0; border-collapse: collapse; }
|
148
166
|
.rouge-table td { padding: 0; vertical-align: top; }
|
@@ -225,13 +243,15 @@ __END__
|
|
225
243
|
<%= erb :toc if (count = @list.size) > 1 %><%
|
226
244
|
@list.each_with_index do |file, i|
|
227
245
|
@file = file
|
228
|
-
@prev = @list[(i - 1) % count]
|
229
246
|
@next = @list[(i + 1) % count]
|
247
|
+
@prev = @list[(i - 1) % count]
|
230
248
|
@curr = count > 1 ? "#{i + 1}) " : "" %>
|
231
249
|
<%= erb :file %><% end %>
|
232
250
|
|
233
251
|
@@ toc
|
234
|
-
<
|
252
|
+
<div class="cap">
|
253
|
+
<div><a name="top">Index</a></div>
|
254
|
+
</div>
|
235
255
|
|
236
256
|
<ul><% @list.each do |file| %>
|
237
257
|
<li><a href="#<%= file %>"><%= file %></a></li><% end %>
|
@@ -261,18 +281,20 @@ __END__
|
|
261
281
|
end
|
262
282
|
%>
|
263
283
|
|
264
|
-
<
|
265
|
-
<
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
<
|
273
|
-
|
274
|
-
|
275
|
-
|
284
|
+
<div class="cap">
|
285
|
+
<div>
|
286
|
+
<a name="<%= @file %>"><%= @curr %><%= @file %>
|
287
|
+
(<%= data.count("\n") + 1 %> lines)
|
288
|
+
<%= "[" + type.tag + "]" if type %>
|
289
|
+
<%= File.mtime(@file).strftime("on %Y-%m-%d at %-I:%M %P") %>
|
290
|
+
</a>
|
291
|
+
</div>
|
292
|
+
<div>
|
293
|
+
<a href="#<%= @next %>">↓</a>
|
294
|
+
<a href="#<%= @prev %>">↑</a>
|
295
|
+
<a href="#top">⥣</a>
|
296
|
+
</div>
|
297
|
+
</div>
|
276
298
|
|
277
299
|
<%=
|
278
300
|
if type
|
data/synful.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Shreeve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rouge
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
rubygems_version: 3.4.
|
72
|
+
rubygems_version: 3.4.7
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Ruby utility that shows syntax highlighted code in your browser
|