From f160642b16c5da9c60d6004defc14f2afc95aa62 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 5 Jul 2023 18:58:03 -0300 Subject: Adds http_server and git modules; update IDEAS --- IDEAS.md | 4 +-- share/templater/git/files/Makefile.git | 8 ++++++ share/templater/git/setup | 2 ++ share/templater/http_server/description | 1 + .../http_server/files/Makefile.http_server | 18 ++++++++++++++ share/templater/http_server/setup | 25 +++++++++++++++++++ share/templater/sphinx/files/Makefile.sphinx | 3 ++- share/templater/templater/files/Makefile | 29 ++++++---------------- 8 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 share/templater/git/files/Makefile.git create mode 100644 share/templater/http_server/description create mode 100644 share/templater/http_server/files/Makefile.http_server create mode 100755 share/templater/http_server/setup diff --git a/IDEAS.md b/IDEAS.md index dd5e59e..d7a3843 100644 --- a/IDEAS.md +++ b/IDEAS.md @@ -1,5 +1,4 @@ -Ideas -===== +# Ideas * Bazaar: * README with basic info and HOWTO @@ -23,6 +22,7 @@ Ideas * [Wrangling Web Contributions: How to Build a CONTRIBUTING.md](https://mozillascience.github.io/working-open-workshop/contributing/) * [Good-CONTRIBUTING.md-template.md · GitHub](https://gist.github.com/PurpleBooth/b24679402957c63ec426) * [vue/CONTRIBUTING.md at dev · vuejs/vue · GitHub](https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md) + * More Code of Conduct flavors * Modules: * Python * Flask diff --git a/share/templater/git/files/Makefile.git b/share/templater/git/files/Makefile.git new file mode 100644 index 0000000..026176b --- /dev/null +++ b/share/templater/git/files/Makefile.git @@ -0,0 +1,8 @@ +# +# Makefile for Git-related tasks - https://templater.fluxo.info +# + +# Configure a git post-receive hook +post_receive: + git config receive.denyCurrentBranch ignore + test -s bin/post-receive && cd .git/hooks && ln -sf ../../bin/post-receive diff --git a/share/templater/git/setup b/share/templater/git/setup index 952e6ef..a9b26a0 100755 --- a/share/templater/git/setup +++ b/share/templater/git/setup @@ -18,6 +18,8 @@ function templater_git { templater_user_input GIT_USER User "-> Choose a git user name" templater_user_input GIT_EMAIL user@example.org "-> Choose a git email address" + templater_install_makefile $SHARE/git/files/Makefile.git + git init git config user.name "$GIT_USER" git config user.email "$GIT_EMAIL" diff --git a/share/templater/http_server/description b/share/templater/http_server/description new file mode 100644 index 0000000..836a709 --- /dev/null +++ b/share/templater/http_server/description @@ -0,0 +1 @@ +setup a simple HTTP server configuration diff --git a/share/templater/http_server/files/Makefile.http_server b/share/templater/http_server/files/Makefile.http_server new file mode 100644 index 0000000..c3d0ab3 --- /dev/null +++ b/share/templater/http_server/files/Makefile.http_server @@ -0,0 +1,18 @@ +# +# HTTP Server Makefile - https://templater.fluxo.info +# + +# Port to serve content +HTTP_PORT="8000" +HTTP_SERVER="http.server" + +# Base to serve the content +HTTP_BASE="." + +# See http://unix.stackexchange.com/questions/32182/simple-command-line-http-server#32200 +# http://php.net/manual/en/features.commandline.webserver.php +serve: + @if [ "$(HTTP_SERVER)" = "SimpleHTTPServer" ]; then cd $(HTTP_BASE) && python -m SimpleHTTPServer $(HTTP_PORT); fi + @if [ "$(HTTP_SERVER)" = "ssi_server" ]; then cd $(HTTP_BASE) && PYTHONDONTWRITEBYTECODE=0 ssi_server.py $(HTTP_PORT); fi + @if [ "$(HTTP_SERVER)" = "http.server" ]; then cd $(HTTP_BASE) && python3 -m http.server $(HTTP_PORT); fi + @if [ "$(HTTP_SERVER)" = "php" ]; then cd $(HTTP_BASE) && php -S localhost:$(HTTP_PORT); fi diff --git a/share/templater/http_server/setup b/share/templater/http_server/setup new file mode 100755 index 0000000..7983f73 --- /dev/null +++ b/share/templater/http_server/setup @@ -0,0 +1,25 @@ +#!/bin/bash +# +# HTTP Server templater module. +# + +# Parameters +SHARE="$1" + +# Include basic functions +source $SHARE/templater/functions || exit 1 + +# Sphinx implementation +function templater_http_server { + if [ ! -e "Makefile.http_server" ]; then + templater_echo "Setting up a basic HTTP Server functionality..." + + templater_install_makefile $SHARE/http_server/files/Makefile.http_server + + else + templater_echo "HTTP Server functionality already set" + fi +} + +# Dispatch +templater_http_server diff --git a/share/templater/sphinx/files/Makefile.sphinx b/share/templater/sphinx/files/Makefile.sphinx index 3369b20..eeaf393 100644 --- a/share/templater/sphinx/files/Makefile.sphinx +++ b/share/templater/sphinx/files/Makefile.sphinx @@ -1,4 +1,5 @@ -# Makefile for Sphinx documentation +# +# Makefile for Sphinx documentation - https://templater.fluxo.info # # You can set these variables from the command line. diff --git a/share/templater/templater/files/Makefile b/share/templater/templater/files/Makefile index 3a988d4..4f0db17 100644 --- a/share/templater/templater/files/Makefile +++ b/share/templater/templater/files/Makefile @@ -5,13 +5,6 @@ # any Makefile.* available in the current folder. # -# Port to serve content -HTTP_PORT="8000" -HTTP_SERVER="http.server" - -# Base to serve the content -HTTP_BASE="." - # Set CONTAINER based in what we have available in the system # This variable can be user in other, included Makefiles to handle virtualization tasks ifeq ($(shell which kvmx > /dev/null && test -s kvmxfile && echo yes), yes) @@ -24,18 +17,8 @@ else CONTAINER = '' endif -# See http://unix.stackexchange.com/questions/32182/simple-command-line-http-server#32200 -# http://php.net/manual/en/features.commandline.webserver.php -serve: - @if [ "$(HTTP_SERVER)" = "SimpleHTTPServer" ]; then cd $(HTTP_BASE) && python -m SimpleHTTPServer $(HTTP_PORT); fi - @if [ "$(HTTP_SERVER)" = "ssi_server" ]; then cd $(HTTP_BASE) && PYTHONDONTWRITEBYTECODE=0 ssi_server.py $(HTTP_PORT); fi - @if [ "$(HTTP_SERVER)" = "http.server" ]; then cd $(HTTP_BASE) && python3 -m http.server $(HTTP_PORT); fi - @if [ "$(HTTP_SERVER)" = "php" ]; then cd $(HTTP_BASE) && php -S localhost:$(HTTP_PORT); fi - -# Configure a git post-receive hook -post_receive: - git config receive.denyCurrentBranch ignore - test -s bin/post-receive && cd .git/hooks && ln -sf ../../bin/post-receive +# Default action +default: all # Process any other Makefile whose filename matches Makefile.* # See https://www.gnu.org/software/make/manual/html_node/Include.html @@ -45,6 +28,8 @@ post_receive: -include Makefile.* # Customization examples can be as simple as setting variables: -#CONTAINER = vagrant -#CONTAINER = docker -#DESTDIR ?= vendor +#CONTAINER = vagrant +#CONTAINER = docker +#DESTDIR ?= vendor +#HTTP_PORT ="8080" +#HTTP_SERVER ="ssi_server" -- cgit v1.2.3