Browse Source

Merge branch 'release/0.1.0'

master
PrivateGER 3 years ago
parent
commit
1de840f1c9
No known key found for this signature in database GPG Key ID: B9918E382ED08059
  1. 2
      .gitattributes
  2. 3
      PageHandlers/Static.go
  3. 50
      PageHandlers/Templates.go
  4. 1
      PageHandlers/static/video-js.min.css
  5. 27
      PageHandlers/static/video.min.js
  6. 8
      PageHandlers/static/videojs-seek-buttons.min.css
  7. 2
      PageHandlers/static/videojs-seek-buttons.min.js
  8. 8
      PageHandlers/templates/view.html
  9. 15
      main.go

2
.gitattributes

@ -0,0 +1,2 @@
*.min.js -text -diff -delta
*.min.css -text -diff -delta

3
PageHandlers/Static.go

@ -0,0 +1,3 @@
package PageHandlers

50
PageHandlers/Templates.go

@ -1,58 +1,20 @@
package PageHandlers
import (
"embed"
_ "embed"
"fmt"
"html/template"
)
//go:embed templates/index.html
var indexTmplSource string
//go:embed templates/view.html
var viewTmplSource string
//go:embed templates/search.html
var searchTmplSource string
//go:embed templates/base.html
var baseTmplSource string
//go:embed templates
var templateFS embed.FS
var tmpl map[string]*template.Template
func init() {
tmpl = make(map[string]*template.Template)
var err error
tmpl["index.html"] = template.New("index.html")
tmpl["index.html"], err = tmpl["index.html"].Parse(baseTmplSource)
if err != nil {
fmt.Println(err)
}
tmpl["index.html"], err = tmpl["index.html"].Parse(indexTmplSource)
if err != nil {
fmt.Println(err)
}
fmt.Println(tmpl["index.html"].Name())
tmpl["search.html"] = template.New("search.html")
tmpl["search.html"], err = tmpl["search.html"].Parse(searchTmplSource)
if err != nil {
fmt.Println(err)
}
tmpl["search.html"], err = tmpl["search.html"].Parse(baseTmplSource)
if err != nil {
fmt.Println(err)
}
tmpl["view.html"] = template.New("view.html")
tmpl["view.html"], err = tmpl["view.html"].Parse(viewTmplSource)
if err != nil {
fmt.Println(err)
}
tmpl["view.html"], err = tmpl["view.html"].Parse(baseTmplSource)
if err != nil {
fmt.Println(err)
}
tmpl["index.html"] = template.Must(template.ParseFS(templateFS, "templates/index.html", "templates/base.html"))
tmpl["search.html"] = template.Must(template.ParseFS(templateFS, "templates/search.html", "templates/base.html"))
tmpl["view.html"] = template.Must(template.ParseFS(templateFS, "templates/view.html", "templates/base.html"))
}

1
PageHandlers/static/video-js.min.css

File diff suppressed because one or more lines are too long

27
PageHandlers/static/video.min.js

File diff suppressed because one or more lines are too long

8
PageHandlers/static/videojs-seek-buttons.min.css

@ -0,0 +1,8 @@
/**
* Skipped minification because the original files appears to be already minified.
* Original file: /npm/videojs-seek-buttons@2.2.0/dist/videojs-seek-buttons.css
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
/*! @name videojs-seek-buttons @version 2.2.0 @license Apache-2.0 */
.video-js .vjs-seek-button{font-family:'VideoJS';cursor:pointer;font-weight:400;font-style:normal}.video-js .vjs-seek-button.skip-back::before,.video-js.vjs-v6 .vjs-seek-button.skip-back .vjs-icon-placeholder::before,.video-js.vjs-v7 .vjs-seek-button.skip-back .vjs-icon-placeholder::before{transform:rotate(-45deg);-ms-transform:rotate(-45deg);-webkit-transform:rotate(-45deg);content:'\f116'}.video-js .vjs-seek-button.skip-forward::before{transform:rotateY(180deg) rotate(-45deg);-ms-transform:rotateY(180deg) rotate(-45deg);-webkit-transform:rotateY(180deg) rotate(-45deg);content:'\f116'}.video-js.vjs-v6 .vjs-seek-button.skip-back::before,.video-js.vjs-v6 .vjs-seek-button.skip-forward::before,.video-js.vjs-v7 .vjs-seek-button.skip-back::before,.video-js.vjs-v7 .vjs-seek-button.skip-forward::before{content:none}.video-js.vjs-v6 .vjs-seek-button.skip-forward .vjs-icon-placeholder::before,.video-js.vjs-v7 .vjs-seek-button.skip-forward .vjs-icon-placeholder::before{transform:scale(-1,1) rotate(-45deg);-ms-transform:scale(-1,1) rotate(-45deg);-webkit-transform:scale(-1,1) rotate(-45deg);content:'\f116'}

