Expose 'install-dompurify' and 'install-colorbox'

This commit exposes the install dompurify and install colorbox
javascript libraries via the browser.
This commit is contained in:
Tom Wiesing 2023-12-04 12:21:17 +01:00
parent b2231f6307
commit 0ab8d3a4e4
No known key found for this signature in database
9 changed files with 179 additions and 88 deletions

View file

@ -0,0 +1,57 @@
package actions
import (
"context"
"io"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth/scopes"
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/tkw1536/pkglib/stream"
)
// installing additional javascript libraries
type InstallColorboxJS struct {
component.Base
}
var (
_ WebsocketInstanceAction = (*InstallColorboxJS)(nil)
)
func (*InstallColorboxJS) Action() InstanceAction {
return InstanceAction{
Action: Action{
Name: "install-colorbox-js",
Scope: scopes.ScopeUserAdmin,
NumParams: 0,
},
}
}
func (*InstallColorboxJS) Act(ctx context.Context, instance *wisski.WissKI, in io.Reader, out io.Writer, params ...string) error {
return instance.Barrel().Shell(ctx, stream.NewIOStream(out, out, nil), "/runtime/install_colorbox.sh")
}
type InstallDompurifyJS struct {
component.Base
}
var (
_ WebsocketInstanceAction = (*InstallDompurifyJS)(nil)
)
func (*InstallDompurifyJS) Action() InstanceAction {
return InstanceAction{
Action: Action{
Name: "install-dompurify-js",
Scope: scopes.ScopeUserAdmin,
NumParams: 0,
},
}
}
func (*InstallDompurifyJS) Act(ctx context.Context, instance *wisski.WissKI, in io.Reader, out io.Writer, params ...string) error {
return instance.Barrel().Shell(ctx, stream.NewIOStream(out, out, nil), "/runtime/install_dompurify.sh")
}