pull/144/head
Henrique Dias 2016-06-30 20:12:43 +01:00
parent 8c9e0bc74f
commit a170e8797e
2 changed files with 11 additions and 9 deletions

View File

@ -59,7 +59,7 @@ Element.prototype.changeToDone = function(error, html) {
this.innerHTML = html;
this.style.opacity = 1;
if (selectedItems.length == 0) {
if (selectedItems.length == 0 && document.getElementById('listing')) {
document.sendCostumEvent('changed-selected');
}
}
@ -380,7 +380,6 @@ var newDirEvent = function(event) {
document.addEventListener("changed-selected", function(event) {
var toolbar = document.getElementById("toolbar");
var selectedNumber = selectedItems.length;
document.getElementById("selected-number").innerHTML = selectedNumber;
if (selectedNumber) {

View File

@ -37,7 +37,7 @@ func (i *Info) Update(w http.ResponseWriter, r *http.Request, c *config.Config)
switch kind {
case "frontmatter-only":
if file, code, err = parseFrontMatterOnlyFile(data, i.Name); err != nil {
if file, code, err = ParseFrontMatterOnlyFile(data, i.Name); err != nil {
return http.StatusInternalServerError, err
}
case "content-only":
@ -45,7 +45,7 @@ func (i *Info) Update(w http.ResponseWriter, r *http.Request, c *config.Config)
mainContent = strings.TrimSpace(mainContent)
file = []byte(mainContent)
case "complete":
if file, code, err = parseCompleteFile(data, i.Name, c.FrontMatter); err != nil {
if file, code, err = ParseCompleteFile(data, i.Name, c.FrontMatter); err != nil {
return http.StatusInternalServerError, err
}
default:
@ -62,9 +62,10 @@ func (i *Info) Update(w http.ResponseWriter, r *http.Request, c *config.Config)
return code, nil
}
func parseFrontMatterOnlyFile(data interface{}, filename string) ([]byte, int, error) {
// ParseFrontMatterOnlyFile parses a frontmatter only file
func ParseFrontMatterOnlyFile(data interface{}, filename string) ([]byte, int, error) {
frontmatter := strings.TrimPrefix(filepath.Ext(filename), ".")
f, code, err := parseFrontMatter(data, frontmatter)
f, code, err := ParseFrontMatter(data, frontmatter)
fString := string(f)
// If it's toml or yaml, strip frontmatter identifier
@ -82,7 +83,8 @@ func parseFrontMatterOnlyFile(data interface{}, filename string) ([]byte, int, e
return f, code, err
}
func parseFrontMatter(data interface{}, frontmatter string) ([]byte, int, error) {
// ParseFrontMatter is the frontmatter parser
func ParseFrontMatter(data interface{}, frontmatter string) ([]byte, int, error) {
var mark rune
switch frontmatter {
@ -105,7 +107,8 @@ func parseFrontMatter(data interface{}, frontmatter string) ([]byte, int, error)
return f, http.StatusOK, nil
}
func parseCompleteFile(data map[string]interface{}, filename string, frontmatter string) ([]byte, int, error) {
// ParseCompleteFile parses a complete file
func ParseCompleteFile(data map[string]interface{}, filename string, frontmatter string) ([]byte, int, error) {
mainContent := ""
if _, ok := data["content"]; ok {
@ -121,7 +124,7 @@ func parseCompleteFile(data map[string]interface{}, filename string, frontmatter
data["date"] = data["date"].(string) + ":00"
}
front, code, err := parseFrontMatter(data, frontmatter)
front, code, err := ParseFrontMatter(data, frontmatter)
if err != nil {
fmt.Println(frontmatter)