From 5d30b60f131acec76a7e97d586acb69cbc1f937f Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Mon, 9 Jul 2018 23:19:16 +0200 Subject: [PATCH] File manager mockup --- res/static/res/script/listmaker.js | 22 +++++----- res/static/res/style/layout.css | 23 ++++++---- res/template/account/file_manager.html | 61 ++++++++++++++++++++++---- res/template/file_viewer.html | 36 +++++++-------- res/template/home.html | 2 +- res/template/paste.html | 5 +-- webcontroller/filePreview.go | 28 ++++++------ webcontroller/fileViewer.go | 3 +- webcontroller/listViewer.go | 3 +- webcontroller/webcontroller.go | 40 +++++++++-------- 10 files changed, 138 insertions(+), 85 deletions(-) diff --git a/res/static/res/script/listmaker.js b/res/static/res/script/listmaker.js index 4d8a00d..048c0ae 100644 --- a/res/static/res/script/listmaker.js +++ b/res/static/res/script/listmaker.js @@ -12,9 +12,9 @@ function createList(){ } var url = "/api/list"; - + var postData = {}; - + var title = prompt( "You are creating a list containing " + listfiles.length + " files.\n" + "What do you want to call it?", "My New Album" @@ -29,13 +29,13 @@ function createList(){ "description": "yo", "files": new Array() }; - + for (var i = 0; i < listfiles.length; i++) { postData.files.push({ "id": listfiles[i] }); } - + $.ajax({ url: url, contentType: "application/json", @@ -53,9 +53,9 @@ function listCreated(response){ + "Your List URL:
" + ""+window.location.hostname+"/l/" + response.id + "" + ""; - + $('#uploads_queue').prepend( - $(resultString).hide().fadeIn('slow') + $(resultString).hide().fadeIn('slow').css("display", "") ); window.open('/l/'+response.id, '_blank'); }else{ @@ -63,9 +63,9 @@ function listCreated(response){ + "The server responded with this:
" + response.type + ": " + response.value + ""; - + $('#uploads_queue').prepend( - $(resultString).hide().fadeIn('slow') + $(resultString).hide().fadeIn('slow').css("display", "") ); } } @@ -74,9 +74,9 @@ function listCreated(response){ // var fileDesc = $("#txtListDesc").val(); // // addToList(fileId, fileDesc); -// +// // divItems.prepend("ID: " + fileId + "
Description:
" + fileDesc + "

"); -// +// // $("#txtListId").val(""); // $("#txtListDesc").val(""); -//}); \ No newline at end of file +//}); diff --git a/res/static/res/style/layout.css b/res/static/res/style/layout.css index 1852d25..40b4fee 100644 --- a/res/static/res/style/layout.css +++ b/res/static/res/style/layout.css @@ -133,14 +133,8 @@ hr{ ::-webkit-scrollbar-thumb {background-color: #555;} ::-webkit-scrollbar-corner{background: transparent;} -a{ - color: var(--highlight_color); - text-decoration: none; -} -a:hover{ - text-decoration: underline; - color: var(--highlight_color); -} +a {color: var(--highlight_color); text-decoration: none;} +a:hover {color: var(--highlight_color); text-decoration: underline;} .form{ margin-left: auto; @@ -243,10 +237,13 @@ pre{ /* BUTTONS */ button, +.button, input[type="submit"], input[type="button"], input[type="color"], select{ + display: inline-block; + box-sizing: border-box; border-radius: 4px; border: none; margin: 2px; @@ -254,24 +251,33 @@ select{ padding: 6px 10px 6px 10px; box-shadow: 2px 2px 8px #000000; font-weight: bold; + font-size: 0.85em; + line-height: 1; + text-decoration: none; color: #FFFFFF; outline: 0; vertical-align: middle; cursor: pointer; + } button:hover, +.button:hover, input[type="submit"]:hover, input[type="button"]:hover, input[type="color"]:hover, select:hover, button:focus, +.button:focus, input[type="submit"]:focus, input[type="button"]:focus, input[type="color"]:focus, select:focus{ + color: #FFFFFF; + text-decoration: none; box-shadow: var(--highlight_border), 2px 2px 8px #000000; } button:active, +.button:active, input[type="submit"]:active, input[type="button"]:active, input[type="color"]:active, @@ -291,6 +297,7 @@ option{background-color: #404040; color: #FFFFFF;} /* TEXT FIELDS */ textarea, +.groove, input[type="text"], input[type="password"], input[type="email"], diff --git a/res/template/account/file_manager.html b/res/template/account/file_manager.html index cd351f1..ab417fe 100644 --- a/res/template/account/file_manager.html +++ b/res/template/account/file_manager.html @@ -3,20 +3,63 @@ {{template "meta_tags" "File Manager"}} + {{template "menu" .}} -
- {{range .Other.Files}} - - {{.FileName}} - {{.FileName}} -
- {{.DateUpload}} -
- {{end}} +
+ +
+ {{$files := .PixelAPI.UserFiles 0 20}} + {{range $files.Files}} + + {{.FileName}} + {{.FileName}} + + {{end}} +
+
+ 13 items (5 directories, 7 files). Total size: 1.23 GB +
+
+ {{template "analytics"}} diff --git a/res/template/file_viewer.html b/res/template/file_viewer.html index a7980b9..01ccbe6 100644 --- a/res/template/file_viewer.html +++ b/res/template/file_viewer.html @@ -13,13 +13,13 @@ - + - + - + {{template "bgpattern"}} - + @@ -49,12 +49,10 @@
-
- -
+ + Back to the Home page + Home + `, @@ -188,7 +188,7 @@ seamless="seamless" frameborder="0" allowtransparency="true" ) } -func (f FilePreview) def() string { +func (f filePreview) def() string { return fmt.Sprintf( `%s
%s
`, f.FileInfo.FileName, diff --git a/webcontroller/fileViewer.go b/webcontroller/fileViewer.go index 6abb034..dbc35f6 100644 --- a/webcontroller/fileViewer.go +++ b/webcontroller/fileViewer.go @@ -26,9 +26,10 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request, ids = append(ids, p.ByName("id")) } + var api = pixelapi.New(wc.conf.APIURLInternal, "") var finfo []*pixelapi.FileInfo for _, id := range ids { - inf, err := wc.api.GetFileInfo(id) + inf, err := api.GetFileInfo(id) if err != nil { continue } diff --git a/webcontroller/listViewer.go b/webcontroller/listViewer.go index 4cf6bf8..0abc9ff 100644 --- a/webcontroller/listViewer.go +++ b/webcontroller/listViewer.go @@ -12,7 +12,8 @@ import ( // ServeListViewer controller for GET /l/:id func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request, p httprouter.Params) { - var list, err = wc.api.GetList(p.ByName("id")) + var api = pixelapi.New(wc.conf.APIURLInternal, "") + var list, err = api.GetList(p.ByName("id")) if err != nil { if (err.(pixelapi.Error)).ReqError { log.Error("API request error occurred: %s", (err.(pixelapi.Error)).Value) diff --git a/webcontroller/webcontroller.go b/webcontroller/webcontroller.go index 3327126..ed75ef7 100644 --- a/webcontroller/webcontroller.go +++ b/webcontroller/webcontroller.go @@ -7,25 +7,26 @@ import ( "github.com/google/uuid" "fornaxian.com/pixeldrain-web/init/conf" - "fornaxian.com/pixeldrain-web/pixelapi" "fornaxian.com/pixeldrain-web/webcontroller/templates" "github.com/Fornaxian/log" "github.com/julienschmidt/httprouter" ) +// WebController controls how requests are handled and makes sure they have +// proper context when running type WebController struct { conf *conf.PixelWebConfig - api *pixelapi.PixelAPI // Shared instance, only used for unauthenticated requests templates *templates.TemplateManager staticResourceDir string } +// New initializes a new WebController by registering all the request handlers +// and parsing all templates in the resource directory func New(r *httprouter.Router, prefix string, conf *conf.PixelWebConfig) *WebController { var wc = &WebController{ conf: conf, staticResourceDir: conf.StaticResourceDir, } - wc.api = pixelapi.New(conf.APIURLInternal, "") wc.templates = templates.New( conf.TemplateDir, conf.APIURLExternal, @@ -36,22 +37,25 @@ func New(r *httprouter.Router, prefix string, conf *conf.PixelWebConfig) *WebCon // Serve static files r.ServeFiles(prefix+"/res/*filepath", http.Dir(wc.staticResourceDir+"/res")) - r.GET(prefix+"/" /* */, wc.serveTemplate("home", false)) - r.GET(prefix+"/favicon.ico" /* */, wc.serveFile("/favicon.ico")) - r.GET(prefix+"/global.css" /* */, wc.globalCSSHandler) - r.GET(prefix+"/api" /* */, wc.serveTemplate("apidoc", false)) - r.GET(prefix+"/history" /* */, wc.serveTemplate("history_cookies", false)) - r.GET(prefix+"/u/:id" /* */, wc.serveFileViewer) - r.GET(prefix+"/u/:id/preview" /**/, wc.serveFilePreview) - r.GET(prefix+"/l/:id" /* */, wc.serveListViewer) - r.GET(prefix+"/t" /* */, wc.serveTemplate("paste", false)) + // General navigation + r.GET(prefix+"/" /* */, wc.serveTemplate("home", false)) + r.GET(prefix+"/favicon.ico" /* */, wc.serveFile("/favicon.ico")) + r.GET(prefix+"/global.css" /* */, wc.globalCSSHandler) + r.GET(prefix+"/api" /* */, wc.serveTemplate("apidoc", false)) + r.GET(prefix+"/history" /* */, wc.serveTemplate("history_cookies", false)) + r.GET(prefix+"/u/:id" /* */, wc.serveFileViewer) + r.GET(prefix+"/u/:id/preview" /* */, wc.serveFilePreview) + r.GET(prefix+"/l/:id" /* */, wc.serveListViewer) + r.GET(prefix+"/t" /* */, wc.serveTemplate("paste", false)) - r.GET(prefix+"/register" /* */, wc.serveTemplate("register", false)) - r.GET(prefix+"/login" /* */, wc.serveTemplate("login", false)) - r.GET(prefix+"/logout" /* */, wc.serveTemplate("logout", true)) - r.POST(prefix+"/logout" /* */, wc.serveLogout) - r.GET(prefix+"/user" /* */, wc.serveTemplate("user_home", true)) - r.GET(prefix+"/user/files" /* */, wc.serveTemplate("user_files", true)) + // User account pages + r.GET(prefix+"/register" /* */, wc.serveTemplate("register", false)) + r.GET(prefix+"/login" /* */, wc.serveTemplate("login", false)) + r.GET(prefix+"/logout" /* */, wc.serveTemplate("logout", true)) + r.POST(prefix+"/logout" /* */, wc.serveLogout) + r.GET(prefix+"/user" /* */, wc.serveTemplate("user_home", true)) + r.GET(prefix+"/user/files" /* */, wc.serveTemplate("user_files", true)) + r.GET(prefix+"/user/filemanager" /**/, wc.serveTemplate("file_manager", true)) r.NotFound = http.HandlerFunc(wc.serveNotFound)