diff --git a/main.go b/main.go index 4295b99..fa75a72 100644 --- a/main.go +++ b/main.go @@ -161,27 +161,31 @@ func createPostList(inFolder, outFolder, templateFolder string) { func createAboutPage(outFolder, templateFolder string) error { + log.Println("outFolder: ", outFolder) + log.Println("templateFolder: ", templateFolder) + // create the about file - aboutFile, err := os.Create(outFolder + "/about.html") - if err != nil { - return err + aboutFile, pluginErr := os.Create(outFolder + "/about.html") + if pluginErr != nil { + log.Println("aboutFile: ", pluginErr) + return pluginErr } - defer aboutFile.Close() // read the header/footer templates - header, err := os.ReadFile(templateFolder + "/header.html") - if err != nil { - return err + header, pluginErr := os.ReadFile(templateFolder + "/header.html") + if pluginErr != nil { + return pluginErr } - footer, err := os.ReadFile(templateFolder + "/footer.html") - if err != nil { - return err + footer, pluginErr := os.ReadFile(templateFolder + "/footer.html") + if pluginErr != nil { + return pluginErr } // explainer text for the about.html page // the way this entire function is structured could be a lot better // it's not that it's wrong, it's just messy and ugly siteExplainer := "about this site
" + log.Println("siteExplainer", siteExplainer) // content vars siteName := "name: " + site_name + "
" @@ -189,6 +193,8 @@ func createAboutPage(outFolder, templateFolder string) error { siteLink := "url: " + site_link + "
" siteLicense := "license: " + site_license + "


" + log.Println("site info:", siteName, siteDesc, siteLink, siteLicense) + // author vars authorExplainer := "author information
" authorName := "name: " + author_name + "
" @@ -199,24 +205,31 @@ func createAboutPage(outFolder, templateFolder string) error { } authorLinks += "

" + log.Println("authorInfo: ", authorExplainer, authorName, authorBio, authorLinks) // plugin vars - pluginsSection := "" - plugins, err := os.ReadDir(pluginsFolder) - if err != nil { - return err + + pluginsSection := " " + + plugins, pluginErr := os.ReadDir(pluginsFolder) + if pluginErr != nil { + log.Println("plugin err: ", pluginErr) + return pluginErr } + if len(plugins) > 0 { + log.Println("plugins: ", len(plugins)) pluginsSection = "plugin credits" for _, plugin := range plugins { file, err := os.Open(pluginsFolder + "/" + plugin.Name() + "/plugin.json") if err != nil { + log.Println("plugin error: ", err) return err } - defer file.Close() var pluginData map[string]string err = json.NewDecoder(file).Decode(&pluginData) if err != nil { + log.Println("pluginData map: ", err) return err } @@ -225,9 +238,14 @@ func createAboutPage(outFolder, templateFolder string) error { pluginsSection += "" } + log.Println("pluginSection: ", pluginsSection) + + log.Println("writeline: ", aboutFile, string(header)+siteExplainer+siteName+siteDesc+siteLink+siteLicense+authorExplainer+authorName+authorBio+authorLinks+pluginsSection+string(footer)) // combine the content and write to the about file fmt.Fprintln(aboutFile, string(header)+siteExplainer+siteName+siteDesc+siteLink+siteLicense+authorExplainer+authorName+authorBio+authorLinks+pluginsSection+string(footer)) + aboutFile.Close() + return nil } @@ -271,7 +289,8 @@ func checkFlags() { } // now, if nothing has gone wrong, we process the html + createAboutPage(outFolder, templateFolder) + markdownToHTML(inFolder, outFolder, templateFolder) createPostList(inFolder, outFolder, templateFolder) - createAboutPage(outFolder, templateFolder) } diff --git a/markdown/writing-plugins.md b/markdown/writing-plugins.md index a604b59..e44d596 100644 --- a/markdown/writing-plugins.md +++ b/markdown/writing-plugins.md @@ -6,10 +6,23 @@ plugins are just zip folders that contain html files. these html files can have - they should only consist of html documents with all necessary scripts and styles inlined, or remotely referenced. it's okay to add documentation but don't count on those files being distributed with the html. - for predictable behavior, use names with no spaces or special characters - each plugin should be encapsulated by a `
` for clear separations between plugin content and bearclaw content. +- don't forget your plugin.json, it looks like this: + +``` +{ + "plugin_name": "blog-elements", + "plugin_version": "1.0.0", + "plugin_author": "@donuts-are-good", + "plugin_description": "this plugin is a test of the bearclaw plugin syste. it contains download.html which will insert a bar that contains links to download bearclaw and bearclaw source code.", + "plugin_license":"MIT License, @donuts-are-good", + "plugin_link": "https://github.com/donuts-are-good/blog-elements" +} +``` structure your plugin zips like this: [socialIconsPlugin.zip] +- plugin.json - youtube-subscribe.html - github-fork.html - twitter-follow.html @@ -18,6 +31,7 @@ don't use an inner folder like this: [socialIconsPlugin.zip] - socialIconsPlugin/ + - plugin.json - youtube-subscribe.html - github-fork.html - twitter-follow.html