api update
This commit is contained in:
@@ -15,11 +15,11 @@ func (p *PixelAPI) GetFile(id string) (io.ReadCloser, error) {
|
|||||||
type FileInfo struct {
|
type FileInfo struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
FileName string `json:"file_name"`
|
Name string `json:"name"`
|
||||||
|
Size uint64 `json:"size"`
|
||||||
|
Views int `json:"views"`
|
||||||
DateUpload time.Time `json:"date_upload"`
|
DateUpload time.Time `json:"date_upload"`
|
||||||
DateLastview time.Time `json:"date_last_view"`
|
DateLastView time.Time `json:"date_last_view"`
|
||||||
FileSize uint64 `json:"file_size"`
|
|
||||||
Views uint `json:"views"`
|
|
||||||
MimeType string `json:"mime_type"`
|
MimeType string `json:"mime_type"`
|
||||||
MimeImage string `json:"mime_image"`
|
MimeImage string `json:"mime_image"`
|
||||||
ThumbnailHREF string `json:"thumbnail_href"`
|
ThumbnailHREF string `json:"thumbnail_href"`
|
||||||
|
@@ -14,18 +14,17 @@ type List struct {
|
|||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
DateCreated time.Time `json:"date_created"`
|
DateCreated time.Time `json:"date_created"`
|
||||||
FileCount int `json:"file_count"`
|
FileCount int `json:"file_count"`
|
||||||
Files []ListFile
|
Files []ListFile `json:"files,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListFile information object from the pixeldrain API
|
// ListFile information object from the pixeldrain API
|
||||||
type ListFile struct {
|
type ListFile struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
DetailHREF string `json:"detail_href"`
|
DetailHREF string `json:"detail_href"`
|
||||||
FileName string `json:"file_name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
DateCreated time.Time `json:"date_created"`
|
DateCreated time.Time `json:"date_created"`
|
||||||
DateLastView time.Time `json:"date_last_view"`
|
DateLastView time.Time `json:"date_last_view"`
|
||||||
ListDescription string `json:"list_description"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetList get a List from the pixeldrain API. Errors will be available through
|
// GetList get a List from the pixeldrain API. Errors will be available through
|
||||||
|
@@ -22,11 +22,11 @@ var DetailsWindow = {
|
|||||||
success: function(data){
|
success: function(data){
|
||||||
$("#info_file_details").html(
|
$("#info_file_details").html(
|
||||||
"<table>"
|
"<table>"
|
||||||
+ "<tr><td>Name<td><td>" + escapeHTML(data.file_name) + "</td></tr>"
|
+ "<tr><td>Name<td><td>" + escapeHTML(data.name) + "</td></tr>"
|
||||||
+ "<tr><td>Url<td><td><a href=\"/u/" + data.id + "\">/u/" + data.id + "</a></td></tr>"
|
+ "<tr><td>Url<td><td><a href=\"/u/" + data.id + "\">/u/" + data.id + "</a></td></tr>"
|
||||||
+ "<tr><td>Mime Type<td><td>" + escapeHTML(data.mime_type) + "</td></tr>"
|
+ "<tr><td>Mime Type<td><td>" + escapeHTML(data.mime_type) + "</td></tr>"
|
||||||
+ "<tr><td>Id<td><td>" + data.id + "</td></tr>"
|
+ "<tr><td>Id<td><td>" + data.id + "</td></tr>"
|
||||||
+ "<tr><td>Size<td><td class=\"bytecounter\">" + data.file_size + "</td></tr>"
|
+ "<tr><td>Size<td><td class=\"bytecounter\">" + data.size + "</td></tr>"
|
||||||
+ "<tr><td>Upload Date<td><td>" + data.date_upload + "</td></tr>"
|
+ "<tr><td>Upload Date<td><td>" + data.date_upload + "</td></tr>"
|
||||||
+ "<tr><td>Description<td><td>" + escapeHTML(file.description) + "</td></tr>"
|
+ "<tr><td>Description<td><td>" + escapeHTML(file.description) + "</td></tr>"
|
||||||
+ "</table>"
|
+ "</table>"
|
||||||
@@ -36,10 +36,10 @@ var DetailsWindow = {
|
|||||||
} else {
|
} else {
|
||||||
$("#info_file_details").html(
|
$("#info_file_details").html(
|
||||||
"<table>"
|
"<table>"
|
||||||
+ "<tr><td>Name<td><td>" + escapeHTML(file.file_name) + "</td></tr>"
|
+ "<tr><td>Name<td><td>" + escapeHTML(file.name) + "</td></tr>"
|
||||||
+ "<tr><td>Mime Type<td><td>" + escapeHTML(file.mime_type) + "</td></tr>"
|
+ "<tr><td>Mime Type<td><td>" + escapeHTML(file.mime_type) + "</td></tr>"
|
||||||
+ "<tr><td>Id<td><td>" + file.id + "</td></tr>"
|
+ "<tr><td>Id<td><td>" + file.id + "</td></tr>"
|
||||||
+ "<tr><td>Size<td><td class=\"bytecounter\">" + file.file_size + "</td></tr>"
|
+ "<tr><td>Size<td><td class=\"bytecounter\">" + file.size + "</td></tr>"
|
||||||
+ "<tr><td>Upload Date<td><td>" + file.date_upload + "</td></tr>"
|
+ "<tr><td>Upload Date<td><td>" + file.date_upload + "</td></tr>"
|
||||||
+ "</table>"
|
+ "</table>"
|
||||||
);
|
);
|
||||||
|
@@ -127,7 +127,7 @@ var ListNavigator = {
|
|||||||
|
|
||||||
for (i = startPos; i <= endPos; i++){
|
for (i = startPos; i <= endPos; i++){
|
||||||
var thumb = "/api/file/" + this.data[i].id + "/thumbnail";
|
var thumb = "/api/file/" + this.data[i].id + "/thumbnail";
|
||||||
var name = this.data[i].file_name;
|
var name = this.data[i].name;
|
||||||
|
|
||||||
var itemHtml = escapeHTML(name) + "<br>"
|
var itemHtml = escapeHTML(name) + "<br>"
|
||||||
+ "<img src=\"" + thumb + "\" "
|
+ "<img src=\"" + thumb + "\" "
|
||||||
@@ -144,8 +144,8 @@ var ListNavigator = {
|
|||||||
|
|
||||||
$.each(data, function(i, item){
|
$.each(data, function(i, item){
|
||||||
var filename;
|
var filename;
|
||||||
if(item.file_name !== "null"){
|
if(item.name !== "null"){
|
||||||
filename = item.file_name;
|
filename = item.name;
|
||||||
}else{
|
}else{
|
||||||
filename = "Removed File";
|
filename = "Removed File";
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ var Viewer = {
|
|||||||
},
|
},
|
||||||
setFile: function(file){
|
setFile: function(file){
|
||||||
this.currentFile = file.id;
|
this.currentFile = file.id;
|
||||||
document.title = file.file_name + " ~ PixelDrain";
|
document.title = file.name + " ~ PixelDrain";
|
||||||
|
|
||||||
$.get("/u/" + file.id + "/preview", function(response){
|
$.get("/u/" + file.id + "/preview", function(response){
|
||||||
$("#filepreview").html(response);
|
$("#filepreview").html(response);
|
||||||
|
@@ -50,8 +50,8 @@ function historyAddItem(json) {
|
|||||||
|
|
||||||
var uploadItem = '<a href="/u/'+ json.id +'" target="_blank" class="file_button">'
|
var uploadItem = '<a href="/u/'+ json.id +'" target="_blank" class="file_button">'
|
||||||
+ '<img src="'+ apiEndpoint + json.thumbnail_href + '"'
|
+ '<img src="'+ apiEndpoint + json.thumbnail_href + '"'
|
||||||
+ "alt=\"" + json.file_name + "\" />"
|
+ "alt=\"" + json.name + "\" />"
|
||||||
+ '<span style="color: var(--highlight_color);">'+json.file_name+'</span>'
|
+ '<span style="color: var(--highlight_color);">'+json.name+'</span>'
|
||||||
+ "<br/>"
|
+ "<br/>"
|
||||||
+ date.getFullYear() + "-"
|
+ date.getFullYear() + "-"
|
||||||
+ ("00" + (date.getMonth() + 1)).slice(-2) + "-"
|
+ ("00" + (date.getMonth() + 1)).slice(-2) + "-"
|
||||||
|
@@ -250,7 +250,7 @@ select{
|
|||||||
border: none;
|
border: none;
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
background: linear-gradient(var(--input_color), var(--input_color_dark));
|
background: linear-gradient(var(--input_color), var(--input_color_dark));
|
||||||
padding: 6px 10px 6px 10px;
|
padding: 6px 8px 6px 8px;
|
||||||
box-shadow: 2px 2px 8px var(--shadow_color);
|
box-shadow: 2px 2px 8px var(--shadow_color);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 0.85em;
|
font-size: 0.85em;
|
||||||
|
@@ -50,8 +50,8 @@
|
|||||||
{{$files := .PixelAPI.UserFiles 0 20}}
|
{{$files := .PixelAPI.UserFiles 0 20}}
|
||||||
{{range $files.Files}}
|
{{range $files.Files}}
|
||||||
<a class="file_button" href="/u/{{.ID}}" target="_blank">
|
<a class="file_button" href="/u/{{.ID}}" target="_blank">
|
||||||
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.FileName}}" />
|
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.File}}" />
|
||||||
{{.FileName}}
|
{{.File}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
{{$files := .PixelAPI.UserFiles 0 1000}}
|
{{$files := .PixelAPI.UserFiles 0 1000}}
|
||||||
{{range $files.Files}}
|
{{range $files.Files}}
|
||||||
<a class="file_button" href="/u/{{.ID}}" target="_blank">
|
<a class="file_button" href="/u/{{.ID}}" target="_blank">
|
||||||
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.FileName}}" />
|
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.Name}}" />
|
||||||
<span style="color: var(--highlight_color);">{{.FileName}}</span>
|
<span style="color: var(--highlight_color);">{{.Name}}</span>
|
||||||
<br/>
|
<br/>
|
||||||
{{.DateUpload.Format "2006-01-02 15:04:05"}}
|
{{.DateUpload.Format "2006-01-02 15:04:05"}}
|
||||||
</a>
|
</a>
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
{{$files := .PixelAPI.UserFiles 0 18}}
|
{{$files := .PixelAPI.UserFiles 0 18}}
|
||||||
{{range $files.Files}}
|
{{range $files.Files}}
|
||||||
<a class="file_button" href="/u/{{.ID}}" target="_blank">
|
<a class="file_button" href="/u/{{.ID}}" target="_blank">
|
||||||
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.FileName}}" />
|
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.Name}}" />
|
||||||
<span style="color: var(--highlight_color);">{{.FileName}}</span>
|
<span style="color: var(--highlight_color);">{{.Name}}</span>
|
||||||
<br/>
|
<br/>
|
||||||
{{.DateUpload.Format "2006-01-02 15:04:05"}}
|
{{.DateUpload.Format "2006-01-02 15:04:05"}}
|
||||||
</a>
|
</a>
|
||||||
|
@@ -144,10 +144,10 @@
|
|||||||
{
|
{
|
||||||
"success": true,
|
"success": true,
|
||||||
"id": "123abc",
|
"id": "123abc",
|
||||||
"file_name": "screenshot.png",
|
"name": "screenshot.png",
|
||||||
"date_upload": 1485894987, // Timestamp
|
"date_upload": 1485894987, // Timestamp
|
||||||
"date_last_view": 1485894987, // Timestamp
|
"date_last_view": 1485894987, // Timestamp
|
||||||
"file_size": 5694837, // Bytes
|
"size": 5694837, // Bytes
|
||||||
"views" 1234, // Amount of unique file views
|
"views" 1234, // Amount of unique file views
|
||||||
"mime_type" "image/png",
|
"mime_type" "image/png",
|
||||||
"description": "File description",
|
"description": "File description",
|
||||||
|
@@ -117,10 +117,10 @@
|
|||||||
"file_info": {
|
"file_info": {
|
||||||
"success": true,
|
"success": true,
|
||||||
"id": "Jf_u5TI9",
|
"id": "Jf_u5TI9",
|
||||||
"file_name": "11. Lenny Kravitz - Fly away.ogg",
|
"name": "11. Lenny Kravitz - Fly away.ogg",
|
||||||
"date_upload": "2018-07-04T22:24:48Z",
|
"date_upload": "2018-07-04T22:24:48Z",
|
||||||
"date_last_view": "2018-07-04T22:24:48Z",
|
"date_last_view": "2018-07-04T22:24:48Z",
|
||||||
"file_size": 9757269,
|
"size": 9757269,
|
||||||
"views": 0,
|
"views": 0,
|
||||||
"mime_type": "application/ogg",
|
"mime_type": "application/ogg",
|
||||||
"thumbnail_href": "/file/Jf_u5TI9/thumbnail"
|
"thumbnail_href": "/file/Jf_u5TI9/thumbnail"
|
||||||
|
@@ -39,9 +39,11 @@
|
|||||||
<pre>HTTP 422: Unprocessable Entity
|
<pre>HTTP 422: Unprocessable Entity
|
||||||
{
|
{
|
||||||
"success": false,
|
"success": false,
|
||||||
"value": "file_not_found",
|
"value": "list_file_not_found",
|
||||||
"id": "Oh42No", // The file you tried to add with this ID does not exist
|
"message": "File Oh42No was not found in the database.",
|
||||||
"message": "File Oh42No was not found in the database."
|
"extra": {
|
||||||
|
"file_not_found": "0h42No" // The file you tried to add with this ID does not exist
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<pre>HTTP 413: Payload too large
|
<pre>HTTP 413: Payload too large
|
||||||
@@ -124,7 +126,7 @@
|
|||||||
{
|
{
|
||||||
"detail_href": "/file/_SqVWi/info",
|
"detail_href": "/file/_SqVWi/info",
|
||||||
"id": "_SqVWi",
|
"id": "_SqVWi",
|
||||||
"file_name": "01 Holy Wars... The Punishment Due.mp3",
|
"name": "01 Holy Wars... The Punishment Due.mp3",
|
||||||
"description": "",
|
"description": "",
|
||||||
"date_created": 1513033304,
|
"date_created": 1513033304,
|
||||||
"date_last_view": 1513033304
|
"date_last_view": 1513033304
|
||||||
@@ -132,7 +134,7 @@
|
|||||||
{
|
{
|
||||||
"detail_href": "/file/RKwgZb/info",
|
"detail_href": "/file/RKwgZb/info",
|
||||||
"id": "RKwgZb",
|
"id": "RKwgZb",
|
||||||
"file_name": "02 Hangar 18.mp3",
|
"name": "02 Hangar 18.mp3",
|
||||||
"description": "",
|
"description": "",
|
||||||
"date_created": 1513033304,
|
"date_created": 1513033304,
|
||||||
"date_last_view": 1513033304
|
"date_last_view": 1513033304
|
||||||
@@ -140,7 +142,7 @@
|
|||||||
{
|
{
|
||||||
"detail_href": "/file/DRaL_e/info",
|
"detail_href": "/file/DRaL_e/info",
|
||||||
"id": "DRaL_e",
|
"id": "DRaL_e",
|
||||||
"file_name": "03 Take No Prisoners.mp3",
|
"name": "03 Take No Prisoners.mp3",
|
||||||
"description": "",
|
"description": "",
|
||||||
"date_created": 1513033304,
|
"date_created": 1513033304,
|
||||||
"date_last_view": 1513033304
|
"date_last_view": 1513033304
|
||||||
|
@@ -78,7 +78,7 @@ func (f filePreview) run(inf *pixelapi.FileInfo) string {
|
|||||||
return f.pdf()
|
return f.pdf()
|
||||||
case
|
case
|
||||||
"application/octet-stream": // Fallback for when mime type not recognized
|
"application/octet-stream": // Fallback for when mime type not recognized
|
||||||
switch filepath.Ext(f.FileInfo.FileName) {
|
switch filepath.Ext(f.FileInfo.Name) {
|
||||||
case
|
case
|
||||||
".mp3":
|
".mp3":
|
||||||
return f.audio()
|
return f.audio()
|
||||||
@@ -110,7 +110,7 @@ func (f filePreview) audio() string {
|
|||||||
</audio>
|
</audio>
|
||||||
</div>
|
</div>
|
||||||
<script src="/res/viewer-scripts/audio.js"></script>`,
|
<script src="/res/viewer-scripts/audio.js"></script>`,
|
||||||
f.FileInfo.FileName,
|
f.FileInfo.Name,
|
||||||
f.FileURL,
|
f.FileURL,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ func (f filePreview) text() string {
|
|||||||
<pre class="pre-container %s" style="width: 100%%;">%s</pre>
|
<pre class="pre-container %s" style="width: 100%%;">%s</pre>
|
||||||
</div>`
|
</div>`
|
||||||
|
|
||||||
if f.FileInfo.FileSize > 1e6 { // Prevent out of memory errors
|
if f.FileInfo.Size > 1e6 { // Prevent out of memory errors
|
||||||
return fmt.Sprintf(htmlOut, "",
|
return fmt.Sprintf(htmlOut, "",
|
||||||
"File is too large to view online.\nPlease download and view it locally.",
|
"File is too large to view online.\nPlease download and view it locally.",
|
||||||
)
|
)
|
||||||
@@ -191,7 +191,7 @@ seamless="seamless" frameborder="0" allowtransparency="true"
|
|||||||
func (f filePreview) def() string {
|
func (f filePreview) def() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
`%s<br/>%s<br/><a href="%s"><img src="%s" class="image"></a>`,
|
`%s<br/>%s<br/><a href="%s"><img src="%s" class="image"></a>`,
|
||||||
f.FileInfo.FileName,
|
f.FileInfo.Name,
|
||||||
f.FileInfo.MimeType,
|
f.FileInfo.MimeType,
|
||||||
f.DownloadURL,
|
f.DownloadURL,
|
||||||
f.APIURL+f.FileInfo.ThumbnailHREF,
|
f.APIURL+f.FileInfo.ThumbnailHREF,
|
||||||
|
@@ -61,7 +61,7 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
err = wc.templates.Get().ExecuteTemplate(w, "file_viewer", map[string]interface{}{
|
err = wc.templates.Get().ExecuteTemplate(w, "file_viewer", map[string]interface{}{
|
||||||
"Title": fmt.Sprintf("%s ~ Pixeldrain file", finfo[0].FileName),
|
"Title": fmt.Sprintf("%s ~ Pixeldrain file", finfo[0].Name),
|
||||||
"APIResponse": finfo[0],
|
"APIResponse": finfo[0],
|
||||||
"Type": "file",
|
"Type": "file",
|
||||||
"OGData": ogData.FromFile(*finfo[0]),
|
"OGData": ogData.FromFile(*finfo[0]),
|
||||||
@@ -80,10 +80,10 @@ func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter) {
|
|||||||
wc.templates.Get().ExecuteTemplate(w, "file_viewer", map[string]interface{}{
|
wc.templates.Get().ExecuteTemplate(w, "file_viewer", map[string]interface{}{
|
||||||
"APIResponse": map[string]interface{}{
|
"APIResponse": map[string]interface{}{
|
||||||
"id": "demo",
|
"id": "demo",
|
||||||
"file_name": "Demo file",
|
"name": "Demo file",
|
||||||
"date_upload": "2017-01-01 12:34:56",
|
"date_upload": "2017-01-01 12:34:56",
|
||||||
"date_lastview": "2017-01-01 12:34:56",
|
"date_lastview": "2017-01-01 12:34:56",
|
||||||
"file_size": 123456789,
|
"size": 123456789,
|
||||||
"views": 1,
|
"views": 1,
|
||||||
"mime_type": "text/demo",
|
"mime_type": "text/demo",
|
||||||
"description": "A file to demonstrate the viewer page",
|
"description": "A file to demonstrate the viewer page",
|
||||||
|
@@ -18,10 +18,10 @@ type OGData struct {
|
|||||||
// FromFile populates the OGData object from FileInfo. It returns itself for
|
// FromFile populates the OGData object from FileInfo. It returns itself for
|
||||||
// compactness.
|
// compactness.
|
||||||
func (d *OGData) FromFile(f pixelapi.FileInfo) *OGData {
|
func (d *OGData) FromFile(f pixelapi.FileInfo) *OGData {
|
||||||
d.Title = f.FileName
|
d.Title = f.Name
|
||||||
d.Type = "website"
|
d.Type = "website"
|
||||||
d.SiteName = "Pixeldrain"
|
d.SiteName = "Pixeldrain"
|
||||||
d.Description = "View " + f.FileName + " on Pixeldrain"
|
d.Description = "View " + f.Name + " on Pixeldrain"
|
||||||
d.URL = "/u/" + f.ID
|
d.URL = "/u/" + f.ID
|
||||||
d.Image = "/api/file/" + f.ID + "/thumbnail"
|
d.Image = "/api/file/" + f.ID + "/thumbnail"
|
||||||
return d
|
return d
|
||||||
|
@@ -36,28 +36,30 @@ func New(r *httprouter.Router, prefix string, conf *conf.PixelWebConfig) *WebCon
|
|||||||
)
|
)
|
||||||
wc.templates.ParseTemplates(false)
|
wc.templates.ParseTemplates(false)
|
||||||
|
|
||||||
|
var p = prefix
|
||||||
|
|
||||||
// Serve static files
|
// Serve static files
|
||||||
r.ServeFiles(prefix+"/res/*filepath", http.Dir(wc.staticResourceDir+"/res"))
|
r.ServeFiles(p+"/res/*filepath", http.Dir(wc.staticResourceDir+"/res"))
|
||||||
|
|
||||||
// General navigation
|
// General navigation
|
||||||
r.GET(prefix+"/" /* */, wc.serveTemplate("home", false))
|
r.GET(p+"/" /* */, wc.serveTemplate("home", false))
|
||||||
r.GET(prefix+"/favicon.ico" /* */, wc.serveFile("/favicon.ico"))
|
r.GET(p+"/favicon.ico" /* */, wc.serveFile("/favicon.ico"))
|
||||||
r.GET(prefix+"/global.css" /* */, wc.globalCSSHandler)
|
r.GET(p+"/global.css" /* */, wc.globalCSSHandler)
|
||||||
r.GET(prefix+"/api" /* */, wc.serveTemplate("apidoc", false))
|
r.GET(p+"/api" /* */, wc.serveTemplate("apidoc", false))
|
||||||
r.GET(prefix+"/history" /* */, wc.serveTemplate("history_cookies", false))
|
r.GET(p+"/history" /* */, wc.serveTemplate("history_cookies", false))
|
||||||
r.GET(prefix+"/u/:id" /* */, wc.serveFileViewer)
|
r.GET(p+"/u/:id" /* */, wc.serveFileViewer)
|
||||||
r.GET(prefix+"/u/:id/preview" /* */, wc.serveFilePreview)
|
r.GET(p+"/u/:id/preview" /* */, wc.serveFilePreview)
|
||||||
r.GET(prefix+"/l/:id" /* */, wc.serveListViewer)
|
r.GET(p+"/l/:id" /* */, wc.serveListViewer)
|
||||||
r.GET(prefix+"/t" /* */, wc.serveTemplate("paste", false))
|
r.GET(p+"/t" /* */, wc.serveTemplate("paste", false))
|
||||||
|
|
||||||
// User account pages
|
// User account pages
|
||||||
r.GET(prefix+"/register" /* */, wc.serveRegister)
|
r.GET(p+"/register" /* */, wc.serveRegister)
|
||||||
r.GET(prefix+"/login" /* */, wc.serveTemplate("login", false))
|
r.GET(p+"/login" /* */, wc.serveTemplate("login", false))
|
||||||
r.GET(prefix+"/logout" /* */, wc.serveTemplate("logout", true))
|
r.GET(p+"/logout" /* */, wc.serveTemplate("logout", true))
|
||||||
r.POST(prefix+"/logout" /* */, wc.serveLogout)
|
r.POST(p+"/logout" /* */, wc.serveLogout)
|
||||||
r.GET(prefix+"/user" /* */, wc.serveTemplate("user_home", true))
|
r.GET(p+"/user" /* */, wc.serveTemplate("user_home", true))
|
||||||
r.GET(prefix+"/user/files" /* */, wc.serveTemplate("user_files", true))
|
r.GET(p+"/user/files" /* */, wc.serveTemplate("user_files", true))
|
||||||
r.GET(prefix+"/user/filemanager" /**/, wc.serveTemplate("file_manager", true))
|
r.GET(p+"/user/filemanager" /**/, wc.serveTemplate("file_manager", true))
|
||||||
|
|
||||||
r.NotFound = http.HandlerFunc(wc.serveNotFound)
|
r.NotFound = http.HandlerFunc(wc.serveNotFound)
|
||||||
|
|
||||||
@@ -97,6 +99,7 @@ func (wc *WebController) serveFile(path string) httprouter.Handle {
|
|||||||
|
|
||||||
func (wc *WebController) serveNotFound(w http.ResponseWriter, r *http.Request) {
|
func (wc *WebController) serveNotFound(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("Not Found: %s", r.URL)
|
log.Debug("Not Found: %s", r.URL)
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
wc.templates.Get().ExecuteTemplate(w, "404", wc.newTemplateData(w, r))
|
wc.templates.Get().ExecuteTemplate(w, "404", wc.newTemplateData(w, r))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user