mirror of
https://github.com/gmemstr/pogo.git
synced 2024-09-19 17:21:10 +01:00
Reorganizing file directory structure to match other Golang projects
This commit is contained in:
parent
019e303b3b
commit
4dd25948f6
|
@ -18,3 +18,5 @@ feed\.json
|
|||
podcasts/
|
||||
|
||||
feed\.rss
|
||||
|
||||
.travis\.yml
|
|
@ -18,7 +18,8 @@ RUN apt update; apt install build-essential -y && \
|
|||
make linux && chmod +x whiterabbit && \
|
||||
ls -al && \
|
||||
mkdir podcasts && \
|
||||
touch feed.rss feed.json && echo '{}' >feed.json
|
||||
touch assets/web/feed.rss assets/web/feed.json && \
|
||||
echo '{}' >assets/web/feed.json
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
|
|
2
src/Godeps/Godeps.json → Godeps/Godeps.json
generated
2
src/Godeps/Godeps.json → Godeps/Godeps.json
generated
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"ImportPath": "podcast/src",
|
||||
"ImportPath": "podcast",
|
||||
"GoVersion": "go1.8",
|
||||
"GodepVersion": "v79",
|
||||
"Deps": [
|
0
src/Godeps/Readme → Godeps/Readme
generated
0
src/Godeps/Readme → Godeps/Readme
generated
12
Makefile
12
Makefile
|
@ -1,11 +1,11 @@
|
|||
all:
|
||||
go build src/webserver.go src/admin.go src/generate_rss.go src/setup.go src/configreader.go
|
||||
go build webserver.go admin.go generate_rss.go setup.go configreader.go
|
||||
|
||||
windows: src/admin.go src/webserver.go src/generate_rss.go
|
||||
go build -o pogoapp.exe src/webserver.go src/admin.go src/generate_rss.go src/setup.go
|
||||
windows: admin.go webserver.go generate_rss.go
|
||||
go build -o pogoapp.exe webserver.go admin.go generate_rss.go setup.go
|
||||
|
||||
linux: src/admin.go src/webserver.go src/generate_rss.go
|
||||
go build -o pogoapp src/webserver.go src/admin.go src/generate_rss.go src/setup.go
|
||||
linux: admin.go webserver.go generate_rss.go
|
||||
go build -o pogoapp webserver.go admin.go generate_rss.go setup.go
|
||||
|
||||
install:
|
||||
go get github.com/gmemstr/feeds
|
||||
|
@ -17,5 +17,5 @@ docker:
|
|||
docker build .
|
||||
|
||||
and run:
|
||||
go build src/webserver.go src/admin.go src/generate_rss.go src/setup.go
|
||||
go build webserver.go admin.go generate_rss.go setup.go
|
||||
./pogoapp.exe
|
|
@ -23,7 +23,7 @@ func CustomCss(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
filename := "custom.css"
|
||||
|
||||
err := ioutil.WriteFile("./assets/static/"+filename, []byte(css), 0644)
|
||||
err := ioutil.WriteFile("./assets/web/static/"+filename, []byte(css), 0644)
|
||||
if err != nil {
|
||||
w.Write([]byte("<script>window.location = '/admin#failed';</script>"))
|
||||
|
||||
|
@ -32,7 +32,7 @@ func CustomCss(w http.ResponseWriter, r *http.Request) {
|
|||
w.Write([]byte("<script>window.location = '/admin#cssupdated';</script>"))
|
||||
}
|
||||
} else {
|
||||
css, err := ioutil.ReadFile("./assets/static/custom.css")
|
||||
css, err := ioutil.ReadFile("./assets/web/static/custom.css")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
} else {
|
19
assets/web/static/custom.css
Normal file
19
assets/web/static/custom.css
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* This is the file of custom CSS styling that
|
||||
* can be set by the publisher.
|
||||
*
|
||||
* If you're writing the custom CSS, please see the reference:
|
||||
* https://github.com/gmemstr/Pogo/wiki/Custom-CSS/
|
||||
*/
|
||||
|
||||
.container {} /* Basic container from styles.css */
|
||||
.title {} /* Page title */
|
||||
.adminlink {} /* Link to admin interface */
|
||||
|
||||
.podcastlist {} /* Chronological podcast list */
|
||||
|
||||
.podcastitem {} /* Single podcast item (group of elements) */
|
||||
.podcasttitle {} /* Title of podcast item */
|
||||
.podcastdate {} /* Date podcast item was published */
|
||||
.podcastdesc {} /* Podcast item description */
|
||||
.podcastaudio {} /* Podcast <audio> tag */
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"MediaDirectory": "podcasts/",
|
||||
"Name": "Pogo Test Feed",
|
||||
"Host": "Gabriel Simmer",
|
||||
"Email": "admin@localhost",
|
||||
"Description": "Discussion about open source projects on the internet.",
|
||||
"Image": "localhost:8000/assets/podcast_image.png",
|
||||
"PodcastUrl": "http://localhost:8000"
|
||||
}
|
61
configreader.go
Normal file
61
configreader.go
Normal file
|
@ -0,0 +1,61 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
// Configuration structure
|
||||
type Config struct {
|
||||
Name string
|
||||
Host string
|
||||
Email string
|
||||
Description string
|
||||
Image string
|
||||
PodcastUrl string
|
||||
}
|
||||
|
||||
// Single use structure
|
||||
type User struct {
|
||||
Username string
|
||||
Hash string
|
||||
}
|
||||
|
||||
// Read config file and make values accesible
|
||||
func ReadConfig() Config {
|
||||
// Read config.json
|
||||
d, err := ioutil.ReadFile("assets/config/config.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var c Config // Unmarshal json
|
||||
err = json.Unmarshal(d, &c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
// Return single users username & passsword *hash*
|
||||
func GetUser(username string) (usr string, pwd string) {
|
||||
// Read users json file
|
||||
d, err := ioutil.ReadFile("assets/config/users.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var u interface{}
|
||||
err = json.Unmarshal(d, &u) // Unmarshal into interface
|
||||
|
||||
// Iterate through map until we find matching username
|
||||
users := u.(map[string]interface{})
|
||||
for k, v := range users {
|
||||
if k == username {
|
||||
usr = k
|
||||
pwd = v.(string)
|
||||
}
|
||||
}
|
||||
return // Returns k & v values, aka username and password *hash*
|
||||
}
|
|
@ -35,8 +35,6 @@ func watch() {
|
|||
case event := <-watcher.Events:
|
||||
// log.Println("event:", event)
|
||||
if event.Op&fsnotify.Write == fsnotify.Write {
|
||||
// log.Println("modified file:", event.Name)
|
||||
log.Println("File up(load/date)ed: ", event.Name)
|
||||
generate_rss()
|
||||
}
|
||||
case err := <-watcher.Errors:
|
||||
|
@ -49,7 +47,7 @@ func watch() {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = watcher.Add("config.json")
|
||||
err = watcher.Add("assets/config/config.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -118,8 +116,8 @@ func generate_rss() {
|
|||
|
||||
// Write to files as neccesary
|
||||
rss_byte := []byte(rss)
|
||||
ioutil.WriteFile("feed.rss", rss_byte, 0644)
|
||||
ioutil.WriteFile("assets/web/feed.rss", rss_byte, 0644)
|
||||
|
||||
json_byte := []byte(json)
|
||||
ioutil.WriteFile("feed.json", json_byte, 0644)
|
||||
ioutil.WriteFile("assets/web/feed.json", json_byte, 0644)
|
||||
}
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
// "fmt"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
@ -20,7 +19,7 @@ type NewConfig struct {
|
|||
// Serve setup.html and config parameters
|
||||
func ServeSetup(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == "GET" {
|
||||
data, err := ioutil.ReadFile("assets/setup.html")
|
||||
data, err := ioutil.ReadFile("assets/web/setup.html")
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -45,7 +44,7 @@ func ServeSetup(w http.ResponseWriter, r *http.Request) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
ioutil.WriteFile("config.json", b, 0644)
|
||||
ioutil.WriteFile("assets/config/config.json", b, 0644)
|
||||
w.Write([]byte("Done"))
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Name string
|
||||
Host string
|
||||
Email string
|
||||
Description string
|
||||
Image string
|
||||
PodcastUrl string
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Username string
|
||||
Hash string
|
||||
}
|
||||
|
||||
func ReadConfig() Config {
|
||||
d, err := ioutil.ReadFile("config.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var c Config
|
||||
err = json.Unmarshal(d, &c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func GetUser(username string) (usr string, pwd string) {
|
||||
d, err := ioutil.ReadFile("users.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var u interface{}
|
||||
err = json.Unmarshal(d, &u)
|
||||
|
||||
users := u.(map[string]interface{})
|
||||
for k, v := range users {
|
||||
if k == username {
|
||||
usr = k
|
||||
pwd = v.(string)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
0
src/vendor/github.com/gmemstr/feeds/doc.go → vendor/github.com/gmemstr/feeds/doc.go
generated
vendored
0
src/vendor/github.com/gmemstr/feeds/doc.go → vendor/github.com/gmemstr/feeds/doc.go
generated
vendored
0
src/vendor/github.com/gmemstr/feeds/rss.go → vendor/github.com/gmemstr/feeds/rss.go
generated
vendored
0
src/vendor/github.com/gmemstr/feeds/rss.go → vendor/github.com/gmemstr/feeds/rss.go
generated
vendored
0
src/vendor/github.com/gorilla/mux/LICENSE → vendor/github.com/gorilla/mux/LICENSE
generated
vendored
0
src/vendor/github.com/gorilla/mux/LICENSE → vendor/github.com/gorilla/mux/LICENSE
generated
vendored
0
src/vendor/github.com/gorilla/mux/doc.go → vendor/github.com/gorilla/mux/doc.go
generated
vendored
0
src/vendor/github.com/gorilla/mux/doc.go → vendor/github.com/gorilla/mux/doc.go
generated
vendored
0
src/vendor/github.com/gorilla/mux/mux.go → vendor/github.com/gorilla/mux/mux.go
generated
vendored
0
src/vendor/github.com/gorilla/mux/mux.go → vendor/github.com/gorilla/mux/mux.go
generated
vendored
0
src/vendor/github.com/gorilla/mux/route.go → vendor/github.com/gorilla/mux/route.go
generated
vendored
0
src/vendor/github.com/gorilla/mux/route.go → vendor/github.com/gorilla/mux/route.go
generated
vendored
0
src/vendor/golang.org/x/sys/AUTHORS → vendor/golang.org/x/sys/AUTHORS
generated
vendored
0
src/vendor/golang.org/x/sys/AUTHORS → vendor/golang.org/x/sys/AUTHORS
generated
vendored
0
src/vendor/golang.org/x/sys/CONTRIBUTORS → vendor/golang.org/x/sys/CONTRIBUTORS
generated
vendored
0
src/vendor/golang.org/x/sys/CONTRIBUTORS → vendor/golang.org/x/sys/CONTRIBUTORS
generated
vendored
0
src/vendor/golang.org/x/sys/LICENSE → vendor/golang.org/x/sys/LICENSE
generated
vendored
0
src/vendor/golang.org/x/sys/LICENSE → vendor/golang.org/x/sys/LICENSE
generated
vendored
0
src/vendor/golang.org/x/sys/PATENTS → vendor/golang.org/x/sys/PATENTS
generated
vendored
0
src/vendor/golang.org/x/sys/PATENTS → vendor/golang.org/x/sys/PATENTS
generated
vendored
0
src/vendor/golang.org/x/sys/unix/README.md → vendor/golang.org/x/sys/unix/README.md
generated
vendored
0
src/vendor/golang.org/x/sys/unix/README.md → vendor/golang.org/x/sys/unix/README.md
generated
vendored
0
src/vendor/golang.org/x/sys/unix/dirent.go → vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
0
src/vendor/golang.org/x/sys/unix/dirent.go → vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
0
src/vendor/golang.org/x/sys/unix/flock.go → vendor/golang.org/x/sys/unix/flock.go
generated
vendored
0
src/vendor/golang.org/x/sys/unix/flock.go → vendor/golang.org/x/sys/unix/flock.go
generated
vendored
0
src/vendor/golang.org/x/sys/unix/gccgo.go → vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
0
src/vendor/golang.org/x/sys/unix/gccgo.go → vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
0
src/vendor/golang.org/x/sys/unix/gccgo_c.c → vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
0
src/vendor/golang.org/x/sys/unix/gccgo_c.c → vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
0
src/vendor/golang.org/x/sys/unix/mkall.sh → vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
0
src/vendor/golang.org/x/sys/unix/mkall.sh → vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
0
src/vendor/golang.org/x/sys/unix/mkpost.go → vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
0
src/vendor/golang.org/x/sys/unix/mkpost.go → vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue