summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2020-12-22 16:01:53 +0100
committerxengineering <mail2xengineering@protonmail.com>2020-12-22 16:01:53 +0100
commit699bf610169daeb47bdcc894eb13fa1a706dc50b (patch)
tree66b3f619fece14608e83d98228ec9c200dcbc236
parent7a89708c46b33d6d91164ff66d86d3c2471f531a (diff)
downloadweb-template-699bf610169daeb47bdcc894eb13fa1a706dc50b.tar
web-template-699bf610169daeb47bdcc894eb13fa1a706dc50b.tar.zst
web-template-699bf610169daeb47bdcc894eb13fa1a706dc50b.zip
Switch to static Web App
-rw-r--r--README.md28
-rw-r--r--config.json11
-rwxr-xr-xmain.py49
-rwxr-xr-xmanage.py45
-rw-r--r--templates/index.html40
-rw-r--r--webroot/css/xengineering.css (renamed from static/css/style.css)22
-rw-r--r--webroot/favicon.ico (renamed from static/img/favicon.ico)bin6715 -> 6715 bytes
-rw-r--r--webroot/index.html28
-rw-r--r--webroot/template.html28
9 files changed, 128 insertions, 123 deletions
diff --git a/README.md b/README.md
index 34376ff..a9f6052 100644
--- a/README.md
+++ b/README.md
@@ -2,26 +2,15 @@
# Web Template
-A template project for dynamic web applications.
+A template project for mixed static / dynamic web applications.
## Usage
-### Just try it
-```
-# Install Flask and waitress with your linux package manager.
-# Otherwise you could use pip:
-pip3 install --user Flask waitress
-
-git clone https://github.com/xengineering/web-template.git
-cd web-template
-python3 main.py
-
-# switch to another terminal
-
-curl http://localhost:8080 # test with curl
-firefox http://localhost:8080 # test with firefox
-```
+Just follow these steps:
+1. Edit config.json
+2. Edit the files in the webroot folder
+3. Upload the webroot to your target server with ```python3 manage.py deploy``` via SSH / rsync
### Use it for your Project
```
@@ -37,10 +26,3 @@ git fetch template
git merge template/master
```
-
-## Used Technologies
-
-- [Python 3](https://www.python.org/)
-- [Python Flask](https://palletsprojects.com/p/flask/)
-- [Waitress WSGI Server](https://github.com/Pylons/waitress)
-- Pure HTML, CSS and JavaScript
diff --git a/config.json b/config.json
new file mode 100644
index 0000000..1ad14b1
--- /dev/null
+++ b/config.json
@@ -0,0 +1,11 @@
+
+{
+ "deployments":[
+ {
+ "host":"example.com",
+ "username":"exampleuser",
+ "webroot":"/srv/http/example.com/public/"
+ }
+ ]
+}
+
diff --git a/main.py b/main.py
deleted file mode 100755
index 0cd7c61..0000000
--- a/main.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/python3
-
-
-"""
- web-template - A Template Project for dynamic Web Applications.
-
- Copyright (C) 2020 xengineering
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-"""
-
-
-from waitress import serve
-from flask import Flask, render_template, current_app
-
-
-app = Flask(__name__)
-
-
-@app.route('/')
-def index():
- return render_template('index.html')
-
-
-@app.route('/static/css/<css_file>')
-def css(css_file):
- return current_app.send_static_file("css/{}".format(css_file))
-
-
-@app.route('/favicon.ico')
-def favicon():
- return current_app.send_static_file("img/favicon.ico")
-
-
-if __name__ == '__main__':
- serve(app, listen='*:8080') # production server / bind to port
- #serve(app, unix_socket='/run/web-template/unix.sock') # production server / unix domain socket
- #app.run() # debug server - NOT FOR PRODUCTION!
diff --git a/manage.py b/manage.py
new file mode 100755
index 0000000..50249e5
--- /dev/null
+++ b/manage.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+
+
+import sys
+import subprocess
+import json
+
+
+CONFIG_PATH = "./config.json"
+
+
+def main():
+
+ if len(sys.argv) != 2:
+ print("Provide exactly one parameter")
+ sys.exit(1)
+
+ cfg = read_config()
+
+ command = sys.argv[1]
+
+ if command == "deploy":
+ for deployment in cfg["deployments"]:
+ subprocess.call(
+ "rsync -av ./webroot/ {0}@{1}:{2}".format(
+ deployment["username"],
+ deployment["host"],
+ deployment["webroot"]
+ ),
+ shell=True
+ )
+ else:
+ print("Unknown command")
+
+def read_config():
+ with open(CONFIG_PATH, "r") as f:
+ content = f.read()
+ return json.loads(content)
+
+if __name__ == "__main__":
+ main()
+
+
+# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab
+
diff --git a/templates/index.html b/templates/index.html
deleted file mode 100644
index 67e2d78..0000000
--- a/templates/index.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<!--
- web-template - A Template Project for dynamic Web Applications.
-
- Copyright (C) 2020 xengineering
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
--->
-<html>
- <head>
- <title>Web Template</title>
- <meta charset="utf-8"/>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" href="static/css/style.css" type="text/css">
- </head>
- <body>
- <div class="menu">
- <a href="http://localhost:8080/">HOME</a>
- <a href="https://xengineering.eu">xengineering</a>
- </div>
- <div class="content-frame">
- <div class="content">
- <header><h1>Web Template</h1></header>
- <p>
- Lorem ipsum.
- </p>
- </div>
- </div>
- </body>
-</html>
diff --git a/static/css/style.css b/webroot/css/xengineering.css
index fd92176..1e14b72 100644
--- a/static/css/style.css
+++ b/webroot/css/xengineering.css
@@ -33,21 +33,21 @@ body {
font-family: Arial, Helvetica, sans-serif; /* select a nice font */
}
-.menu {
+.xmenu {
background-color: black;
}
-.content {
+.xcontent {
background-color: white;
}
-.menu a {
+.xmenu a {
color: lightgray;
text-decoration: none; /* disable ugly underlined links */
}
/* How should the link behave if the mouse is over this item? */
-.menu a:hover {
+.xmenu a:hover {
background-color: lightgray;
color: black;
}
@@ -58,13 +58,13 @@ body {
Default Geometry / Geometry for Phones ('Mobile First Development')
*/
-.content {
+.xcontent {
padding-left: 20px;
padding-right: 20px;
text-align: justify;
}
-.menu a {
+.xmenu a {
display: block;
padding: 16px;
text-align: center;
@@ -88,22 +88,22 @@ body {
@media only screen and (min-width: 768px) {
- .menu {
+ .xmenu {
height: 100%;
width: 200px;
position: fixed; /* position fixed in top left corner (with offset) */
top: 0px; /* disable the offset from top left corner */
}
- .menu a {
+ .xmenu a {
text-align: left;
}
- .content {
- margin-left: 200px; /* transparent margin on the left for .menu */
+ .xcontent {
+ margin-left: 200px; /* transparent margin on the left for .xmenu */
}
- .content *{ /* everything inside the content container */
+ .xcontent *{ /* everything inside the content container */
max-width: 960px; /* maximum width on desktops should be 960 px */
margin-left: auto; /* center it with margin */
margin-right: auto; /* center it with margin */
diff --git a/static/img/favicon.ico b/webroot/favicon.ico
index 969b451..969b451 100644
--- a/static/img/favicon.ico
+++ b/webroot/favicon.ico
Binary files differ
diff --git a/webroot/index.html b/webroot/index.html
new file mode 100644
index 0000000..59922a2
--- /dev/null
+++ b/webroot/index.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+
+<html>
+
+ <head>
+
+ <title>Web Template</title>
+
+ <meta charset="utf-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" href="css/xengineering.css" type="text/css">
+
+ </head>
+
+ <body>
+
+ <div class="xmenu">
+ <a href="https://example.com">HOME</a>
+ </div>
+
+ <div class="xcontent">
+ <h1>Web Template</h1>
+ </div>
+
+ </body>
+
+</html>
+
diff --git a/webroot/template.html b/webroot/template.html
new file mode 100644
index 0000000..b8ce99a
--- /dev/null
+++ b/webroot/template.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+
+<html>
+
+ <head>
+
+ <title>Web Template</title>
+
+ <meta charset="utf-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" href="xengineering.css" type="text/css">
+
+ </head>
+
+ <body>
+
+ <div class="xmenu">
+ <a href="https://example.com">HOME</a>
+ </div>
+
+ <div class="xcontent">
+ <h1>Web Template</h1>
+ </div>
+
+ </body>
+
+</html>
+