Compare commits
	
		
			9 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 7e7de28b14 | |||
| 0139f7ab9a | |||
| 7fc115bcc3 | |||
| ae90f693f6 | |||
| a730e11b4a | |||
| 959e1e96b3 | |||
| 68b052625f | |||
| a0fe0024f2 | |||
| 6e3c4bf647 | 
							
								
								
									
										44
									
								
								.air.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								.air.toml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
root = "."
 | 
			
		||||
testdata_dir = "testdata"
 | 
			
		||||
tmp_dir = "tmp"
 | 
			
		||||
 | 
			
		||||
[build]
 | 
			
		||||
  args_bin = []
 | 
			
		||||
  bin = "./tmp/main -key tmp/key.gob -log tmp/cpolis.log -pics tmp/pics -rss tmp/orientexpress_alle.rss -web web"
 | 
			
		||||
  cmd = "go build -o ./tmp/main ./cmd/main.go"
 | 
			
		||||
  delay = 0
 | 
			
		||||
  exclude_dir = ["assets", "tmp", "vendor", "testdata"]
 | 
			
		||||
  exclude_file = []
 | 
			
		||||
  exclude_regex = ["_test.go"]
 | 
			
		||||
  exclude_unchanged = false
 | 
			
		||||
  follow_symlink = false
 | 
			
		||||
  full_bin = ""
 | 
			
		||||
  include_dir = []
 | 
			
		||||
  include_ext = ["go", "tpl", "tmpl", "html", "css"]
 | 
			
		||||
  include_file = []
 | 
			
		||||
  kill_delay = "0s"
 | 
			
		||||
  log = "build-errors.log"
 | 
			
		||||
  poll = false
 | 
			
		||||
  poll_interval = 0
 | 
			
		||||
  rerun = false
 | 
			
		||||
  rerun_delay = 500
 | 
			
		||||
  send_interrupt = false
 | 
			
		||||
  stop_on_error = false
 | 
			
		||||
 | 
			
		||||
[color]
 | 
			
		||||
  app = ""
 | 
			
		||||
  build = "yellow"
 | 
			
		||||
  main = "magenta"
 | 
			
		||||
  runner = "green"
 | 
			
		||||
  watcher = "cyan"
 | 
			
		||||
 | 
			
		||||
[log]
 | 
			
		||||
  main_only = false
 | 
			
		||||
  time = false
 | 
			
		||||
 | 
			
		||||
[misc]
 | 
			
		||||
  clean_on_exit = false
 | 
			
		||||
 | 
			
		||||
[screen]
 | 
			
		||||
  clear_on_rebuild = false
 | 
			
		||||
  keep_scroll = true
 | 
			
		||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -23,3 +23,4 @@ go.work
 | 
			
		||||
 | 
			
		||||
# Custom stuff
 | 
			
		||||
tmp/
 | 
			
		||||
