Commit 997e57e7 authored by Juergen Enge's avatar Juergen Enge
Browse files

external viewer included

parent a68a6a85
Pipeline #16112 passed with stages
in 3 minutes and 54 seconds
......@@ -60,6 +60,7 @@ type Config struct {
VideoViewerTemplate string
AudioViewerTemplate string
FileMap []FileMap
Viewer map[string]string
}
func LoadConfig(filepath string) Config {
......
......@@ -113,8 +113,7 @@ func main() {
log,
accesslog,
config.ErrorTemplate,
config.VideoViewerTemplate,
config.AudioViewerTemplate,
config.Viewer,
config.StaticPrefix,
config.StaticDir,
)
......@@ -127,6 +126,7 @@ func main() {
srv.AddAction(memostream.NewActionImageIIIF(srv))
srv.AddAction(memostream.NewActionVideo(srv))
srv.AddAction(memostream.NewActionAudio(srv))
srv.AddAction(memostream.NewActionExternal(srv))
srv.AddAction(memostream.NewActionMaster(srv))
go func() {
......
......@@ -13,10 +13,17 @@ jwtkey = "swordfish"
jwtalg = ["HS256", "HS384", "HS512"] # "hs256" "hs384" "hs512" "es256" "es384" "es512" "ps256" "ps384" "ps512"
resolverCacheSize = 1000
errorTemplate = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/error.gohtml" # error message for memoHandler
videoviewertemplate = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/video.gohtml"
audioviewertemplate = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/audio.gohtml"
baseurl = "http://localhost:88"
[viewer]
image = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/iiif-image.gohtml"
video = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/video.gohtml"
audio = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/audio.gohtml"
srfaudio = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/player--srg.gohtml"
srfvideo = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/player--srg.gohtml"
vimeo = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/video--vimeo.gohtml"
youtube = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/template/video--youtube.gohtml"
[[filemap]]
alias = "c"
folder = "C:/"
......
......@@ -82,6 +82,6 @@ func (aa *ActionAudio) viewer(w http.ResponseWriter, req *http.Request, me *Medi
BaseUrl: aa.ms.baseUrl,
StaticPrefix: aa.ms.staticPrefix,
}
aa.ms.audioViewerTemplate.Execute(w, data)
aa.ms.viewerTemplates["audio"].Execute(w, data)
return true, nil
}
package memostream
import (
"fmt"
"net/http"
"regexp"
)
// image Action using IIIF server for image manipulation
type ActionExternal struct {
ms *memoServer
}
func NewActionExternal(ms *memoServer) *ActionExternal {
ae := &ActionExternal{ms: ms}
return ae
}
func (ae *ActionExternal) GetType() []string {
return []string{"srfaudio", "srfvideo", "youtube", "vimeo"}
}
func (ae *ActionExternal) Do(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error) {
switch action {
case "viewer":
return ae.viewer(w, req, me, action, params...)
default:
}
return false, nil
}
var extMatches = map[string]*regexp.Regexp{
"srfvideo": regexp.MustCompile("^.+(urn:srf:video:[-0-9a-f]+)$"),
"srfaudio": regexp.MustCompile("^.+(urn:srf:audio:[-0-9a-f]+)$"),
"youtube": regexp.MustCompile("^http.+/([^/]+)$"),
"vimeo": regexp.MustCompile("^http.+/([^/]+)$"), // https://vimeo.com/289691364
}
func (ae *ActionExternal) viewer(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error) {
type vData struct {
Id string
BackgroundColor string
BaseUrl string
StaticPrefix string
}
data := vData{
BackgroundColor: "#000000",
BaseUrl: ae.ms.baseUrl,
StaticPrefix: ae.ms.staticPrefix,
}
rexp, ok := extMatches[me.Type]
if !ok {
return false, fmt.Errorf("no id regexp for type %s - %v", me.Type, me.Signature)
}
matches := rexp.FindStringSubmatch(me.URI.String())
if matches != nil {
data.Id = matches[1]
}
tpl, ok := ae.ms.viewerTemplates[me.Type]
if !ok {
return false, fmt.Errorf("no template for type %s - %v", me.Type, me.Signature)
}
tpl.Execute(w, data)
return true, nil
}
......@@ -65,7 +65,10 @@ func (iai *ActionImageIIIF) iiif(w http.ResponseWriter, req *http.Request, me *M
func (iai *ActionImageIIIF) viewer(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error) {
type vData struct {
BackgroundColor string
Id string
TileSource string
BaseUrl string
StaticPrefix string
}
var err error
newtoken := ""
......@@ -86,9 +89,12 @@ func (iai *ActionImageIIIF) viewer(w http.ResponseWriter, req *http.Request, me
}
data := vData{
BackgroundColor: "#000000",
Id: me.Signature,
TileSource: tileSource,
BaseUrl: iai.ms.baseUrl,
StaticPrefix: iai.ms.staticPrefix,
}
iai.ms.iiifViewerTemplate.Execute(w, data)
iai.ms.viewerTemplates["image"].Execute(w, data)
return true, nil
}
......
......@@ -82,6 +82,6 @@ func (av *ActionVideo) viewer(w http.ResponseWriter, req *http.Request, me *Medi
BaseUrl: av.ms.baseUrl,
StaticPrefix: av.ms.staticPrefix,
}
av.ms.videoViewerTemplate.Execute(w, data)
av.ms.viewerTemplates["video"].Execute(w, data)
return true, nil
}
......@@ -42,9 +42,7 @@ type memoServer struct {
iiifBase string
iiifUrl string
iiifJwtSubPrefix string
iiifViewerTemplate *template.Template
videoViewerTemplate *template.Template
audioViewerTemplate *template.Template
viewerTemplates map[string]*template.Template
resolver *ResolverCache
host string
port string
......@@ -73,9 +71,8 @@ func NewServer(
jwtAlg []string,
log *logging.Logger,
accesslog io.Writer,
errorTemplate,
videoViewerTemplate,
audioViewerTemplate,
errorTemplate string,
viewer map[string]string,
staticPrefix,
staticDir string) (*memoServer, error) {
urlPrefix = "/" + strings.Trim(urlPrefix, "/") + "/"
......@@ -85,17 +82,13 @@ func NewServer(
//log.Panicf("cannot split address %s: %v", addr, err)
return nil, emperror.Wrapf(err, "cannot split address %s", addr)
}
iiifTpl, err := template.ParseFiles(iiifViewerTemplate)
if err != nil {
return nil, emperror.Wrapf(err, "cannot parse iiif template %s", iiifViewerTemplate)
}
videoTpl, err := template.ParseFiles(videoViewerTemplate)
vs := make(map[string]*template.Template)
for key, file := range viewer {
vs[key], err = template.ParseFiles(file)
if err != nil {
return nil, emperror.Wrapf(err, "cannot parse videoViewer template %s", videoViewerTemplate)
return nil, emperror.Wrapf(err, "cannot parse %s template %s", key, file)
}
audioTpl, err := template.ParseFiles(audioViewerTemplate)
if err != nil {
return nil, emperror.Wrapf(err, "cannot parse audioViewer template %s", audioViewerTemplate)
}
errorTpl, err := template.ParseFiles(errorTemplate)
if err != nil {
......@@ -113,9 +106,7 @@ func NewServer(
iiifBase: iiifBase,
iiifUrl: iiifUrl,
iiifJwtSubPrefix: iiifJwtSubPrefix,
iiifViewerTemplate: iiifTpl,
videoViewerTemplate: videoTpl,
audioViewerTemplate: audioTpl,
viewerTemplates: vs,
host: host,
port: port,
jwtSecret: jwtSecret,
......
......@@ -45,3 +45,42 @@ body {
height: 100%;
overflow: hidden;
}
/* Mobile */
@media only screen
and (min-device-width: 320px)
and (max-device-width: 767px) {
.openseadragon-viewer {
height: 250px;
width: 300px;
}
}
/* Tablet */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1023px) {
.openseadragon-viewer {
height: 300px;
width: 400px;
}
}
/* Tablet Landscape */
@media only screen
and (min-device-width: 1024px)
and (max-device-width: 1279px) {
.openseadragon-viewer {
height: 400px;
width: 500px;
}
}
/* Desktop */
@media only screen
and (min-device-width: 1280px) {
.openseadragon-viewer {
height: 500px;
width: 700px;
}
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Media Player</title>
<link rel="stylesheet" type="text/css" href="{{.BaseUrl}}{{.StaticPrefix}}css/style.css">
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/jquery.min.js"></script>
<script src="{{.BaseUrl}}{{.StaticPrefix}}openseadragon-bin-2.4.2/openseadragon.js"></script>
<!-- <script src="{{.BaseUrl}}{{.StaticPrefix}}js/openseadragon-viewer.js"></script> -->
<script>
$(document).ready(function () {
$('.openseadragon-viewer').each(function () {
let openseadragon = $(this);
$.ajax({
type: 'GET',
url: '{{.TileSource}}',
success: function (data) {
let options = {
id: openseadragon.attr('data-image-id'),
tileSources: data,
prefixUrl: `{{.BaseUrl}}{{.StaticPrefix}}openseadragon-bin-2.4.2/images/`
};
let viewer = new OpenSeadragon.Viewer(options);
}
});
});
});
</script>
</head>
<body>
<div class="openseadragon-viewer" id="{{.Id}}" data-image-id="{{.Id}}"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Media Player</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery.min.js"></script>
<script src="openseadragon-bin-2.4.2/openseadragon.js"></script>
<script src="js/openseadragon-viewer.js"></script>
</head>
<body>
<div class="openseadragon-viewer" id="BAZ-B_MEI-MEI_49905a-1" data-image-id="BAZ-B_MEI-MEI_49905a-1"></div>
</body>
</html>
......@@ -3,15 +3,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Media Player</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery.min.js"></script>
<script src="js/srg-player-api.min.js"></script>
<script src="js/player--srg.js"></script>
<link rel="stylesheet" type="text/css" href="{{.BaseUrl}}{{.StaticPrefix}}css/style.css">
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/jquery.min.js"></script>
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/srg-player-api.min.js"></script>
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/player--srg.js"></script>
</head>
<body>
<!-- SRG -->
<div id="srg-player" class="player player--srg" data-urn-src="urn:srf:video:3832c22e-7a7a-4b21-be19-9916e3a9bda7"></div>
<div id="srg-player" class="player player--srg" data-urn-src="{{.Id}}"></div>
</body>
</html>
......@@ -3,16 +3,16 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Media Player</title>
<link rel="stylesheet" type="text/css" href="css/plyr.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/plyr.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/player.js"></script>
<link rel="stylesheet" type="text/css" href="{{.BaseUrl}}{{.StaticPrefix}}css/plyr.css">
<link rel="stylesheet" type="text/css" href="{{.BaseUrl}}{{.StaticPrefix}}css/style.css">
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/plyr.js"></script>
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/jquery.min.js"></script>
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/player.js"></script>
</head>
<body>
<!-- VIMEO -->
<div class="player" data-plyr-provider="vimeo" data-plyr-embed-id="259411563"></div>
<div class="player" data-plyr-provider="vimeo" data-plyr-embed-id="{{.Id}}"></div>
</body>
</html>
......@@ -3,16 +3,16 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Media Player</title>
<link rel="stylesheet" type="text/css" href="css/plyr.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/plyr.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/player.js"></script>
<link rel="stylesheet" type="text/css" href="{{.BaseUrl}}{{.StaticPrefix}}css/plyr.css">
<link rel="stylesheet" type="text/css" href="{{.BaseUrl}}{{.StaticPrefix}}css/style.css">
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/plyr.js"></script>
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/jquery.min.js"></script>
<script src="{{.BaseUrl}}{{.StaticPrefix}}js/player.js"></script>
</head>
<body>
<!-- YOUTUBE -->
<div class="player" data-plyr-provider="youtube" data-plyr-embed-id="kY1F_Y0GniQ"></div>
<div class="player" data-plyr-provider="youtube" data-plyr-embed-id="{{.Id}}"></div>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment