hiiro 0.1.24 → 0.1.26
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/bin/g-pr +327 -0
- data/bin/h-branch +18 -0
- data/bin/h-dot +35 -0
- data/bin/h-dotfiles +42 -0
- data/bin/h-home +62 -0
- data/bin/h-html +380 -0
- data/bin/h-link +243 -125
- data/bin/h-mic +93 -0
- data/bin/h-note +119 -0
- data/bin/h-plugin +1 -1
- data/bin/h-pr +72 -2
- data/bin/h-pr-monitor +3 -0
- data/bin/h-pr-watch +3 -0
- data/bin/h-project +173 -0
- data/bin/h-runtask +79 -0
- data/bin/h-serve +6 -0
- data/bin/h-session +21 -1
- data/bin/h-sha +10 -0
- data/bin/h-subtask +2 -1
- data/bin/h-task +81 -12
- data/bin/h-video +2 -1
- data/bin/h-vim +63 -0
- data/lib/hiiro/history.rb +1 -3
- data/lib/hiiro/version.rb +1 -1
- data/script/sync +107 -0
- metadata +17 -2
data/bin/h-html
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "hiiro"
|
|
3
|
+
|
|
4
|
+
o = Hiiro.init(*ARGV)
|
|
5
|
+
o.add_subcmd(:vids) { |outfile, *args|
|
|
6
|
+
outfile = 'index.html' if outfile.nil?
|
|
7
|
+
|
|
8
|
+
hash = Digest::SHA1.hexdigest(Dir.pwd)
|
|
9
|
+
puts hash: hash
|
|
10
|
+
|
|
11
|
+
videos = Dir.glob('*.mp4').map { |vid|
|
|
12
|
+
next if File.directory?(vid)
|
|
13
|
+
|
|
14
|
+
vid.inspect
|
|
15
|
+
}.compact
|
|
16
|
+
|
|
17
|
+
puts video_count: videos.count
|
|
18
|
+
|
|
19
|
+
videos = videos.join(",\n")
|
|
20
|
+
|
|
21
|
+
template = <<~TEMPLATE
|
|
22
|
+
<html>
|
|
23
|
+
<head>
|
|
24
|
+
<style>
|
|
25
|
+
/* a, p, video {
|
|
26
|
+
margin-top: 20px;
|
|
27
|
+
} */
|
|
28
|
+
select, textarea {
|
|
29
|
+
margin-top: 20px;
|
|
30
|
+
width: 80%;
|
|
31
|
+
display: block;
|
|
32
|
+
}
|
|
33
|
+
.flex_links {
|
|
34
|
+
display: flex;
|
|
35
|
+
gap: 70px;
|
|
36
|
+
margin-top: 38px;
|
|
37
|
+
margin-bottom: 38px;
|
|
38
|
+
}
|
|
39
|
+
* {
|
|
40
|
+
font-size: 16pt;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
a {
|
|
44
|
+
font-size: 26pt;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
47
|
+
<script type="text/javascript">
|
|
48
|
+
var favs = localStorage.getItem('favs-#{hash}') || '[]';
|
|
49
|
+
console.log({ favs: favs });
|
|
50
|
+
|
|
51
|
+
var videos = [
|
|
52
|
+
#{videos.gsub(/\n/, "\n ")}
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
function create_links() {
|
|
56
|
+
var container = document.getElementById('links');
|
|
57
|
+
var player = document.getElementById('player');
|
|
58
|
+
|
|
59
|
+
for(var x=0; x < videos.length; x++) {
|
|
60
|
+
var link = document.createElement('option');
|
|
61
|
+
link.value = x;
|
|
62
|
+
link.innerText = videos[x];
|
|
63
|
+
|
|
64
|
+
container.appendChild(link);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function load_video() {
|
|
69
|
+
var player = document.getElementById('player');
|
|
70
|
+
var src = document.getElementById('player_src');
|
|
71
|
+
var links = document.getElementById('links');
|
|
72
|
+
var idx = links.value;
|
|
73
|
+
var id = parseInt(idx);
|
|
74
|
+
src.src = videos[id];
|
|
75
|
+
player.load();
|
|
76
|
+
player.currentTime = 5;
|
|
77
|
+
player.play();
|
|
78
|
+
load_stats();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function save_video() {
|
|
82
|
+
var fav_videos = localStorage.getItem('favs-#{hash}') || '[]';
|
|
83
|
+
var json = JSON.parse(fav_videos);
|
|
84
|
+
console.log({ favs: fav_videos, json: json });
|
|
85
|
+
|
|
86
|
+
var vid = document.getElementById('links').value;
|
|
87
|
+
vid = videos[parseInt(vid)];
|
|
88
|
+
|
|
89
|
+
if(vid !== undefined) {
|
|
90
|
+
json.push(vid);
|
|
91
|
+
|
|
92
|
+
localStorage.setItem('favs-#{hash}', JSON.stringify(json));
|
|
93
|
+
fav_videos = localStorage.getItem('favs-#{hash}') || '[]';
|
|
94
|
+
json = JSON.parse(fav_videos);
|
|
95
|
+
console.log({ favs: fav_videos, json: json });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
display_favs();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function rm_fav() {
|
|
102
|
+
var fav_videos = localStorage.getItem('favs-#{hash}') || '[]';
|
|
103
|
+
var json = JSON.parse(fav_videos);
|
|
104
|
+
console.log({ favs: fav_videos, json: json });
|
|
105
|
+
|
|
106
|
+
var sel = document.getElementById('favs_select');
|
|
107
|
+
var current_index = sel.selectedIndex;
|
|
108
|
+
vid = json[current_index];
|
|
109
|
+
|
|
110
|
+
json.splice(current_index, 1)
|
|
111
|
+
|
|
112
|
+
if(vid !== undefined) {
|
|
113
|
+
localStorage.setItem('favs-#{hash}', JSON.stringify(json));
|
|
114
|
+
fav_videos = localStorage.getItem('favs-#{hash}') || '[]';
|
|
115
|
+
json = JSON.parse(fav_videos);
|
|
116
|
+
console.log({ favs: fav_videos, json: json });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
display_favs();
|
|
120
|
+
|
|
121
|
+
if(sel.length == 0) return;
|
|
122
|
+
|
|
123
|
+
if(current_index >= sel.length) {
|
|
124
|
+
current_index = sel.length - 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
sel.selectedIndex = current_index;
|
|
128
|
+
load_fav();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function load_fav() {
|
|
132
|
+
var sel = document.getElementById('favs_select');
|
|
133
|
+
|
|
134
|
+
var player = document.getElementById('player');
|
|
135
|
+
var src = document.getElementById('player_src');
|
|
136
|
+
src.src = sel.value;
|
|
137
|
+
player.load();
|
|
138
|
+
player.currentTime = 5;
|
|
139
|
+
player.play();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function prev_fav() {
|
|
143
|
+
var sel = document.getElementById('favs_select');
|
|
144
|
+
if(sel.selectedIndex == 0) return;
|
|
145
|
+
sel.selectedIndex = sel.selectedIndex - 1;
|
|
146
|
+
load_fav();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function next_fav() {
|
|
150
|
+
var sel = document.getElementById('favs_select');
|
|
151
|
+
if(sel.selectedIndex >= sel.length - 1) return;
|
|
152
|
+
sel.selectedIndex = sel.selectedIndex + 1;
|
|
153
|
+
load_fav();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function export_favs() {
|
|
157
|
+
var text = document.getElementById('export_favs');
|
|
158
|
+
var data = localStorage.getItem('favs-#{hash}') || '[]';
|
|
159
|
+
var list = JSON.parse(data);
|
|
160
|
+
text.innerHTML = list.join("\\n");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function display_favs() {
|
|
164
|
+
var sel = document.getElementById('favs_select');
|
|
165
|
+
sel.innerHTML = '';
|
|
166
|
+
|
|
167
|
+
var data = localStorage.getItem('favs-#{hash}') || '[]';
|
|
168
|
+
var favs = JSON.parse(data);
|
|
169
|
+
|
|
170
|
+
for(var x=0; x<favs.length; x++) {
|
|
171
|
+
var opt = document.createElement('option');
|
|
172
|
+
opt.value = favs[x];
|
|
173
|
+
opt.innerText = favs[x];
|
|
174
|
+
sel.appendChild(opt);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function clear_last() {
|
|
179
|
+
localStorage.removeItem('last_vid-#{hash}');
|
|
180
|
+
|
|
181
|
+
show_last();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function mark_last() {
|
|
185
|
+
var sel = document.getElementById('links');
|
|
186
|
+
var idx = sel.value;
|
|
187
|
+
var id = parseInt(idx);
|
|
188
|
+
|
|
189
|
+
localStorage.setItem('last_vid-#{hash}', videos[id]);
|
|
190
|
+
|
|
191
|
+
show_last();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function show_last() {
|
|
195
|
+
var links = document.getElementById('links');
|
|
196
|
+
var div = document.getElementById('last_vid');
|
|
197
|
+
var last_vid = localStorage.getItem('last_vid-#{hash}') || 'no last vid';
|
|
198
|
+
div.innerHTML = last_vid;
|
|
199
|
+
var found = false;
|
|
200
|
+
if(last_vid != 'no last vid') {
|
|
201
|
+
for(var x=0; x<videos.length; x++) {
|
|
202
|
+
if(videos[x] == last_vid) {
|
|
203
|
+
found = true;
|
|
204
|
+
links.selectedIndex = x;
|
|
205
|
+
load_video();
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if(found == false) {
|
|
211
|
+
links.selectedIndex = 0;
|
|
212
|
+
load_stats();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function prev_vid() {
|
|
217
|
+
var sel = document.getElementById('links');
|
|
218
|
+
if(sel.selectedIndex == 0) return;
|
|
219
|
+
sel.selectedIndex = sel.selectedIndex - 1;
|
|
220
|
+
load_video();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function next_vid() {
|
|
224
|
+
var sel = document.getElementById('links');
|
|
225
|
+
if(sel.selectedIndex >= sel.length - 1) return;
|
|
226
|
+
sel.selectedIndex = sel.selectedIndex + 1;
|
|
227
|
+
load_video();
|
|
228
|
+
mark_last();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function load_stats() {
|
|
232
|
+
var sel = document.getElementById('links');
|
|
233
|
+
var cur = document.getElementById('current_idx');
|
|
234
|
+
var total = document.getElementById('total_links');
|
|
235
|
+
|
|
236
|
+
cur.innerHTML = sel.selectedIndex + 1;
|
|
237
|
+
total.innerHTML = sel.length;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function trash() {
|
|
241
|
+
var sel = document.getElementById('links');
|
|
242
|
+
var idx = sel.selectedIndex;
|
|
243
|
+
|
|
244
|
+
var container = document.getElementById('trash');
|
|
245
|
+
var link = document.createElement('option');
|
|
246
|
+
link.value = idx;
|
|
247
|
+
link.innerText = videos[idx];
|
|
248
|
+
|
|
249
|
+
container.appendChild(link);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function clear_trash() {
|
|
253
|
+
var container = document.getElementById('trash');
|
|
254
|
+
container.innerHTML = '';
|
|
255
|
+
}
|
|
256
|
+
</script>
|
|
257
|
+
</head>
|
|
258
|
+
<body>
|
|
259
|
+
:r!ls *.mp4 | sed 's@.*@<video height="480" controls><source src="&" type="video/mp4"></video>@'
|
|
260
|
+
<hr/>
|
|
261
|
+
|
|
262
|
+
<div id="last_vid">not loaded</div>
|
|
263
|
+
<div class="flex_links">
|
|
264
|
+
<a href="javascript:void(0);" onclick="mark_last()" />Mark Last</a>
|
|
265
|
+
<a href="javascript:void(0);" onclick="clear_last()" />Clear Last</a>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<div id="links_stats">
|
|
269
|
+
<span id="current_idx">0</span> /
|
|
270
|
+
<span id="total_links">99999</span>
|
|
271
|
+
</div>
|
|
272
|
+
|
|
273
|
+
<select id="links" size="5" onchange="load_stats(); load_video();">
|
|
274
|
+
</select>
|
|
275
|
+
|
|
276
|
+
<div class="flex_links">
|
|
277
|
+
<a href="javascript:void(0);" onclick="load_video()" />Load</a>
|
|
278
|
+
<a href="javascript:void(0);" onclick="save_video()" />Save</a>
|
|
279
|
+
<a href="javascript:void(0);" onclick="prev_vid()">Prev Vid</a>
|
|
280
|
+
<a href="javascript:void(0);" onclick="next_vid()">Next Vid</a>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<select id="favs_select" size="5" onchange="load_fav();">
|
|
284
|
+
</select>
|
|
285
|
+
|
|
286
|
+
<div class="flex_links">
|
|
287
|
+
<a href="javascript:void(0);" onclick="rm_fav()" />Remove Fav</a>
|
|
288
|
+
<a href="javascript:void(0);" onclick="load_fav()" />Load Fav</a>
|
|
289
|
+
<a href="javascript:void(0);" onclick="prev_fav()" />Prev Fav</a>
|
|
290
|
+
<a href="javascript:void(0);" onclick="next_fav()" />Next Fav</a>
|
|
291
|
+
</div>
|
|
292
|
+
|
|
293
|
+
<select id="trash" size="5">
|
|
294
|
+
</select>
|
|
295
|
+
|
|
296
|
+
<div class="flex_links">
|
|
297
|
+
<a href="javascript:void(0);" onclick="trash()" />Trash</a>
|
|
298
|
+
<a href="javascript:void(0);" onclick="clear_trash()" />Clear</a>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
<textarea id="export_favs" rows="5" cols="40">
|
|
302
|
+
</textarea>
|
|
303
|
+
|
|
304
|
+
<div class="flex_links">
|
|
305
|
+
<a href="javascript:void(0);" onclick="localStorage.removeItem('favs-#{hash}'); display_favs();" />Clear Favs</a>
|
|
306
|
+
<a href="javascript:void(0);" onclick="export_favs()" />Export Favs</a>
|
|
307
|
+
</div>
|
|
308
|
+
|
|
309
|
+
<div id="player_wrapper">
|
|
310
|
+
<video id="player" height="480" controls>
|
|
311
|
+
<source id="player_src" src="">
|
|
312
|
+
</video>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<script type="text/javascript">
|
|
316
|
+
create_links();
|
|
317
|
+
display_favs();
|
|
318
|
+
show_last();
|
|
319
|
+
load_stats();
|
|
320
|
+
</script>
|
|
321
|
+
</body>
|
|
322
|
+
</html>
|
|
323
|
+
TEMPLATE
|
|
324
|
+
|
|
325
|
+
size = IO.write(outfile, template)
|
|
326
|
+
|
|
327
|
+
puts size: size
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
o.add_subcmd(:videos) { |outfile, *args|
|
|
331
|
+
puts :in_html_videos
|
|
332
|
+
|
|
333
|
+
if outfile&.match?(/^-/)
|
|
334
|
+
args = [outfile, *args]
|
|
335
|
+
outfile = nil
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
outfile = 'index.html' if outfile.nil?
|
|
339
|
+
|
|
340
|
+
if File.exist?(outfile) && args.none?{|a| a.match?(/-f/) }
|
|
341
|
+
puts 'File Exists: use -f flag to force'
|
|
342
|
+
else
|
|
343
|
+
tags = Dir.glob('**/*').map { |vid|
|
|
344
|
+
next if File.directory?(vid)
|
|
345
|
+
|
|
346
|
+
file_cmd = format('file --mime-type "%s"', vid)
|
|
347
|
+
result = %x[ #{file_cmd} ]
|
|
348
|
+
next unless result.match?(/video\//)
|
|
349
|
+
|
|
350
|
+
format('<p>%s</p><video height="480" controls><source src="%s"></video>', vid, vid)
|
|
351
|
+
}.compact
|
|
352
|
+
|
|
353
|
+
template = <<~TEMPLATE
|
|
354
|
+
<html>
|
|
355
|
+
<head>
|
|
356
|
+
<style>
|
|
357
|
+
a, p, video {
|
|
358
|
+
display: block;
|
|
359
|
+
margin-top: 20px;
|
|
360
|
+
}
|
|
361
|
+
</style>
|
|
362
|
+
</head>
|
|
363
|
+
<body>
|
|
364
|
+
:r!ls *.mp4 | sed 's@.*@<video height="480" controls><source src="&" type="video/mp4"></video>@'
|
|
365
|
+
<hr/>
|
|
366
|
+
%s
|
|
367
|
+
</body>
|
|
368
|
+
</html>
|
|
369
|
+
TEMPLATE
|
|
370
|
+
|
|
371
|
+
contents = format(template, tags.join("\n"))
|
|
372
|
+
bytes = IO.write(outfile, contents)
|
|
373
|
+
|
|
374
|
+
printf("video count: %d\n", tags.count)
|
|
375
|
+
printf("bytes_written: %d\n", bytes)
|
|
376
|
+
end
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
o.run
|
|
380
|
+
|