style.css
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,9 @@ type CliArgs struct {
 | 
			
		||||
	DBName  string
 | 
			
		||||
	KeyFile string
 | 
			
		||||
	LogFile string
 | 
			
		||||
	Port    string
 | 
			
		||||
	PicsDir string
 | 
			
		||||
	RSSFile string
 | 
			
		||||
	WebDir  string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -18,9 +20,11 @@ func HandleCliArgs() (*CliArgs, error) {
 | 
			
		||||
	var err error
 | 
			
		||||
	cliArgs := new(CliArgs)
 | 
			
		||||
 | 
			
		||||
	keyFile := flag.String("key", "/var/www/cpolis.key", "key file")
 | 
			
		||||
	keyFile := flag.String("key", "/var/www/cpolis/cpolis.key", "key file")
 | 
			
		||||
	logFile := flag.String("log", "/var/log/cpolis.log", "log file")
 | 
			
		||||
	picsDir := flag.String("pics", "/var/www/cpolis/pics", "pictures directory")
 | 
			
		||||
	port := flag.Int("port", 8080, "port")
 | 
			
		||||
	rssFile := flag.String("rss", "/var/www/cpolis/cpolis.rss", "RSS file")
 | 
			
		||||
	webDir := flag.String("web", "/var/www/cpolis/web", "web directory")
 | 
			
		||||
	flag.StringVar(&cliArgs.DBName, "db", "cpolis", "DB name")
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
@@ -29,14 +33,24 @@ func HandleCliArgs() (*CliArgs, error) {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("error finding absolute path for KeyFile: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cliArgs.LogFile, err = filepath.Abs(*logFile)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("error finding absolute path for LogFile: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cliArgs.PicsDir, err = filepath.Abs(*picsDir)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("error finding absolute path for PicsDir: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cliArgs.Port = fmt.Sprint(":", *port)
 | 
			
		||||
 | 
			
		||||
	cliArgs.RSSFile, err = filepath.Abs(*rssFile)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("error finding absolute path for RSSFile: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cliArgs.WebDir, err = filepath.Abs(*webDir)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("error finding absolute path for WebDir: %v", err)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								cmd/main.go
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								cmd/main.go
									
									
									
									
									
								
							@@ -54,8 +54,14 @@ func main() {
 | 
			
		||||
	mux.HandleFunc("GET /edit-user/", view.EditUser(args, db, store))
 | 
			
		||||
	mux.HandleFunc("GET /hub/", view.ShowHub(args, db, store))
 | 
			
		||||
	mux.HandleFunc("GET /logout/", view.Logout(args, store))
 | 
			
		||||
	mux.HandleFunc("GET /publish-issue/", view.PublishLatestIssue(args, db, store))
 | 
			
		||||
	mux.HandleFunc("GET /rejected-articles/", view.ShowRejectedArticles(args, db, store))
 | 
			
		||||
	mux.HandleFunc("GET /publish-issue/",
 | 
			
		||||
		view.PublishLatestIssue(args, db, store))
 | 
			
		||||
	mux.HandleFunc("GET /rejected-articles/",
 | 
			
		||||
		view.ShowRejectedArticles(args, db, store))
 | 
			
		||||
	mux.HandleFunc("GET /review-rejected-article/{id}/",
 | 
			
		||||
		view.ReviewRejectedArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("GET /review-unpublished-article/{id}/",
 | 
			
		||||
		view.ReviewUnpublishedArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("GET /rss/", view.ShowRSS(args,
 | 
			
		||||
		db,
 | 
			
		||||
		"Freimaurer Distrikt Niedersachsen und Sachsen-Anhalt",
 | 
			
		||||
@@ -63,20 +69,22 @@ func main() {
 | 
			
		||||
		"Freiheit, Gleichheit, Brüderlichkeit, Toleranz und Humanität",
 | 
			
		||||
	))
 | 
			
		||||
	mux.HandleFunc("GET /this-issue/", view.ShowCurrentArticles(args, db))
 | 
			
		||||
	mux.HandleFunc("GET /unpublished-articles/", view.ShowUnpublishedArticles(args, db))
 | 
			
		||||
	mux.HandleFunc("GET /unpublished-articles/",
 | 
			
		||||
		view.ShowUnpublishedArticles(args, db))
 | 
			
		||||
	mux.HandleFunc("GET /write-article/", view.WriteArticle(args, db))
 | 
			
		||||
 | 
			
		||||
	mux.HandleFunc("POST /add-tag/", view.AddTag(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /add-user/", view.AddUser(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /login/", view.Login(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /publish-article/", view.PublishArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /reject-article/", view.RejectArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /resubmit-article/", view.ResubmitArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /review-rejected-article/", view.ReviewRejectedArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /review-unpublished-article/", view.ReviewUnpublishedArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /publish-article/{id}/",
 | 
			
		||||
		view.PublishArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /reject-article/{id}/",
 | 
			
		||||
		view.RejectArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /resubmit-article/{id}/",
 | 
			
		||||
		view.ResubmitArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /submit-article/", view.SubmitArticle(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /update-user/", view.UpdateUser(args, db, store))
 | 
			
		||||
	mux.HandleFunc("POST /upload-image/", view.UploadImage(args))
 | 
			
		||||
 | 
			
		||||
	log.Fatalln(http.ListenAndServe(":8080", mux))
 | 
			
		||||
	log.Fatalln(http.ListenAndServe(args.Port, mux))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -92,7 +92,7 @@ func SubmitArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) htt
 | 
			
		||||
 | 
			
		||||
func ResubmitArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		id, err := strconv.ParseInt(r.PostFormValue("article-id"), 10, 64)
 | 
			
		||||
		id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Println(err)
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
@@ -202,7 +202,7 @@ func ReviewUnpublishedArticle(c *control.CliArgs, db *model.DB, s *control.Cooki
 | 
			
		||||
		}
 | 
			
		||||
		data := new(htmlData)
 | 
			
		||||
 | 
			
		||||
		id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
 | 
			
		||||
		id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Println(err)
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
@@ -238,7 +238,7 @@ func ReviewRejectedArticle(c *control.CliArgs, db *model.DB, s *control.CookieSt
 | 
			
		||||
		}
 | 
			
		||||
		data := new(htmlData)
 | 
			
		||||
 | 
			
		||||
		id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
 | 
			
		||||
		id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Println(err)
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
@@ -278,7 +278,7 @@ func ReviewRejectedArticle(c *control.CliArgs, db *model.DB, s *control.CookieSt
 | 
			
		||||
 | 
			
		||||
func PublishArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
 | 
			
		||||
		id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Println(err)
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
@@ -319,7 +319,7 @@ func PublishArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) ht
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		if err = control.SaveRSS("tmp/orientexpress_alle.rss", feed); err != nil {
 | 
			
		||||
		if err = control.SaveRSS(c.RSSFile, feed); err != nil {
 | 
			
		||||
			log.Println(err)
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
			return
 | 
			
		||||
@@ -333,7 +333,7 @@ func PublishArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) ht
 | 
			
		||||
 | 
			
		||||
func RejectArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
 | 
			
		||||
		id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Println(err)
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								tailwind.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								tailwind.config.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
/** @type {import('tailwindcss').Config} */
 | 
			
		||||
module.exports = {
 | 
			
		||||
    content: ["./web/templates/*.html"],
 | 
			
		||||
    theme: {
 | 
			
		||||
        extend: {}
 | 
			
		||||
    },
 | 
			
		||||
    plugins: [],
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										41
									
								
								web/static/css/input.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								web/static/css/input.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
@tailwind base;
 | 
			
		||||
@tailwind components;
 | 
			
		||||
@tailwind utilities;
 | 
			
		||||
 | 
			
		||||
body {
 | 
			
		||||
    width: 800px;
 | 
			
		||||
    @apply mx-auto text-slate-900;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
h2 {
 | 
			
		||||
    @apply font-bold mb-2 text-2xl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
form {
 | 
			
		||||
    @apply flex flex-col gap-y-3;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
input[type="file"] {
 | 
			
		||||
    @apply border rounded-md w-full;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
input[type="password"],
 | 
			
		||||
input[type="text"] {
 | 
			
		||||
    @apply border h-8 rounded-md;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
textarea {
 | 
			
		||||
    @apply border h-32 rounded-md;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.btn-area {
 | 
			
		||||
    @apply flex gap-4 mt-4;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.btn {
 | 
			
		||||
    @apply bg-slate-50 border my-2 px-3 py-2 rounded-md w-full hover:bg-slate-100;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.action-btn {
 | 
			
		||||
    @apply bg-slate-800 border my-2 px-3 py-2 rounded-md text-slate-50 w-full hover:bg-slate-700;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,10 +1,12 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<h2>Neuer Benutzer</h2>
 | 
			
		||||
<h2>Neuer Tag</h2>
 | 
			
		||||
 | 
			
		||||
<form>
 | 
			
		||||
    <input required name="tag" placeholder="Tag" type="text" />
 | 
			
		||||
    <input type="submit" value="Anlegen" hx-post="/add-tag/" hx-target="#page-content" />
 | 
			
		||||
    <input required name="tag" placeholder="Tag eingeben" type="text" />
 | 
			
		||||
    <div class="btn-area">
 | 
			
		||||
        <input class="action-btn" type="submit" value="Anlegen" hx-post="/add-tag/" hx-target="#page-content" />
 | 
			
		||||
        <button class="btn" hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
    </div>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,33 +1,54 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<h2>Neuer Benutzer</h2>
 | 
			
		||||
<form>
 | 
			
		||||
    <div>
 | 
			
		||||
        <input required name="username" placeholder="Benutzername" type="text" value="{{.UserName}}" />
 | 
			
		||||
        <input required name="password" placeholder="Passwort" type="password" />
 | 
			
		||||
        <input required name="password2" placeholder="Passwort wiederholen" type="password" />
 | 
			
		||||
    <div class="grid grid-cols-3 gap-4">
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="username">Benutzername</label>
 | 
			
		||||
            <input class="w-full" required name="username" type="text" value="{{.UserName}}" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="password">Passwort</label>
 | 
			
		||||
            <input class="w-full" required name="password" placeholder="***" type="password" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="password2">Passwort wiederholen</label>
 | 
			
		||||
            <input class="w-full" required name="password2" placeholder="***" type="password" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="first-name">Vorname</label>
 | 
			
		||||
            <input class="w-full" required name="first-name" type="text" value="{{.FirstName}}" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="last-name">Nachname</label>
 | 
			
		||||
            <input class="w-full" required name="last-name" type="text" value="{{.LastName}}" />
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div>
 | 
			
		||||
        <input required name="first-name" placeholder="Vorname" type="text" value="{{.FirstName}}" />
 | 
			
		||||
        <input required name="last-name" placeholder="Nachname" type="text" value="{{.LastName}}" />
 | 
			
		||||
    <div class="flex gap-4">
 | 
			
		||||
        <div>
 | 
			
		||||
            <input required id="author" name="role" type="radio" value="3" {{if eq .Role 3 }}checked{{end}} />
 | 
			
		||||
            <label for="author">Autor</label>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <input required id="editor" name="role" type="radio" value="2" {{if eq .Role 2 }}checked{{end}} />
 | 
			
		||||
            <label for="editor">Redakteur</label>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <input required id="publisher" name="role" type="radio" value="1" {{if eq .Role 1 }}checked{{end}} />
 | 
			
		||||
            <label for="publisher">Herausgeber</label>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <input required id="admin" name="role" type="radio" value="0" {{if eq .Role 0 }}checked{{end}} />
 | 
			
		||||
            <label for="admin">Admin</label>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div>
 | 
			
		||||
        <input required id="author" name="role" type="radio" value="3" {{if eq .Role 3 }}checked{{end}} />
 | 
			
		||||
        <label for="author">Autor</label>
 | 
			
		||||
        <input required id="editor" name="role" type="radio" value="2" {{if eq .Role 2 }}checked{{end}} />
 | 
			
		||||
        <label for="editor">Redakteur</label>
 | 
			
		||||
        <input required id="publisher" name="role" type="radio" value="1" {{if eq .Role 1 }}checked{{end}} />
 | 
			
		||||
        <label for="publisher">Herausgeber</label>
 | 
			
		||||
        <input required id="admin" name="role" type="radio" value="0" {{if eq .Role 0 }}checked{{end}} />
 | 
			
		||||
        <label for="admin">Admin</label>
 | 
			
		||||
    <div class="btn-area">
 | 
			
		||||
        <input class="action-btn" type="submit" value="Anlegen" hx-post="/add-user/" hx-target="#page-content" />
 | 
			
		||||
        <button class="btn" hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <input type="submit" value="Anlegen" hx-post="/add-user/" hx-target="#page-content" />
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
    var msg = "{{.Msg}}";
 | 
			
		||||
    if (msg != "") {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,15 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<div>
 | 
			
		||||
<div class="flex flex-col gap-4">
 | 
			
		||||
    {{range .}}
 | 
			
		||||
    <div>
 | 
			
		||||
        <h1>{{.Title}}</h1>
 | 
			
		||||
    <div class="border px-2 py-1 rounded-md">
 | 
			
		||||
        <h1 class="font-bold text-2xl">{{.Title}}</h1>
 | 
			
		||||
        <p>{{.Description}}</p>
 | 
			
		||||
    </div>
 | 
			
		||||
    {{end}}
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/publish-issue/" hx-target="#page-content">Ausgabe publizieren</button>
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
<div class="btn-area">
 | 
			
		||||
    <button class="action-btn" hx-get="/publish-issue/" hx-target="#page-content">Ausgabe publizieren</button>
 | 
			
		||||
    <button class="btn" hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
</div>
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,19 +1,36 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<form>
 | 
			
		||||
    <div>
 | 
			
		||||
        <input name="username" type="text" value="{{.UserName}}" />
 | 
			
		||||
        <input name="first-name" type="text" value="{{.FirstName}}" />
 | 
			
		||||
        <input name="last-name" type="text" value="{{.LastName}}" />
 | 
			
		||||
    <div class="grid grid-cols-3 gap-4">
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="username">Benutzername</label>
 | 
			
		||||
            <input class="w-full" name="username" type="text" value="{{.UserName}}" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="first-name">Vorname</label>
 | 
			
		||||
            <input class="w-full" name="first-name" type="text" value="{{.FirstName}}" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="last-name">Nachname</label>
 | 
			
		||||
            <input class="w-full" name="last-name" type="text" value="{{.LastName}}" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="old-password">Altes Passwort</label>
 | 
			
		||||
            <input class="w-full" name="old-password" placeholder="***" type="password" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="password">Passwort</label>
 | 
			
		||||
            <input class="w-full" name="password" placeholder="***" type="password" />
 | 
			
		||||
        </div>
 | 
			
		||||
        <div>
 | 
			
		||||
            <label for="password2">Passwort wiederholen</label>
 | 
			
		||||
            <input class="w-full" name="password2" placeholder="***" type="password" />
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div>
 | 
			
		||||
        <input name="old-password" placeholder="Altes Passwort" type="password" />
 | 
			
		||||
        <input name="password" placeholder="Neues Passwort" type="password" />
 | 
			
		||||
        <input name="password2" placeholder="Wiederholen" type="password" />
 | 
			
		||||
    <div class="btn-area">
 | 
			
		||||
        <input class="action-btn" type="submit" value="Aktualisieren" hx-post="/update-user/"
 | 
			
		||||
            hx-target="#page-content" />
 | 
			
		||||
        <button class="btn" hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <input type="submit" value="Aktualisieren" hx-post="/update-user/" hx-target="#page-content" />
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,20 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<h2>Editor</h2>
 | 
			
		||||
<form>
 | 
			
		||||
    <div>
 | 
			
		||||
        <input name="article-title" placeholder="Titel" type="text" />
 | 
			
		||||
        <textarea name="article-description" placeholder="Beschreibung"></textarea>
 | 
			
		||||
        <textarea name="article-content" placeholder="Artikel"></textarea>
 | 
			
		||||
    <div class="flex flex-col gap-y-1">
 | 
			
		||||
        <label for="article-title">Titel</label>
 | 
			
		||||
        <input name="article-title" type="text" />
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="flex flex-col">
 | 
			
		||||
        <label for="article-description">Beschreibung</label>
 | 
			
		||||
        <textarea name="article-description"></textarea>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="flex flex-col">
 | 
			
		||||
        <label for="article-content">Artikel</label>
 | 
			
		||||
        <textarea name="article-content"></textarea>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div>
 | 
			
		||||
    <div class="flex gap-4">
 | 
			
		||||
        {{range .}}
 | 
			
		||||
        <div>
 | 
			
		||||
            <input id="{{.Name}}" name="tags" type="checkbox" value="{{.ID}}" />
 | 
			
		||||
@@ -17,15 +24,16 @@
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div id="editor-images">
 | 
			
		||||
        <input name="article-image" type="file" hx-encoding="multipart/form-data" hx-post="/upload-image/"
 | 
			
		||||
        <input class="mb-2" name="article-image" type="file" hx-encoding="multipart/form-data" hx-post="/upload-image/"
 | 
			
		||||
            hx-swap="beforeend" hx-target="#editor-images" />
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <input type="submit" value="Senden" hx-post="/submit-article/" hx-target="#page-content" />
 | 
			
		||||
    <div class="btn-area">
 | 
			
		||||
        <input class="action-btn" type="submit" value="Senden" hx-post="/submit-article/" hx-target="#page-content" />
 | 
			
		||||
        <button class="btn" hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
    </div>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Abbrechen</button>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
    function copyToClipboard(text) {
 | 
			
		||||
        event.preventDefault(); // Get-Request verhindern
 | 
			
		||||
@@ -49,9 +57,10 @@
 | 
			
		||||
 | 
			
		||||
{{define "editor-images"}}
 | 
			
		||||
{{if gt (len .) 0}}
 | 
			
		||||
<div>
 | 
			
		||||
    {{.}}
 | 
			
		||||
    <button onclick="copyToClipboard('{{.}}')">Kopieren</button>
 | 
			
		||||
<div class="border px-2 py-1 rounded-md flex gap-4 justify-between">
 | 
			
		||||
    <div class="self-center">{{.}}</div>
 | 
			
		||||
    <button class="bg-slate-50 border my-2 px-3 py-2 rounded-md w-32 hover:bg-slate-100"
 | 
			
		||||
        onclick="copyToClipboard('{{.}}')">Kopieren</button>
 | 
			
		||||
</div>
 | 
			
		||||
{{end}}
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,25 +1,40 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<h2>Hub</h2>
 | 
			
		||||
<div>
 | 
			
		||||
    <button hx-get="/write-article/" hx-target="#page-content">Artikel schreiben</button>
 | 
			
		||||
    <button hx-get="/rejected-articles/" hx-target="#page-content">Abgelehnte Artikel</button>
 | 
			
		||||
    <button hx-get="/rss/" hx-target="#page-content">RSS Feed</button>
 | 
			
		||||
    <button hx-get="/edit-user/" hx-target="#page-content">Benutzer bearbeiten</button>
 | 
			
		||||
</div>
 | 
			
		||||
{{if lt . 3}}
 | 
			
		||||
<div>
 | 
			
		||||
    <button hx-get="/unpublished-articles/" hx-target="#page-content">Unveröffentlichte Artikel</button>
 | 
			
		||||
    <button hx-get="/create-tag/" hx-target="#page-content">Neuer Tag</button>
 | 
			
		||||
<div class="flex flex-col gap-4">
 | 
			
		||||
    <div class="mb-3">
 | 
			
		||||
        <h2>Autor</h2>
 | 
			
		||||
        <div class="grid grid-cols-2 gap-x-4 gap-y-2">
 | 
			
		||||
            <button class="btn" hx-get="/write-article/" hx-target="#page-content">Artikel schreiben</button>
 | 
			
		||||
            <button class="btn" hx-get="/rejected-articles/" hx-target="#page-content">Abgelehnte Artikel</button>
 | 
			
		||||
            <button class="btn" hx-get="/rss/" hx-target="#page-content">RSS Feed</button>
 | 
			
		||||
            <button class="btn" hx-get="/edit-user/" hx-target="#page-content">Benutzer bearbeiten</button>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    {{if lt . 3}}
 | 
			
		||||
    <div class="mb-3">
 | 
			
		||||
        <h2>Redakteur</h2>
 | 
			
		||||
        <div class="grid grid-cols-2 gap-4">
 | 
			
		||||
            <button class="btn" hx-get="/unpublished-articles/" hx-target="#page-content">
 | 
			
		||||
                Unveröffentlichte Artikel
 | 
			
		||||
            </button>
 | 
			
		||||
            <button class="btn" hx-get="/create-tag/" hx-target="#page-content">Neuer Tag</button>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    {{end}}
 | 
			
		||||
    {{if lt . 2}}
 | 
			
		||||
    <div class="mb-3">
 | 
			
		||||
        <h2>Herausgeber</h2>
 | 
			
		||||
        <div class="grid grid-cols-2 gap-4">
 | 
			
		||||
            <button class="btn" hx-get="/this-issue/" hx-target="#page-content">Diese Ausgabe</button>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    {{end}}
 | 
			
		||||
    {{if eq . 0}}
 | 
			
		||||
    <div class="mb-3">
 | 
			
		||||
        <h2>Administrator</h2>
 | 
			
		||||
        <div class="grid grid-cols-2 gap-4">
 | 
			
		||||
            <button class="btn" hx-get="/create-user/" hx-target="#page-content">Benutzer hinzufügen</button>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    {{end}}
 | 
			
		||||
</div>
 | 
			
		||||
{{end}}
 | 
			
		||||
{{if lt . 2}}
 | 
			
		||||
<div>
 | 
			
		||||
    <button hx-get="/this-issue/" hx-target="#page-content">Diese Ausgabe</button>
 | 
			
		||||
</div>
 | 
			
		||||
{{end}}
 | 
			
		||||
{{if eq . 0}}
 | 
			
		||||
<div>
 | 
			
		||||
    <button hx-get="/create-user/" hx-target="#page-content">Benutzer hinzufügen</button>
 | 
			
		||||
</div>
 | 
			
		||||
{{end}}
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,13 +5,13 @@
 | 
			
		||||
    <meta charset="UTF-8">
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
    <title>Orient Editor</title>
 | 
			
		||||
    <link href="web/static/css/style.css" rel="stylesheet">
 | 
			
		||||
    <link href="/web/static/css/style.css" rel="stylesheet">
 | 
			
		||||
</head>
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
    <header>
 | 
			
		||||
        <h1>Orient Editor</h1>
 | 
			
		||||
        <button hx-get="logout" hx-target="#page-content">Abmelden</button>
 | 
			
		||||
<body class="flex flex-col justify-between min-h-[100dvh] bg-slate-50">
 | 
			
		||||
    <header class="my-8">
 | 
			
		||||
        <h1 class="font-bold text-4xl text-center">Orient Editor</h1>
 | 
			
		||||
        <button class="btn" hx-get="logout" hx-target="#page-content">Abmelden</button>
 | 
			
		||||
    </header>
 | 
			
		||||
 | 
			
		||||
    <main>
 | 
			
		||||
@@ -19,11 +19,13 @@
 | 
			
		||||
            {{template "page-content" .}}
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <script src="web/static/js/htmx.min.js"></script>
 | 
			
		||||
        <script src="/web/static/js/htmx.min.js"></script>
 | 
			
		||||
    </main>
 | 
			
		||||
 | 
			
		||||
    <footer>
 | 
			
		||||
        <p>© 2024 Jason Streifling. Alle Rechte vorbehalten.</p>
 | 
			
		||||
    <footer class="my-8">
 | 
			
		||||
        <p class="text-center text-gray-500 dark:text-gray-400">
 | 
			
		||||
            © 2024 Jason Streifling. Alle Rechte vorbehalten.
 | 
			
		||||
        </p>
 | 
			
		||||
    </footer>
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<h2>Anmeldung</h2>
 | 
			
		||||
<form>
 | 
			
		||||
    <div>
 | 
			
		||||
        <input name="username" placeholder="Benutzername" type="text" />
 | 
			
		||||
        <input name="password" placeholder="Passwort" type="password" />
 | 
			
		||||
    <div class="btn-area">
 | 
			
		||||
        <input class="w-full" name="username" placeholder="Benutzername" type="text" />
 | 
			
		||||
        <input class="w-full" name="password" placeholder="Passwort" type="password" />
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <input type="submit" value="Anmelden" hx-post="/login/" hx-target="#page-content" />
 | 
			
		||||
    <input class="action-btn" type="submit" value="Anmelden" hx-post="/login/" hx-target="#page-content" />
 | 
			
		||||
</form>
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,14 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<form>
 | 
			
		||||
    <div>
 | 
			
		||||
        {{range .RejectedArticles}}
 | 
			
		||||
        <div>
 | 
			
		||||
            {{if index $.MyIDs .ID}}
 | 
			
		||||
            <input required id="{{.ID}}" name="id" type="radio" value="{{.ID}}" />
 | 
			
		||||
            <label for="{{.ID}}">{{.Title}}</label>
 | 
			
		||||
            {{end}}
 | 
			
		||||
        </div>
 | 
			
		||||
        {{end}}
 | 
			
		||||
    </div>
 | 
			
		||||
<div class="flex flex-col gap-4">
 | 
			
		||||
    {{range .RejectedArticles}}
 | 
			
		||||
    {{if index $.MyIDs .ID}}
 | 
			
		||||
    <button class="btn" hx-get="/review-rejected-article/{{.ID}}/" hx-target="#page-content">
 | 
			
		||||
        <h1 class="font-bold text-2xl">{{.Title}}</h1>
 | 
			
		||||
        <p>{{.Description}}</p>
 | 
			
		||||
    </button>
 | 
			
		||||
    {{end}}
 | 
			
		||||
    {{end}}
 | 
			
		||||
 | 
			
		||||
    <input type="submit" value="Auswählen" hx-post="/review-rejected-article/" hx-target="#page-content" />
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
 | 
			
		||||
    <button class="action-btn" hx-get="/hub/" hx-target="#page-content">Zurück</button>
 | 
			
		||||
</div>
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,20 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<h2>Editor</h2>
 | 
			
		||||
<form>
 | 
			
		||||
    <div>
 | 
			
		||||
        <input name="article-title" placeholder="Titel" type="text" value="{{.Article.Title}}" />
 | 
			
		||||
        <textarea name="article-description" placeholder="Beschreibung">{{.Article.Description}}</textarea>
 | 
			
		||||
    <div class="flex flex-col gap-y-1">
 | 
			
		||||
        <label for="article-title">Titel</label>
 | 
			
		||||
        <input name="article-title" type="text" value="{{.Article.Title}}" />
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="flex flex-col">
 | 
			
		||||
        <label for="article-description">Beschreibung</label>
 | 
			
		||||
        <textarea name="article-description">{{.Article.Description}}</textarea>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="flex flex-col">
 | 
			
		||||
        <label for="article-content">Artikel</label>
 | 
			
		||||
        <textarea name="article-content" placeholder="Artikel">{{.Article.Content}}</textarea>
 | 
			
		||||
        <input name="article-id" type="hidden" value="{{.Article.ID}}" />
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div>
 | 
			
		||||
    <div class="flex gap-4">
 | 
			
		||||
        {{range .Tags}}
 | 
			
		||||
        <div>
 | 
			
		||||
            <input id="tag-{{.Name}}" name="tags" type="checkbox" value="{{.ID}}" {{if index $.Selected
 | 
			
		||||
@@ -18,8 +24,45 @@
 | 
			
		||||
        {{end}}
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <input type="submit" value="Senden" hx-post="/resubmit-article/" hx-target="#page-content" />
 | 
			
		||||
    <div id="editor-images">
 | 
			
		||||
        <input class="mb-2" name="article-image" type="file" hx-encoding="multipart/form-data" hx-post="/upload-image/"
 | 
			
		||||
            hx-swap="beforeend" hx-target="#editor-images" />
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="btn-area">
 | 
			
		||||
        <input class="action-btn" type="submit" value="Senden" hx-post="/resubmit-article/{{.Article.ID}}/"
 | 
			
		||||
            hx-target="#page-content" />
 | 
			
		||||
        <button class="btn" hx-get="/hub/" hx-target="#page-content">Zurück</button>
 | 
			
		||||
    </div>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
 | 
			
		||||
<script>
 | 
			
		||||
    function copyToClipboard(text) {
 | 
			
		||||
        event.preventDefault(); // Get-Request verhindern
 | 
			
		||||
 | 
			
		||||
        var textarea = document.createElement("textarea");
 | 
			
		||||
        textarea.textContent = text;
 | 
			
		||||
        document.body.appendChild(textarea);
 | 
			
		||||
 | 
			
		||||
        textarea.select();
 | 
			
		||||
        try {
 | 
			
		||||
            document.execCommand('copy');
 | 
			
		||||
        } catch (err) {
 | 
			
		||||
            console.warn('Fehler beim Kopieren', err);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        document.body.removeChild(textarea);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "editor-images"}}
 | 
			
		||||
{{if gt (len .) 0}}
 | 
			
		||||
<div class="border px-2 py-1 rounded-md flex gap-4 justify-between">
 | 
			
		||||
    <div class="self-center">{{.}}</div>
 | 
			
		||||
    <button class="bg-slate-50 border my-2 px-3 py-2 rounded-md w-32 hover:bg-slate-100"
 | 
			
		||||
        onclick="copyToClipboard('{{.}}')">Kopieren</button>
 | 
			
		||||
</div>
 | 
			
		||||
{{end}}
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,10 +10,12 @@
 | 
			
		||||
        {{end}}
 | 
			
		||||
    </p>
 | 
			
		||||
 | 
			
		||||
    <input name="id" type="hidden" value="{{.Article.ID}}" />
 | 
			
		||||
    <input type="submit" value="Veröffentlichen" hx-post="/publish-article/" hx-target="#page-content" />
 | 
			
		||||
    <input type="submit" value="Ablehnen" hx-post="/reject-article/" hx-target="#page-content" />
 | 
			
		||||
    <div class="btn-area">
 | 
			
		||||
        <input class="action-btn" type="submit" value="Veröffentlichen" hx-post="/publish-article/{{.Article.ID}}/"
 | 
			
		||||
            hx-target="#page-content" />
 | 
			
		||||
        <input class="btn" type="submit" value="Ablehnen" hx-post="/reject-article/{{.Article.ID}}/"
 | 
			
		||||
            hx-target="#page-content" />
 | 
			
		||||
        <button class="btn" hx-get="/hub/" hx-target="#page-content">Zurück</button>
 | 
			
		||||
    </div>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,11 @@
 | 
			
		||||
{{define "page-content"}}
 | 
			
		||||
<form>
 | 
			
		||||
    <div>
 | 
			
		||||
        {{range .}}
 | 
			
		||||
        <div>
 | 
			
		||||
            <input required id="{{.ID}}" name="id" type="radio" value="{{.ID}}" />
 | 
			
		||||
            <label for="{{.ID}}">{{.Title}}</label>
 | 
			
		||||
        </div>
 | 
			
		||||
        {{end}}
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <input type="submit" value="Auswählen" hx-post="/review-unpublished-article/" hx-target="#page-content" />
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
 | 
			
		||||
<div class="flex flex-col gap-4">
 | 
			
		||||
    {{range .}}
 | 
			
		||||
    <button class="btn" hx-get="/review-unpublished-article/{{.ID}}/" hx-target="#page-content">
 | 
			
		||||
        <h1 class="font-bold text-2xl">{{.Title}}</h1>
 | 
			
		||||
        <p>{{.Description}}</p>
 | 
			
		||||
    </button>
 | 
			
		||||
    {{end}}
 | 
			
		||||
    <button class="btn" hx-get="/hub/" hx-target="#page-content">Zurück</button>
 | 
			
		||||
</div>
 | 
			
		||||
{{end}}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user