Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42553d5bd0 | ||
|
|
1db639647f | ||
|
|
4411192a4b |
43 changed files with 425 additions and 20373 deletions
|
|
@ -1,10 +1,3 @@
|
|||
# EVA frontend + backend
|
||||
|
||||
https://doku.ccc.de/SpaceAPI#spaceapi.ccc.de
|
||||
> Timm hat 2016 ein SpaceAPI Directory für Chaos-nahe Gruppen geschrieben und es unter https://spaceapi.ccc.de deployed. Es sollten alle CCC(-nahen) Hackerspaces gelistet sein.
|
||||
|
||||
|
||||
Der Code war ehemals auf zwei Repos verteilt
|
||||
https://github.com/gidsi/eva-frontend + https://github.com/gidsi/eva-backend – dort gibt es auch noch offene Issues die man bei Bedarf auch Inspirationen abhohlen kann... – und wurde dann im Mono-Repo https://github.com/gidsi/spaceapi.ccc.de/ zusammengefasst, das jetzt hier ins Gitlab umgezogen ist.
|
||||
|
||||
Woher der Name EVA kommt ist aktuell nicht mehr direkt nachvollziehbar – falls du noch weißt wie wir damals auf diesen Namen gekommen sind, bearbeite gerne diesen Absatz.
|
||||
[](https://greenkeeper.io/)
|
||||
|
|
@ -5,10 +5,11 @@ COPY . .
|
|||
RUN go get -d ./...
|
||||
RUN go install ./...
|
||||
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
RUN apk --no-cache add ca-certificates
|
||||
WORKDIR /app
|
||||
COPY --from=builder /go/bin/spaceapi.ccc.de ./app
|
||||
COPY --from=builder /go/bin/app .
|
||||
COPY config.yaml config.yaml
|
||||
EXPOSE 8080
|
||||
CMD ["./app"]
|
||||
|
|
|
|||
|
|
@ -13,5 +13,3 @@ SpaceAPI extensions
|
|||
===================
|
||||
|
||||
* Key `ext_ccc` describes Chaos Computer Club relation status (Example values: `"chaostreff"` or `"erfa"`)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func getCalendars() {
|
|||
outputChan := parser.GetOutputChan()
|
||||
calendar := Calendar{}
|
||||
calendar.Space = spaceData.Space
|
||||
var events []Event
|
||||
events := []Event{}
|
||||
go func() {
|
||||
for event := range outputChan {
|
||||
events = append(events, mapEventObject(event))
|
||||
|
|
|
|||
|
|
@ -4,6 +4,4 @@ type ConfigFile struct {
|
|||
SharedSecret string `yaml:"shared_secret,omitempty"`
|
||||
MongoDbServer string `yaml:"mongodb_server,omitempty"`
|
||||
MongoDbDatabase string `yaml:"mongodb_database,omitempty"`
|
||||
DokuWikiUser string `yaml:"doku_wiki_user,omitempty"`
|
||||
DokuWikiPassword string `yaml:"doku_wiki_password,omitempty"`
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"gopkg.in/mgo.v2"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"log"
|
||||
"gopkg.in/mgo.v2"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
)
|
||||
|
||||
func writeSpaceData(data SpaceData) {
|
||||
if data.Space != "" {
|
||||
if(data.Space != "") {
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -17,7 +17,7 @@ func writeSpaceData(data SpaceData) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spacedata")
|
||||
_, err = c.Upsert(bson.M{"space": data.Space}, data)
|
||||
_, err = c.Upsert(bson.M{ "space": data.Space }, data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
@ -34,9 +34,9 @@ func writeSpaceurl(spaceUrl SpaceUrl) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||
count, _ := c.Find(bson.M{"url": spaceUrl.Url}).Count()
|
||||
if count == 0 {
|
||||
c.Insert(spaceUrl)
|
||||
count, _ := c.Find(bson.M{ "url": spaceUrl.Url }).Count()
|
||||
if(count == 0) {
|
||||
c.Insert(spaceUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,28 +50,7 @@ func writeCalendar(calendar Calendar) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("calendar")
|
||||
c.Upsert(bson.M{"space": calendar.Space}, calendar)
|
||||
}
|
||||
|
||||
func writeDecentralizedServices(services []DecentrealizedService) {
|
||||
if len(services) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("decentralized_services")
|
||||
|
||||
c.DropCollection()
|
||||
for _, service := range(services) {
|
||||
c.Insert(service)
|
||||
}
|
||||
c.Upsert(bson.M{ "space": calendar.Space }, calendar)
|
||||
}
|
||||
|
||||
func updateSpaceurl(spaceUrl SpaceUrl) {
|
||||
|
|
@ -84,11 +63,11 @@ func updateSpaceurl(spaceUrl SpaceUrl) {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||
c.Update(bson.M{"url": spaceUrl.Url}, spaceUrl)
|
||||
c.Update(bson.M{ "url": spaceUrl.Url }, spaceUrl);
|
||||
}
|
||||
|
||||
func readSpacedata() []SpaceData {
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -97,8 +76,8 @@ func readSpacedata() []SpaceData {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spacedata")
|
||||
result := []SpaceData{}
|
||||
c.Find(bson.M{}).Iter().All(&result)
|
||||
result := []SpaceData{}
|
||||
c.Find(bson.M{}).Iter().All(&result)
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
@ -115,10 +94,11 @@ func readSpaceurl() []SpaceUrl {
|
|||
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||
result := []SpaceUrl{}
|
||||
c.Find(bson.M{}).Iter().All(&result)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func deleteSpaceurl(id string) error {
|
||||
func deleteSpaceurl(String id) {
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -128,13 +108,7 @@ func deleteSpaceurl(id string) error {
|
|||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||
err = c.Remove(bson.M{"id": id})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
c.Remove(bson.M{"_id": id})
|
||||
}
|
||||
|
||||
func readCalendar() []Calendar {
|
||||
|
|
@ -152,20 +126,3 @@ func readCalendar() []Calendar {
|
|||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
func readServices() []DecentrealizedService {
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
c := session.DB(config.MongoDbDatabase).C("decentralized_services")
|
||||
var result []DecentrealizedService
|
||||
c.Find(bson.M{}).Iter().All(&result)
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,100 +1,65 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/robfig/cron"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
"gopkg.in/yaml.v2"
|
||||
"log"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
var config = ConfigFile{}
|
||||
|
||||
func main() {
|
||||
data, _ := ioutil.ReadFile("config.yaml")
|
||||
err := yaml.Unmarshal(data, &config)
|
||||
if err != nil {
|
||||
panic("Can't load config")
|
||||
}
|
||||
config.SharedSecret = os.Getenv("SHARED_SECRET")
|
||||
config.DokuWikiUser = os.Getenv("DOKU_WIKI_USER")
|
||||
config.DokuWikiPassword = os.Getenv("DOKU_WIKI_PASSWORD")
|
||||
data, _ := ioutil.ReadFile("config.yaml")
|
||||
yaml.Unmarshal(data, &config)
|
||||
config.SharedSecret = os.Getenv("SHARED_SECRET")
|
||||
|
||||
updateDecentralizedServicesList()
|
||||
|
||||
c := cron.New()
|
||||
err = c.AddFunc("@hourly", func() {
|
||||
loadSpaceData()
|
||||
getCalendars()
|
||||
updateDecentralizedServicesList()
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Can't start cron %v", err)
|
||||
} else {
|
||||
c.Start()
|
||||
}
|
||||
|
||||
router := NewRouter()
|
||||
http.Handle("/", router)
|
||||
log.Fatal(http.ListenAndServe(":8080", router))
|
||||
router := NewRouter()
|
||||
http.Handle("/", router)
|
||||
log.Fatal(http.ListenAndServe(":8080", router))
|
||||
}
|
||||
|
||||
func getJson(url string, target interface{}) error {
|
||||
r, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer r.Body.Close()
|
||||
r, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
return json.NewDecoder(r.Body).Decode(target)
|
||||
return json.NewDecoder(r.Body).Decode(target)
|
||||
}
|
||||
|
||||
func SpaceDataIndex(w http.ResponseWriter, r *http.Request) {
|
||||
ReturnJson(w, readSpacedata())
|
||||
ReturnJson(w, readSpacedata())
|
||||
}
|
||||
|
||||
func SpaceUrlIndex(w http.ResponseWriter, r *http.Request) {
|
||||
ReturnJson(w, readSpaceurl())
|
||||
ReturnJson(w, readSpaceurl())
|
||||
}
|
||||
|
||||
func CalendarIndex(w http.ResponseWriter, r *http.Request) {
|
||||
ReturnJson(w, readCalendar())
|
||||
}
|
||||
|
||||
func DecentralizedServicesIndex(w http.ResponseWriter, r *http.Request) {
|
||||
ReturnJson(w, readServices())
|
||||
ReturnJson(w, readCalendar())
|
||||
}
|
||||
|
||||
func SpaceUrlAdd(w http.ResponseWriter, r *http.Request) {
|
||||
spaceUrl := SpaceUrl{}
|
||||
createEntry(&spaceUrl, w, r)
|
||||
spaceUrl.Validated = false
|
||||
|
||||
generatedUuid, err := uuid.NewV4()
|
||||
if err != nil {
|
||||
log.Printf("%v", err)
|
||||
w.WriteHeader(500)
|
||||
} else {
|
||||
spaceUrl.Id = generatedUuid.String()
|
||||
writeSpaceurl(spaceUrl)
|
||||
}
|
||||
spaceUrl := SpaceUrl{}
|
||||
createEntry(&spaceUrl, w, r)
|
||||
spaceUrl.Validated = false
|
||||
writeSpaceurl(spaceUrl)
|
||||
}
|
||||
|
||||
func SpaceUrlUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
SharedSecret := vars["SharedSecret"]
|
||||
if SharedSecret == config.SharedSecret {
|
||||
spaceUrl := SpaceUrl{}
|
||||
createEntry(&spaceUrl, w, r)
|
||||
updateSpaceurl(spaceUrl)
|
||||
}
|
||||
vars := mux.Vars(r)
|
||||
SharedSecret := vars["SharedSecret"]
|
||||
if(SharedSecret == config.SharedSecret) {
|
||||
spaceUrl := SpaceUrl{}
|
||||
createEntry(&spaceUrl, w, r)
|
||||
updateSpaceurl(spaceUrl)
|
||||
}
|
||||
}
|
||||
|
||||
func SpaceUrlDelete(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -102,87 +67,36 @@ func SpaceUrlDelete(w http.ResponseWriter, r *http.Request) {
|
|||
SharedSecret := vars["SharedSecret"]
|
||||
Id := vars["id"]
|
||||
if SharedSecret == config.SharedSecret {
|
||||
err := deleteSpaceurl(Id)
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
} else {
|
||||
w.WriteHeader(204)
|
||||
}
|
||||
} else {
|
||||
w.WriteHeader(401)
|
||||
deleteSpaceurl(Id)
|
||||
}
|
||||
}
|
||||
|
||||
func loadSpaceData() {
|
||||
spaceUrls := readSpaceurl()
|
||||
spaceUrls := readSpaceurl()
|
||||
|
||||
timestamp := time.Now().Unix()
|
||||
timestamp := time.Now().Unix()
|
||||
|
||||
for _, spaceUrl := range spaceUrls {
|
||||
if spaceUrl.Validated && int64(spaceUrl.LastUpdated+60) < timestamp {
|
||||
spaceData := SpaceData{}
|
||||
err := getJson(spaceUrl.Url, &spaceData)
|
||||
if err != nil {
|
||||
log.Println(spaceUrl.Url)
|
||||
log.Println(err)
|
||||
} else {
|
||||
writeSpaceData(spaceData)
|
||||
for _, spaceUrl := range spaceUrls {
|
||||
if(spaceUrl.Validated && int64(spaceUrl.LastUpdated + 60) < timestamp) {
|
||||
spaceData := SpaceData{}
|
||||
err := getJson(spaceUrl.Url, &spaceData)
|
||||
if err != nil
|
||||
{
|
||||
log.Println(spaceUrl.Url)
|
||||
log.Println(err)
|
||||
} else {
|
||||
writeSpaceData(spaceData)
|
||||
|
||||
spaceUrl.LastUpdated = timestamp
|
||||
updateSpaceurl(spaceUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
spaceUrl.LastUpdated = timestamp
|
||||
updateSpaceurl(spaceUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func refreshData(w http.ResponseWriter, r *http.Request) {
|
||||
loadSpaceData()
|
||||
getCalendars()
|
||||
loadSpaceData()
|
||||
getCalendars()
|
||||
|
||||
w.WriteHeader(204)
|
||||
}
|
||||
|
||||
func updateDecentralizedServicesList() {
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", "https://doku.ccc.de/index.php?title=Spezial:Ask&x=-5B-5BKategorie%3ADienste-5D-5D%2F-3FService-2DName%3DName%2F-3FService-2DProduct%3DProdukt%2F-3FService-2DIs-2DCentralized%3DZentralisiert%2F-3FService-2DVisibility%3DSichtbarkeit%2F-3FService-2DOrg%3DOrganisation%2F-3FService-2DType%3DTyp%2F-3FService-2DURL%3DURL%2F-3FService-2DContact%3DKontakt%2F-3FService-2DCheck-23ISO%3DOnline-20Check%2F-3FService-2DState%3DOnline-3F%2F-3FService-2DEncryption%3DVerschl%C3%BCsselung%2F-3FService-2DHas-2DIPv4%3DIPv4%2F-3FService-2DHas-2DIPv6%3DIPv6&mainlabel=-&limit=50&offset=0&format=csv&headers=show&searchlabel=CSV&default=%21no%20result%21&sep=%3B&valuesep=%3B&filename=dienste.csv", nil)
|
||||
if err != nil{
|
||||
log.Fatal(err)
|
||||
}
|
||||
req.SetBasicAuth(config.DokuWikiUser, config.DokuWikiPassword)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil{
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
r := csv.NewReader(resp.Body)
|
||||
r.Comma = ';'
|
||||
|
||||
var DecentrealizedServiceList []DecentrealizedService
|
||||
for {
|
||||
record, err := r.Read()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if len(record) > 9 && record[3] == "public" && record[9] == "wahr" && record[6] != "" {
|
||||
foo := DecentrealizedService{
|
||||
record[0],
|
||||
record[1],
|
||||
record[6],
|
||||
}
|
||||
|
||||
DecentrealizedServiceList = append(DecentrealizedServiceList, foo)
|
||||
}
|
||||
}
|
||||
|
||||
writeDecentralizedServices(DecentrealizedServiceList)
|
||||
}
|
||||
|
||||
type DecentrealizedService struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Url string `json:"url"`
|
||||
w.WriteHeader(204)
|
||||
}
|
||||
|
|
@ -3,20 +3,21 @@ package main
|
|||
import "time"
|
||||
|
||||
type Calendar struct {
|
||||
Space string
|
||||
Events []Event
|
||||
Space string
|
||||
Events []Event
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
Start time.Time `json:"start"`
|
||||
ImportedId string `json:"importId"`
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description"`
|
||||
Location string `json:"location"`
|
||||
Summary string `json:"summary"`
|
||||
Rrule string `json:"rrule"`
|
||||
Class string `json:"class"`
|
||||
Url string `json:"url"`
|
||||
Sequence int `json:"sequence"`
|
||||
WholeDayEvent bool `json:"wholeDayEvent"`
|
||||
ImportedId string `json:"importId"`
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description"`
|
||||
Location string `json:"location"`
|
||||
Summary string `json:"summary"`
|
||||
Rrule string `json:"rrule"`
|
||||
Class string `json:"class"`
|
||||
Url string `json:"url"`
|
||||
Sequence int `json:"sequence"`
|
||||
WholeDayEvent bool `json:"whileDayEvent"`
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
module github.com/gidsi/spaceapi.ccc.de
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/PuloV/ics-golang v0.0.0-20190808201353-a3394d3bcade
|
||||
github.com/channelmeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61 // indirect
|
||||
github.com/gidsi/ics-golang v0.0.0-20190331185529-e95e328c4a08
|
||||
github.com/gofrs/uuid v3.3.0+incompatible
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/robfig/cron v1.2.0
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
)
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
github.com/PuloV/ics-golang v0.0.0-20190808201353-a3394d3bcade h1:odEkSCl2gLWPtvraEdCyBZbeYyMMTysWPLMurnB8sUY=
|
||||
github.com/PuloV/ics-golang v0.0.0-20190808201353-a3394d3bcade/go.mod h1:f1P3hjG+t54/IrnXMnnw+gRmFCDR/ryj9xSQ7MPMkQw=
|
||||
github.com/channelmeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61 h1:o64h9XF42kVEUuhuer2ehqrlX8rZmvQSU0+Vpj1rF6Q=
|
||||
github.com/channelmeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61/go.mod h1:Rp8e0DCtEKwXFOC6JPJQVTz8tuGoGvw6Xfexggh/ed0=
|
||||
github.com/gidsi/ics-golang v0.0.0-20190331185529-e95e328c4a08 h1:x57vmmjqLdRGv3bZQqoyzt4S08z5pTk/vkWaqXGnswI=
|
||||
github.com/gidsi/ics-golang v0.0.0-20190331185529-e95e328c4a08/go.mod h1:oIDQdzzcgVLYQRfohyxBaOVr7pyfRydoPcEdVNXry4s=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
|
||||
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
|
||||
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DataObject interface {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"github.com/gorilla/mux"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func NewRouter() *mux.Router {
|
||||
|
|
@ -13,21 +13,21 @@ func NewRouter() *mux.Router {
|
|||
handler = Logger(route.Handler, route.Name)
|
||||
|
||||
router.
|
||||
Methods(route.Method).
|
||||
Path(route.Pattern).
|
||||
Name(route.Name).
|
||||
Handler(handler)
|
||||
Methods(route.Method).
|
||||
Path(route.Pattern).
|
||||
Name(route.Name).
|
||||
Handler(handler)
|
||||
|
||||
router.
|
||||
Methods("OPTIONS").
|
||||
Name("Options Handler").
|
||||
Handler(http.HandlerFunc(optionsHandler))
|
||||
}
|
||||
|
||||
router.
|
||||
Methods("OPTIONS").
|
||||
Name("Options Handler").
|
||||
Handler(http.HandlerFunc(optionsHandler))
|
||||
}
|
||||
|
||||
router.
|
||||
Methods("OPTIONS").
|
||||
Name("Options Handler").
|
||||
Handler(http.HandlerFunc(optionsHandler))
|
||||
|
||||
router.NotFoundHandler = http.HandlerFunc(notFound)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ type Route struct {
|
|||
Handler http.HandlerFunc
|
||||
}
|
||||
|
||||
|
||||
type Routes []Route
|
||||
|
||||
var IndexRoutes = Routes{
|
||||
|
|
@ -36,12 +37,6 @@ var IndexRoutes = Routes{
|
|||
"/calendar",
|
||||
CalendarIndex,
|
||||
},
|
||||
Route{
|
||||
"ServicesIndex",
|
||||
"GET",
|
||||
"/services",
|
||||
DecentralizedServicesIndex,
|
||||
},
|
||||
Route{
|
||||
"SpaceUrlAdd",
|
||||
"POST",
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,78 +1,44 @@
|
|||
package main
|
||||
|
||||
// non standard should start with ext_
|
||||
|
||||
type Location struct {
|
||||
Address string `json:"address"`
|
||||
// non standard
|
||||
ExtFloor int `json:"ext_floor"`
|
||||
Lon float32 `json:"lon"`
|
||||
Lat float32 `json:"lat"`
|
||||
}
|
||||
|
||||
type SpaceFed struct {
|
||||
SpaceNet bool `json:"spacenet"`
|
||||
Spacesaml bool `json:"spacesaml"`
|
||||
SpacePhone bool `json:"spacephone"`
|
||||
}
|
||||
|
||||
type Stream struct {
|
||||
M4 bool `json:"m4,omitempty"`
|
||||
MJPEG bool `json:"mjpeg,omitempty"`
|
||||
UStream bool `json:"ustream,omitempty"`
|
||||
}
|
||||
|
||||
type State struct {
|
||||
Open bool `json:"open"`
|
||||
Lastchange float64 `json:"lastchange,omitempty"`
|
||||
TriggerPerson string `json:"trigger_person,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Icon struct {
|
||||
Open string `json:"open"`
|
||||
Closed string `json:"closed"`
|
||||
} `json:"icon,omitempty"`
|
||||
}
|
||||
|
||||
type Contact struct {
|
||||
Twitter string `json:"twitter"`
|
||||
Phone string `json:"phone"`
|
||||
Irc string `json:"irc"`
|
||||
Email string `json:"email"`
|
||||
Ml string `json:"ml"`
|
||||
IssueMail string `json:"issue_mail"`
|
||||
}
|
||||
|
||||
type Feed struct {
|
||||
Type string `json:"type"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type Feeds struct {
|
||||
Blog Feed `json:"blog"`
|
||||
Wiki Feed `json:"wiki"`
|
||||
Calendar Feed `json:"calendar"`
|
||||
type Location struct {
|
||||
Address string `json:"address"`
|
||||
Lon float32 `json:"lon"`
|
||||
Lat float32 `json:"lat"`
|
||||
}
|
||||
|
||||
// main struct
|
||||
type Contact struct {
|
||||
Twitter string `json:"twitter"`
|
||||
Phone string `json:"phone"`
|
||||
Irc string `json:"irc"`
|
||||
Email string `json:"email"`
|
||||
Ml string `json:"ml"`
|
||||
IssueMail string `json:"issue_mail"`
|
||||
}
|
||||
|
||||
type State struct {
|
||||
Open bool `json:"open"`
|
||||
}
|
||||
|
||||
type Feeds struct {
|
||||
Blog Feed `json:"blog"`
|
||||
Wiki Feed `json:"wiki"`
|
||||
Calendar Feed `json:"calendar"`
|
||||
}
|
||||
|
||||
type SpaceData struct {
|
||||
Api string `json:"api"`
|
||||
Space string `json:"space"`
|
||||
Logo string `json:"logo"`
|
||||
Url string `json:"url"`
|
||||
Location Location `json:"location"`
|
||||
SpaceFed SpaceFed `json:"spacefed,omitempty"`
|
||||
Cam []string `json:"cam,omitempty"`
|
||||
Stream *Stream `json:"stream,omitempty"`
|
||||
State State `json:"state"`
|
||||
// missing: `json:"events,omitempty"`
|
||||
Contact *Contact `json:"contact,omitempty"`
|
||||
IssueReportChannels []string `json:"issue_report_channels"`
|
||||
// missing: `json:"sensors,omitempty"`
|
||||
Feeds Feeds `json:"feeds,omitempty"`
|
||||
// missing: `json:"cache,omitempty"`
|
||||
Projects []string `json:"projects,omitempty"`
|
||||
// missing: `json:"radio_show,omitempty"`
|
||||
// not in spaceapi.io/docs
|
||||
Ext_ccc string `json:"ext_ccc"`
|
||||
Api string `json:"api"`
|
||||
Space string `json:"space"`
|
||||
Logo string `json:"logo"`
|
||||
Url string `json:"url"`
|
||||
Location Location `json:"location"`
|
||||
Contact Contact `json:"contact"`
|
||||
IssueReportChannels []string `json:"issue_report_channels"`
|
||||
State State `json:"state"`
|
||||
Feeds Feeds `json:"feeds"`
|
||||
Ext_ccc string `json:"ext_ccc"`
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package main
|
||||
|
||||
type SpaceUrl struct {
|
||||
Id string `json:"id"`
|
||||
Url string `json:"url"`
|
||||
Validated bool `json:"validated"`
|
||||
LastUpdated int64 `json:"lastUpdated"`
|
||||
Url string `json:"url"`
|
||||
Validated bool `json:"validated"`
|
||||
LastUpdated int64 `json:"lastUpdated"`
|
||||
}
|
||||
|
|
@ -2,38 +2,16 @@ version: "3"
|
|||
services:
|
||||
frontend:
|
||||
build: ./frontend
|
||||
networks:
|
||||
spaceapi-network:
|
||||
ipv4_address: 172.16.238.10
|
||||
image: gidsi/spaceapi-ccc-frontend:latest
|
||||
restart: always
|
||||
expose:
|
||||
- "80"
|
||||
depends_on:
|
||||
- backend
|
||||
backend:
|
||||
build: ./backend
|
||||
networks:
|
||||
- spaceapi-network
|
||||
image: gidsi/spaceapi-ccc-backend:latest
|
||||
restart: always
|
||||
environment:
|
||||
- SHARED_SECRET=${SHARED_SECRET:-secret}
|
||||
- DOKU_WIKI_USER=${DOKU_WIKI_USER}
|
||||
- DOKU_WIKI_PASSWORD=${DOKU_WIKI_PASSWORD}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
- database
|
||||
database:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- spaceapi-network
|
||||
restart: always
|
||||
volumes:
|
||||
- /opt/eva:/data/db
|
||||
|
||||
networks:
|
||||
spaceapi-network:
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.16.238.0/24
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
FROM node:16-alpine as builder
|
||||
FROM node as builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
eva-frontend
|
||||
eve-frontend
|
||||
=======================
|
||||
|
||||
The React frontent running https://spaceapi.ccc.de
|
||||
|
||||
Usage
|
||||
-----
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
npm install -g yarn
|
||||
yarn install
|
||||
yarn start
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue