Compare commits
2 Commits
26988ecf6a
...
a0fe0024f2
Author | SHA1 | Date | |
---|---|---|---|
a0fe0024f2 | |||
6e3c4bf647 |
@ -10,7 +10,9 @@ type CliArgs struct {
|
|||||||
DBName string
|
DBName string
|
||||||
KeyFile string
|
KeyFile string
|
||||||
LogFile string
|
LogFile string
|
||||||
|
Port string
|
||||||
PicsDir string
|
PicsDir string
|
||||||
|
RSSFile string
|
||||||
WebDir string
|
WebDir string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,9 +20,11 @@ func HandleCliArgs() (*CliArgs, error) {
|
|||||||
var err error
|
var err error
|
||||||
cliArgs := new(CliArgs)
|
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")
|
logFile := flag.String("log", "/var/log/cpolis.log", "log file")
|
||||||
picsDir := flag.String("pics", "/var/www/cpolis/pics", "pictures directory")
|
picsDir := flag.String("pics", "/var/www/cpolis/pics", "pictures directory")
|
||||||
|
cliArgs.Port = fmt.Sprint(":", 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")
|
webDir := flag.String("web", "/var/www/cpolis/web", "web directory")
|
||||||
flag.StringVar(&cliArgs.DBName, "db", "cpolis", "DB name")
|
flag.StringVar(&cliArgs.DBName, "db", "cpolis", "DB name")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -29,14 +33,22 @@ func HandleCliArgs() (*CliArgs, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error finding absolute path for KeyFile: %v", err)
|
return nil, fmt.Errorf("error finding absolute path for KeyFile: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cliArgs.LogFile, err = filepath.Abs(*logFile)
|
cliArgs.LogFile, err = filepath.Abs(*logFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error finding absolute path for LogFile: %v", err)
|
return nil, fmt.Errorf("error finding absolute path for LogFile: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cliArgs.PicsDir, err = filepath.Abs(*picsDir)
|
cliArgs.PicsDir, err = filepath.Abs(*picsDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error finding absolute path for PicsDir: %v", err)
|
return nil, fmt.Errorf("error finding absolute path for PicsDir: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
cliArgs.WebDir, err = filepath.Abs(*webDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error finding absolute path for WebDir: %v", err)
|
return nil, fmt.Errorf("error finding absolute path for WebDir: %v", err)
|
||||||
|
@ -78,5 +78,5 @@ func main() {
|
|||||||
mux.HandleFunc("POST /update-user/", view.UpdateUser(args, db, store))
|
mux.HandleFunc("POST /update-user/", view.UpdateUser(args, db, store))
|
||||||
mux.HandleFunc("POST /upload-image/", view.UploadImage(args))
|
mux.HandleFunc("POST /upload-image/", view.UploadImage(args))
|
||||||
|
|
||||||
log.Fatalln(http.ListenAndServe(":8080", mux))
|
log.Fatalln(http.ListenAndServe(args.Port, mux))
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ func PublishArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) ht
|
|||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = control.SaveRSS("tmp/orientexpress_alle.rss", feed); err != nil {
|
if err = control.SaveRSS(c.RSSFile, feed); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
@ -18,8 +18,42 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="editor-images">
|
||||||
|
<input 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="/resubmit-article/" hx-target="#page-content" />
|
<input type="submit" value="Senden" hx-post="/resubmit-article/" hx-target="#page-content" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
|
<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>
|
||||||
|
{{.}}
|
||||||
|
<button onclick="copyToClipboard('{{.}}')">Kopieren</button>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user