Keep code base tidy

This commit is contained in:
Frédéric Guillot 2018-01-29 20:46:01 -08:00
parent 24a2f472ec
commit c8138351c9
5 changed files with 16 additions and 18 deletions

View File

@ -67,6 +67,5 @@ func Parse() {
logger.EnableDebug()
}
// start daemon
daemon.Run(cfg, store)
}

View File

@ -12,24 +12,23 @@ import (
var requestedLevel = InfoLevel
// LogLevel type
// LogLevel type.
type LogLevel uint32
const (
// FatalLevel should be used in fatal situations, the app will exit
// FatalLevel should be used in fatal situations, the app will exit.
FatalLevel LogLevel = iota
// ErrorLevel should be used when someone should really look at the error
// ErrorLevel should be used when someone should really look at the error.
ErrorLevel
// InfoLevel should be used during normal operations
// InfoLevel should be used during normal operations.
InfoLevel
// DebugLevel should be used only during development
// DebugLevel should be used only during development.
DebugLevel
)
// Convert the Level to a string.
func (level LogLevel) String() string {
switch level {
case DebugLevel:
@ -40,9 +39,9 @@ func (level LogLevel) String() string {
return "ERROR"
case FatalLevel:
return "FATAL"
default:
return "UNKNOWN"
}
return "UNKNOWN"
}
// EnableDebug increases logging, more verbose (debug)

View File

@ -20,7 +20,7 @@ type Worker struct {
// Run wait for a job and refresh the given feed.
func (w *Worker) Run(c chan model.Job) {
logger.Debug("[Worker] #%d started", w.id)
logger.Info("[Worker] #%d started", w.id)
for {
job := <-c

View File

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2018-01-20 13:23:40.729553481 -0800 PST m=+0.015026127
// 2018-01-29 20:38:56.472493026 -0800 PST m=+0.027898185
package static
@ -44,10 +44,9 @@ return "";}
execute(){fetch(new Request(this.url,this.options)).then((response)=>{if(this.callback){this.callback(response);}});}}
class UnreadCounterHandler{static decrement(n){this.updateValue((current)=>{return current-n;});}
static increment(n){this.updateValue((current)=>{return current+n;});}
static updateValue(callback){let counterElements=document.querySelectorAll("span.unread-counter");counterElements.forEach((element)=>{let oldValue=parseInt(element.textContent,10);element.innerHTML=callback(oldValue);});}}
class EntryHandler{static updateEntriesStatus(entryIDs,status,callback){let url=document.body.dataset.entriesStatusUrl;let request=new RequestBuilder(url);request.withBody({entry_ids:entryIDs,status:status});request.withCallback(callback);request.execute();}
static toggleEntryStatus(element){let entryID=parseInt(element.dataset.id,10);let statuses={read:"unread",unread:"read"};for(let currentStatus in statuses){let newStatus=statuses[currentStatus];if(element.classList.contains("item-status-"+currentStatus)){element.classList.remove("item-status-"+currentStatus);element.classList.add("item-status-"+newStatus);this.updateEntriesStatus([entryID],newStatus);if(newStatus==="read"){UnreadCounterHandler.decrement(1);}else{UnreadCounterHandler.increment(1);}
let link=element.querySelector("a[data-toggle-status]");if(link){this.toggleLinkStatus(link);}
static updateValue(callback){let counterElements=document.querySelectorAll("span.unread-counter");counterElements.forEach((element)=>{let oldValue=parseInt(element.textContent,10);element.innerHTML=callback(oldValue);});if(window.location.href.endsWith('/unread')){let oldValue=parseInt(document.title.split('(')[1],10);let newValue=callback(oldValue);document.title=document.title.replace(/(.*?)\(\d+\)(.*?)/,function(match,prefix,suffix,offset,string){return prefix+'('+newValue+')'+suffix;});}}}
class EntryHandler{static updateEntriesStatus(entryIDs,status,callback){let url=document.body.dataset.entriesStatusUrl;let request=new RequestBuilder(url);request.withBody({entry_ids:entryIDs,status:status});request.withCallback(callback);request.execute();if(status==="read"){UnreadCounterHandler.decrement(1);}else{UnreadCounterHandler.increment(1);}}
static toggleEntryStatus(element){let entryID=parseInt(element.dataset.id,10);let statuses={read:"unread",unread:"read"};for(let currentStatus in statuses){let newStatus=statuses[currentStatus];if(element.classList.contains("item-status-"+currentStatus)){element.classList.remove("item-status-"+currentStatus);element.classList.add("item-status-"+newStatus);this.updateEntriesStatus([entryID],newStatus);let link=element.querySelector("a[data-toggle-status]");if(link){this.toggleLinkStatus(link);}
break;}}}
static toggleLinkStatus(link){if(link.dataset.value==="read"){link.innerHTML=link.dataset.labelRead;link.dataset.value="unread";}else{link.innerHTML=link.dataset.labelUnread;link.dataset.value="read";}}
static toggleBookmark(element){element.innerHTML=element.dataset.labelLoading;let request=new RequestBuilder(element.dataset.bookmarkUrl);request.withCallback(()=>{if(element.dataset.value==="star"){element.innerHTML=element.dataset.labelStar;element.dataset.value="unstar";}else{element.innerHTML=element.dataset.labelUnstar;element.dataset.value="star";}});request.execute();}
@ -74,7 +73,8 @@ let currentItem=document.querySelector(".current-item");if(currentItem!==null){t
toggleBookmarkLink(parent){let bookmarkLink=parent.querySelector("a[data-toggle-bookmark]");if(bookmarkLink){EntryHandler.toggleBookmark(bookmarkLink);}}
openOriginalLink(){let entryLink=document.querySelector(".entry h1 a");if(entryLink!==null){DomHelper.openNewTab(entryLink.getAttribute("href"));return;}
let currentItemOriginalLink=document.querySelector(".current-item a[data-original-link]");if(currentItemOriginalLink!==null){DomHelper.openNewTab(currentItemOriginalLink.getAttribute("href"));let currentItem=document.querySelector(".current-item");this.goToNextListItem();EntryHandler.markEntryAsRead(currentItem);}}
openSelectedItem(){let currentItemLink=document.querySelector(".current-item .item-title a");if(currentItemLink!==null){window.location.href=currentItemLink.getAttribute("href");}}
openSelectedItem(){let currentItemLink=document.querySelector(".current-item .item-title a");if(currentItemLink!==null){let currentItemOriginalLink=document.querySelector(".current-item a[data-original-link]");if(currentItemOriginalLink!==null){let currentItem=document.querySelector(".current-item");EntryHandler.markEntryAsRead(currentItem);}
window.location.href=currentItemLink.getAttribute("href");}}
goToPage(page,fallbackSelf){let element=document.querySelector("a[data-page="+page+"]");if(element){document.location.href=element.href;}else if(fallbackSelf){window.location.reload();}}
goToPrevious(){if(this.isListView()){this.goToPreviousListItem();}else{this.goToPage("previous");}}
goToNext(){if(this.isListView()){this.goToNextListItem();}else{this.goToPage("next");}}
@ -91,5 +91,5 @@ document.addEventListener("DOMContentLoaded",function(){FormHandler.handleSubmit
}
var JavascriptChecksums = map[string]string{
"app": "aa432d89d424abf0d19278f72e75ffd98cba203cf3cccb40b80e6d91e7609a17",
"app": "cfeb45231fd784b9eaceefb12ecf7f2543e4c871fb3af3cebf25757446e3eae7",
}

View File

@ -69,7 +69,7 @@ func (c *Controller) SubmitSubscription(ctx *handler.Context, request *handler.R
return
}
logger.Info("[UI:SubmitSubscription] %s", subscriptions)
logger.Debug("[UI:SubmitSubscription] %s", subscriptions)
n := len(subscriptions)
switch {