2
PageHandlers/static/videojs-seek-buttons.min.js

@ -0,0 +1,2 @@
/*! @name videojs-seek-buttons @version 2.2.0 @license Apache-2.0 */
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).videojsSeekButtons=o(e.videojs)}(this,(function(e){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=o(e);function n(e,o,t){return e(t={path:o,exports:{},require:function(e,o){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==o&&t.path)}},t.exports),t.exports}var r=n((function(e){function o(t,n){return e.exports=o=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},e.exports.default=e.exports,e.exports.__esModule=!0,o(t,n)}e.exports=o,e.exports.default=e.exports,e.exports.__esModule=!0})),s=n((function(e){e.exports=function(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,r(e,o)},e.exports.default=e.exports,e.exports.__esModule=!0})),i=t.default.getComponent("Button"),c={forwardIndex:1,backIndex:1},d=t.default.registerPlugin||t.default.plugin,u=function(e){var o=this;this.ready((function(){!function(e,o){e.addClass("vjs-seek-buttons"),o.forward&&o.forward>0&&(e.controlBar.seekForward=e.controlBar.addChild("seekButton",{direction:"forward",seconds:o.forward},o.forwardIndex)),o.back&&o.back>0&&(e.controlBar.seekBack=e.controlBar.addChild("seekButton",{direction:"back",seconds:o.back},o.backIndex))}(o,t.default.mergeOptions(c,e))}))};u.VERSION="2.2.0";var a=function(e){function o(o,t){var n;return"forward"===(n=e.call(this,o,t)||this).options_.direction?n.controlText(n.localize("Seek forward {{seconds}} seconds").replace("{{seconds}}",n.options_.seconds)):"back"===n.options_.direction&&n.controlText(n.localize("Seek back {{seconds}} seconds").replace("{{seconds}}",n.options_.seconds)),n}s(o,e);var t=o.prototype;return t.buildCSSClass=function(){return"vjs-seek-button skip-"+this.options_.direction+" skip-"+this.options_.seconds+" "+e.prototype.buildCSSClass.call(this)},t.handleClick=function(){var e=this.player_.currentTime();"forward"===this.options_.direction?this.player_.currentTime(e+this.options_.seconds):"back"===this.options_.direction&&this.player_.currentTime(e-this.options_.seconds)},o}(i);return t.default.registerComponent("SeekButton",a),d("seekButtons",u),u}));

8
PageHandlers/templates/view.html

@ -1,7 +1,7 @@
{{define "head"}}
<title>{{.Title}} | {{.Id}}</title>
<link href="https://vjs.zencdn.net/7.15.4/video-js.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/videojs-seek-buttons/dist/videojs-seek-buttons.css" rel="stylesheet">
<link href="/static/video-js.min.css" rel="stylesheet" />
<link href="/static/videojs-seek-buttons.min.css" rel="stylesheet">
<style>
</style>
@ -71,8 +71,8 @@
</div>
<br />
<script src="https://vjs.zencdn.net/7.15.4/video.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/videojs-seek-buttons/dist/videojs-seek-buttons.min.js"></script>
<script src="/static/video.min.js"></script>
<script src="/static/videojs-seek-buttons.min.js"></script>
<script>
var player = videojs('player');

15
main.go

@ -1,9 +1,11 @@
package main
import (
"embed"
_ "embed"
"flag"
"fmt"
"io/fs"
"net/http"
"os"
"strconv"
@ -13,6 +15,9 @@ import (
"ytdlp-viewer/PageHandlers"
)
//go:embed PageHandlers/static
var staticEmbedFS embed.FS
func main() {
var path string
flag.StringVar(&path, "path", "./", "the full path to the ytdlp archive")
@ -64,9 +69,17 @@ func main() {
fmt.Println(time.Now().String(),request.URL)
PageHandlers.View(writer, request, &FL, path)
})
subFS, err := fs.Sub(staticEmbedFS, "PageHandlers/static")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(subFS))))
http.Handle("/videos/", http.StripPrefix("/videos/", http.FileServer(http.Dir(path))))
err := http.ListenAndServe(":" + strconv.Itoa(port), nil)
err = http.ListenAndServe(":" + strconv.Itoa(port), nil)
if err != nil {
fmt.Println(err)
os.Exit(1)

Loading…
Cancel
Save