Skip to content

Commit

Permalink
about.html fixed, #21
Browse files Browse the repository at this point in the history
  • Loading branch information
donuts-are-good committed Mar 7, 2023
1 parent cff01d1 commit 54e58c2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 16 deletions.
51 changes: 35 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,34 +161,40 @@ 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 := "<b class=\"info\">about this site</b><br>"
log.Println("siteExplainer", siteExplainer)

// content vars
siteName := "name:&ensp;" + site_name + "<br>"
siteDesc := "bio:&ensp;" + site_description + "<br>"
siteLink := "url:&ensp;<a href='" + site_link + "'>" + site_link + "</a><br>"
siteLicense := "license:&ensp;" + site_license + "<br><br><br>"

log.Println("site info:", siteName, siteDesc, siteLink, siteLicense)

// author vars
authorExplainer := "<b class=\"info\">author information</b><br>"
authorName := "name:&ensp;" + author_name + "<br>"
Expand All @@ -199,24 +205,31 @@ func createAboutPage(outFolder, templateFolder string) error {
}
authorLinks += "<br><br>"

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 = "<b>plugin credits</b>"
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
}

Expand All @@ -225,9 +238,14 @@ func createAboutPage(outFolder, templateFolder string) error {
pluginsSection += "</ul>"
}

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
}

Expand Down Expand Up @@ -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)
}
14 changes: 14 additions & 0 deletions markdown/writing-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<div>` 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
Expand All @@ -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
Expand Down

0 comments on commit 54e58c2

Please sign in to comment.