Skip to content

Commit

Permalink
Refactor - Release 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
v9n committed Feb 8, 2019
1 parent 2ae7517 commit 12d1db0
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 53 deletions.
10 changes: 7 additions & 3 deletions asset.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package baja

import (
"github.com/yeo/baja/utils"
)

func compileAsset(config *Config) {
// This should go into a site/path helper
CopyDir("themes/"+config.Theme+"/static/css", "public/css")
CopyDir("themes/"+config.Theme+"/static/js", "public/js")
CopyDir("static", "public")
utils.CopyDir("themes/"+config.Theme+"/static/css", "public/css")
utils.CopyDir("themes/"+config.Theme+"/static/js", "public/js")
utils.CopyDir("static", "public")
}
40 changes: 40 additions & 0 deletions baja.go
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
package baja

type Site struct {
Name string
Author string
BaseUrl string
}

type NodeParams struct{}

type TreeNode struct {
Name string
Leafs []TreeNode
Type string
}

type NodeMeta struct {
Title string
Draft bool
Date time.Time
DateFormatted string
Tags []string
Category string
Type string
}

type Node struct {
Meta *NodeMeta
Body template.HTML
Name string

Params *NodeParams

Raw string
Path string
BaseDirectory string
templatePaths []string
}

var NodeDB map[string][]*Node
var Nodes []*Node
42 changes: 6 additions & 36 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,6 @@ import (
"strings"
)

type NodeParams struct{}

type TreeNode struct {
Name string
Leafs []TreeNode
Type string
}

type NodeMeta struct {
Title string
Draft bool
Date time.Time
DateFormatted string
Tags []string
Category string
Hidden bool
}

type Node struct {
Meta *NodeMeta
Body template.HTML

Params *NodeParams

Raw string
Path string
BaseDirectory string
Name string
templatePaths []string
}

func NewNode(path string) *Node {
n := Node{Path: path}
n.BaseDirectory = strings.Join(strings.Split(filepath.Dir(path), "/")[1:], "/")
Expand All @@ -57,6 +26,10 @@ func NewNode(path string) *Node {
return &n
}

func (n *Node) IsPage() bool {
return n.Meta.Type == "page"
}

func (n *Node) Permalink() string {
return n.BaseDirectory + "/" + filepath.Base(n.Name)
}
Expand Down Expand Up @@ -142,8 +115,6 @@ func (n *Node) Compile() {

type visitor func(path string, f os.FileInfo, err error) error

var NodeDB map[string][]*Node

func visit(node *TreeNode) filepath.WalkFunc {
NodeDB = make(map[string][]*Node)

Expand All @@ -163,9 +134,8 @@ func visit(node *TreeNode) filepath.WalkFunc {
n.Parse()
n.FindTheme(DefaultConfig())
n.Compile()
if n.Meta.Hidden == false {
NodeDB[n.BaseDirectory] = append(NodeDB[n.BaseDirectory], n)
}

NodeDB[n.BaseDirectory] = append(NodeDB[n.BaseDirectory], n)

return nil
}
Expand Down
7 changes: 0 additions & 7 deletions site.go

This file was deleted.

15 changes: 8 additions & 7 deletions utils.go → utils/utils.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package baja

// https://gist.github.com/jaybill/2876519
import "os"
import "io"
import "io/ioutil"
import "log"
package utils

import (
"io"
"io/ioutil"
"log"
"os"
)

// Copies file source to destination dest.
func CopyFile(source string, dest string) (err error) {
Expand Down

0 comments on commit 12d1db0

Please sign in to comment.