aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-09 16:54:52 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-12 12:01:51 +0200
commit2d498443031c1831925d9ba91f8795b7f994677f (patch)
tree5952a1ae36d41ce20a8257f34c7f9487131203db /templates
parent1e0ae41f1ec06379a6602613612c085ad053c0fa (diff)
Split server code and http code
Create multiple instances of Ideez by running NewIdeez(), after creating they can be added to the Ideezes slice to manage them. NewIdeez() imports the data and registers the routes. main.go has the code for managing the instances and server.go has the code coupled to a single instance. For eg. main.go has the code which checks files with .data extension in data directory, and imports servers on startup. - Add import functionality - Add nginx configuration - Add style and copy animation - Check for https with "X-Forwarded-Proto" - Change assets and templates to reflect the new id change - Change port to 15118 - Add Id field to Idea - Do not check for duplicate titles anymore - Extract ideez_servers into const variable - Extract documentation in doc.go - Rename Server -> Ideez - Rename t_idea/ -> templates/ - Fix cancel not working with form by using javascript instead - Set logger prefix in different contexts
Diffstat (limited to 'templates')
-rw-r--r--templates/edit.html52
-rw-r--r--templates/ideas.html44
-rw-r--r--templates/servers.html28
3 files changed, 124 insertions, 0 deletions
diff --git a/templates/edit.html b/templates/edit.html
new file mode 100644
index 0000000..fef6846
--- /dev/null
+++ b/templates/edit.html
@@ -0,0 +1,52 @@
+{{ with .Idea}}
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta property="og:title" content="Editing '{{.Title}}'"/>
+ <meta property="og:image" content="/static/favicon.ico" />
+ <link rel="stylesheet" href="/static/main.css">
+ <title>Editing "{{.Title}}"</title>
+ <style>
+textarea[name="text"] {
+ color: #4c4c4c;
+ border: dashed 1px black;
+ font-size: 1.25em;
+ font-family: monospace;
+ width: 93%;
+ margin-left: 3%;
+ margin-right: 4%;
+}
+input[name="title"] {
+ color: #4c4c4c;
+ border: dashed 1px black;
+ font-weight: bold;
+ font-size: 2em;
+ display: inline;
+ width: 90%;
+}
+ </style>
+ </head>
+ <body>
+ <h3>Editing "{{.Title}}"</h3>
+ <hr>
+ <div class="idea">
+ <form action="{{$.RoutePrefix}}/idea/edit/" method="post">
+ <input name="title" type="text" value="{{.Title}}"><br>
+ <textarea name="text" rows=6 required>{{.Text}}</textarea>
+ <p class="creation">by <span class="author">{{.Author}}</span> on <span class="date">{{.LastUpdated}}</span></p>
+ <input type="hidden" name="id" value="{{.Id}}"}}>
+ <input type="submit" value="confirm">
+ </form>
+ <button id="cancel">cancel</button>
+ </div>
+ </body>
+</html>
+<script defer>
+ let cancelButton = document.getElementById("cancel")
+ cancelButton.onclick = function() {
+ window.location = "{{$.RoutePrefix}}"
+ }
+</script>
+{{end}}
diff --git a/templates/ideas.html b/templates/ideas.html
new file mode 100644
index 0000000..e233000
--- /dev/null
+++ b/templates/ideas.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta property="og:title" content="{{.Name}} Ideez"/>
+ <meta property="og:description" content="Find all {{.Name}} ideez here!"/>
+ <meta property="og:image" content="/static/favicon.ico" />
+ <link rel="stylesheet" href="/static/main.css">
+ <script src="/static/index.js" defer></script>
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
+ <title>{{.Name}} Ideez</title>
+ </head>
+ <body>
+ {{ with .Error }}
+ <p class="error">{{.}}</p>
+ {{ end}}
+ <h3>Add an idea to <span title="copy link to Ideez" id="link">{{.Name}}</span>:</h3>
+ <form action="{{.RoutePrefix}}/idea/create/" method="post">
+ <input name="title" type="text" placeholder="Title" required></br>
+ <textarea name="text" cols=50 rows=4 placeholder="Write what is in your lightbulb here." required></textarea>
+ </br>
+ <input name="author" type="text" placeholder="Your Name" required></br>
+ <input type="submit" value="Think">
+ </form>
+ <hr>
+ <ul>
+ {{ range .Ideas }}
+ <div class="idea">
+ <h2 class="title">{{.Title}}</h2>
+ <pre class="text">{{.Text}}</pre>
+ <p class="creation">by <span class="author">{{.Author}}</span> on <span class="date">{{.LastUpdated}}</span></p>
+ <form action="{{$.RoutePrefix}}/idea/delete/" method="post">
+ <input type="hidden" name="id" value="{{.Id}}">
+ <input type="submit" value="delete">
+ </form>
+ <button class="edit" idea-id="{{.Id}}">edit</button>
+ </div>
+ {{ else }}
+ <p><i>No ideas here... Be the first one to think!</i></p>
+ {{ end }}
+ </ul>
+ </body>
+</html>
diff --git a/templates/servers.html b/templates/servers.html
new file mode 100644
index 0000000..f35f4e9
--- /dev/null
+++ b/templates/servers.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta property="og:title" content="Ideez"/>
+ <meta property="og:description" content="Ideez is an app that you can storm with ideas, hoping to facilitate plans and brainstorms."/>
+ <meta property="og:image" content="/static/favicon.ico" />
+ <link rel="stylesheet" href="/static/main.css">
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
+ <title>Servers</title>
+ </head>
+ <body>
+ {{ with .Error }}
+ <p class="error">{{.}}</p>
+ {{ end}}
+ <form method="post" action="/server/create/">
+ <input name="name" type="text" placeholder="Ideez Server Name" required>
+ <button>Create Server</button>
+ </form>
+ <hr>
+ <ul>
+ {{range .Ideezes}}
+ <li><a href="{{$.Address}}/server/{{.ID}}/">{{.Name}}</a></li>
+ {{end}}
+ <ul>
+ </body>
+</html>