changes
This commit is contained in:
parent
f96b506abf
commit
edf62a466f
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ cm
|
|||||||
test/
|
test/
|
||||||
website_update.sh
|
website_update.sh
|
||||||
site.png
|
site.png
|
||||||
|
*.sublime-project
|
||||||
|
|||||||
1878
cm.sublime-workspace
Normal file
1878
cm.sublime-workspace
Normal file
File diff suppressed because it is too large
Load Diff
9
gen.odin
9
gen.odin
@ -5,6 +5,13 @@ import "core:fmt"
|
|||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WIP files are denoted with an '!' at the start of the file.
|
||||||
|
* This stops the files being processed and uploaded to the site
|
||||||
|
* before you finish writing!
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
BLOG_START_MD := `
|
BLOG_START_MD := `
|
||||||
(\
|
(\
|
||||||
\'\
|
\'\
|
||||||
@ -40,7 +47,7 @@ generate_blog_md_file :: proc(path: string, allocator := context.allocator) {
|
|||||||
trim_b := strings.trim_right(b[1], ".md")
|
trim_b := strings.trim_right(b[1], ".md")
|
||||||
if trim_b == "index" { continue } //Ignore Index
|
if trim_b == "index" { continue } //Ignore Index
|
||||||
|
|
||||||
if strings.starts_with(trim_b, "!") { continue }
|
if strings.starts_with(trim_b, "!") { continue } //Ignore WIP files!
|
||||||
append(&blog_list, blog)
|
append(&blog_list, blog)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import "core:time"
|
|||||||
|
|
||||||
print_usage :: proc() {
|
print_usage :: proc() {
|
||||||
fmt.println("Usage:\n\tcm [working dir] [output dir]\nNote:USE FULL PATH!")
|
fmt.println("Usage:\n\tcm [working dir] [output dir]\nNote:USE FULL PATH!")
|
||||||
os.exit(0)
|
os.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
@ -84,5 +84,6 @@ main :: proc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//TODO: Do timings now?
|
||||||
free_all(arena_alloc)
|
free_all(arena_alloc)
|
||||||
}
|
}
|
||||||
|
|||||||
10
odinfmt.json
10
odinfmt.json
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"character_width": 120,
|
|
||||||
"tabs": true,
|
|
||||||
"tabs_width": 4,
|
|
||||||
"sort_imports": true,
|
|
||||||
"spaces_around_colons": false,
|
|
||||||
"align_struct_fields": true,
|
|
||||||
"align_struct_values": true,
|
|
||||||
"space_single_line_blocks": true
|
|
||||||
}
|
|
||||||
17
parse.odin
17
parse.odin
@ -9,11 +9,10 @@ import cm "vendor:commonmark"
|
|||||||
MD_SUFFIX :: ".md"
|
MD_SUFFIX :: ".md"
|
||||||
|
|
||||||
UTF8_PREFIX :: "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n"
|
UTF8_PREFIX :: "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n"
|
||||||
CSS_PREFIX :: "<head><link rel=\"stylesheet\" href=\"./css/style.css\">\n"
|
CSS_PREFIX :: "<head><link rel=\"stylesheet\" href=\"./css/style.css\">\n<title>Simon Kellet</title>"
|
||||||
FAVICON_PREFIX :: "<link rel=\"icon\" type=\"image\\x-icon\" href=\"/imgs/favicon.ico\">\n"
|
FAVICON_PREFIX :: "<link rel=\"icon\" type=\"image\\x-icon\" href=\"/imgs/favicon.ico\">\n"
|
||||||
MASTODON_PREFIX :: "<a rel=me href=https://linuxrocks.online/@simonkellet></a>\n"
|
MASTODON_PREFIX :: "<a rel=me href=https://linuxrocks.online/@simonkellet></a>\n"
|
||||||
|
|
||||||
|
|
||||||
write_prefixs_to_html_file :: proc(file: ^os.File) {
|
write_prefixs_to_html_file :: proc(file: ^os.File) {
|
||||||
os.write_string(file, UTF8_PREFIX)
|
os.write_string(file, UTF8_PREFIX)
|
||||||
os.write_string(file, CSS_PREFIX)
|
os.write_string(file, CSS_PREFIX)
|
||||||
@ -28,25 +27,23 @@ walk_tree_and_get_md_names :: proc(path: string, allocator := context.allocator)
|
|||||||
defer os.walker_destroy(&w)
|
defer os.walker_destroy(&w)
|
||||||
|
|
||||||
for info in os.walker_walk(&w) {
|
for info in os.walker_walk(&w) {
|
||||||
//handle errors
|
|
||||||
if path, err := os.walker_error(&w); err != nil {
|
if path, err := os.walker_error(&w); err != nil {
|
||||||
fmt.eprintfln("failed walking %s: %s", path, err)
|
fmt.eprintfln("failed walking %s: %s", path, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
//Skip a dir
|
// Skip the Git dir
|
||||||
if strings.has_suffix(info.fullpath, ".git") {
|
if strings.has_suffix(info.fullpath, ".git") {
|
||||||
os.walker_skip_dir(&w)
|
os.walker_skip_dir(&w)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.has_suffix(info.name, MD_SUFFIX) {
|
// Skip files that are NOT .md files
|
||||||
continue //skip
|
if !strings.has_suffix(info.name, MD_SUFFIX) { continue }
|
||||||
}
|
|
||||||
|
|
||||||
append(&files, strings.clone(info.fullpath, allocator))
|
append(&files, strings.clone(info.fullpath, allocator))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle error if one happened during iteration at the end:
|
// Handle error if one happened during iteration at the end:
|
||||||
if path, err := os.walker_error(&w); err != nil {
|
if path, err := os.walker_error(&w); err != nil {
|
||||||
fmt.eprintfln("failed walking %s: %v", path, err)
|
fmt.eprintfln("failed walking %s: %v", path, err)
|
||||||
@ -67,7 +64,6 @@ walk_tree :: proc(path: string) -> []u8 {
|
|||||||
fmt.eprintfln("failed walking %s: %s", path, err)
|
fmt.eprintfln("failed walking %s: %s", path, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//lets play around
|
|
||||||
filename = info.name
|
filename = info.name
|
||||||
if !strings.has_suffix(info.name, MD_SUFFIX) {
|
if !strings.has_suffix(info.name, MD_SUFFIX) {
|
||||||
continue
|
continue
|
||||||
@ -80,7 +76,8 @@ walk_tree :: proc(path: string) -> []u8 {
|
|||||||
|
|
||||||
parse_file_md_to_html :: proc(filename: string, allocator := context.allocator) -> (parsed: string, err: os.Error) {
|
parse_file_md_to_html :: proc(filename: string, allocator := context.allocator) -> (parsed: string, err: os.Error) {
|
||||||
str := os.read_entire_file_from_path(filename, allocator) or_return
|
str := os.read_entire_file_from_path(filename, allocator) or_return
|
||||||
root := cm.parse_document(raw_data(str), len(str), cm.DEFAULT_OPTIONS)
|
root := cm.parse_document_from_string(string(str), cm.DEFAULT_OPTIONS)
|
||||||
|
//root := cm.parse_document(raw_data(str), len(str), cm.DEFAULT_OPTIONS)
|
||||||
defer cm.node_free(root)
|
defer cm.node_free(root)
|
||||||
|
|
||||||
html := cm.render_html(root, cm.DEFAULT_OPTIONS)
|
html := cm.render_html(root, cm.DEFAULT_OPTIONS)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user