sc0ttj / mdsh

A simple static site generator, using Markdown and Bash
https://sc0ttj.github.io/mdsh/
10 stars 0 forks source link

Support cgi-bin #34

Open sc0ttj opened 5 years ago

sc0ttj commented 5 years ago

The main scripts should know if they're running in a cgi-bin ..

They should check for $REMOTE_HOST (or something.. look it up).

This could be useful for creating a web based admin interface for managing the site (we could use some other stuff I already made to get that going fairly quickly)..

Also, make Bash on Steroids and SQLite available if running in a cgi-bin..

When building a page, could do something like:

# create a post with Bash on Steroids CGI stuff
new post --with-cgi-backend

# create a post with sqlite3
new post --with-sqlite-backend

# create a post with both Bash on Steroids CGI stuff _and_ sqlite3
new post --with-backend
sc0ttj commented 5 years ago

Make various Mdsh functions available as an API, so we can POST stuff to the functions, and get back the output from the API response..

This could be useful for posting Markdown to mdsh, and getting back the converted output.. Which would pave the way for a nice Admin Panel running in a cgi-bin, via which users could create their pages.

Another use case would be to post JS, CSS (etc) to some endpoint, and get back the minified versions.

How to

Create the dir mdsh/api/, and put Bash-CGI scripts in there as endpoints, which are just wrappers around existing functions like process_markdown, mdsh2md, mo, generate_page_data, etc.

Example: mdsh/api/get-markdown

Post some Markdown to this endpoint, and it will run it through process_markdown and mdsh2md, then return the output.

Usage

Create a basic admin panel, that has:

On updating the text, we can use onChange or onKeyUp on the textarea, to periodically post the textarea contents using AJAX to these endpoints, get the response and add them to the page in a "preview" panel.