Compare commits

..
Author SHA1 Message Date
greenkeeper[bot]
42553d5bd0 docs(readme): add Greenkeeper badge 2018-05-06 08:18:07 +00:00
greenkeeper[bot]
1db639647f chore(package): update dependencies 2018-05-06 08:18:04 +00:00
greenkeeper[bot]
4411192a4b chore: add Greenkeeper config file 2018-05-06 08:18:01 +00:00
43 changed files with 425 additions and 20373 deletions

View file

@ -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 [![Greenkeeper badge](https://badges.greenkeeper.io/gidsi/spaceapi.ccc.de.svg)](https://greenkeeper.io/)
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.

View file

@ -5,10 +5,11 @@ COPY . .
RUN go get -d ./... RUN go get -d ./...
RUN go install ./... RUN go install ./...
FROM alpine:latest FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata RUN apk --no-cache add ca-certificates
WORKDIR /app WORKDIR /app
COPY --from=builder /go/bin/spaceapi.ccc.de ./app COPY --from=builder /go/bin/app .
COPY config.yaml config.yaml COPY config.yaml config.yaml
EXPOSE 8080 EXPOSE 8080
CMD ["./app"] CMD ["./app"]

View file

@ -13,5 +13,3 @@ SpaceAPI extensions
=================== ===================
* Key `ext_ccc` describes Chaos Computer Club relation status (Example values: `"chaostreff"` or `"erfa"`) * Key `ext_ccc` describes Chaos Computer Club relation status (Example values: `"chaostreff"` or `"erfa"`)

View file

@ -15,7 +15,7 @@ func getCalendars() {
outputChan := parser.GetOutputChan() outputChan := parser.GetOutputChan()
calendar := Calendar{} calendar := Calendar{}
calendar.Space = spaceData.Space calendar.Space = spaceData.Space
var events []Event events := []Event{}
go func() { go func() {
for event := range outputChan { for event := range outputChan {
events = append(events, mapEventObject(event)) events = append(events, mapEventObject(event))
@ -44,4 +44,4 @@ func mapEventObject(event *ics.Event) Event {
eventData.WholeDayEvent = event.GetWholeDayEvent() eventData.WholeDayEvent = event.GetWholeDayEvent()
return eventData return eventData
} }

View file

@ -4,6 +4,4 @@ type ConfigFile struct {
SharedSecret string `yaml:"shared_secret,omitempty"` SharedSecret string `yaml:"shared_secret,omitempty"`
MongoDbServer string `yaml:"mongodb_server,omitempty"` MongoDbServer string `yaml:"mongodb_server,omitempty"`
MongoDbDatabase string `yaml:"mongodb_database,omitempty"` MongoDbDatabase string `yaml:"mongodb_database,omitempty"`
DokuWikiUser string `yaml:"doku_wiki_user,omitempty"` }
DokuWikiPassword string `yaml:"doku_wiki_password,omitempty"`
}

View file

@ -1,13 +1,13 @@
package main package main
import ( import (
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"log" "log"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
) )
func writeSpaceData(data SpaceData) { func writeSpaceData(data SpaceData) {
if data.Space != "" { if(data.Space != "") {
session, err := mgo.Dial(config.MongoDbServer) session, err := mgo.Dial(config.MongoDbServer)
if err != nil { if err != nil {
panic(err) panic(err)
@ -17,7 +17,7 @@ func writeSpaceData(data SpaceData) {
session.SetMode(mgo.Monotonic, true) session.SetMode(mgo.Monotonic, true)
c := session.DB(config.MongoDbDatabase).C("spacedata") 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -34,9 +34,9 @@ func writeSpaceurl(spaceUrl SpaceUrl) {
session.SetMode(mgo.Monotonic, true) session.SetMode(mgo.Monotonic, true)
c := session.DB(config.MongoDbDatabase).C("spaceurl") c := session.DB(config.MongoDbDatabase).C("spaceurl")
count, _ := c.Find(bson.M{"url": spaceUrl.Url}).Count() count, _ := c.Find(bson.M{ "url": spaceUrl.Url }).Count()
if count == 0 { if(count == 0) {
c.Insert(spaceUrl) c.Insert(spaceUrl);
} }
} }
@ -50,28 +50,7 @@ func writeCalendar(calendar Calendar) {
session.SetMode(mgo.Monotonic, true) session.SetMode(mgo.Monotonic, true)
c := session.DB(config.MongoDbDatabase).C("calendar") c := session.DB(config.MongoDbDatabase).C("calendar")
c.Upsert(bson.M{"space": calendar.Space}, 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)
}
} }
func updateSpaceurl(spaceUrl SpaceUrl) { func updateSpaceurl(spaceUrl SpaceUrl) {
@ -84,11 +63,11 @@ func updateSpaceurl(spaceUrl SpaceUrl) {
session.SetMode(mgo.Monotonic, true) session.SetMode(mgo.Monotonic, true)
c := session.DB(config.MongoDbDatabase).C("spaceurl") 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 { func readSpacedata() []SpaceData {
session, err := mgo.Dial(config.MongoDbServer) session, err := mgo.Dial(config.MongoDbServer)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -97,8 +76,8 @@ func readSpacedata() []SpaceData {
session.SetMode(mgo.Monotonic, true) session.SetMode(mgo.Monotonic, true)
c := session.DB(config.MongoDbDatabase).C("spacedata") c := session.DB(config.MongoDbDatabase).C("spacedata")
result := []SpaceData{} result := []SpaceData{}
c.Find(bson.M{}).Iter().All(&result) c.Find(bson.M{}).Iter().All(&result)
return result return result
} }
@ -115,10 +94,11 @@ func readSpaceurl() []SpaceUrl {
c := session.DB(config.MongoDbDatabase).C("spaceurl") c := session.DB(config.MongoDbDatabase).C("spaceurl")
result := []SpaceUrl{} result := []SpaceUrl{}
c.Find(bson.M{}).Iter().All(&result) c.Find(bson.M{}).Iter().All(&result)
return result return result
} }
func deleteSpaceurl(id string) error { func deleteSpaceurl(String id) {
session, err := mgo.Dial(config.MongoDbServer) session, err := mgo.Dial(config.MongoDbServer)
if err != nil { if err != nil {
panic(err) panic(err)
@ -128,13 +108,7 @@ func deleteSpaceurl(id string) error {
session.SetMode(mgo.Monotonic, true) session.SetMode(mgo.Monotonic, true)
c := session.DB(config.MongoDbDatabase).C("spaceurl") c := session.DB(config.MongoDbDatabase).C("spaceurl")
err = c.Remove(bson.M{"id": id}) c.Remove(bson.M{"_id": id})
if err != nil {
log.Println(err)
return err
}
return nil
} }
func readCalendar() []Calendar { func readCalendar() []Calendar {
@ -151,21 +125,4 @@ func readCalendar() []Calendar {
c.Find(bson.M{}).Iter().All(&result) c.Find(bson.M{}).Iter().All(&result)
return result 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
}

View file

@ -1,100 +1,65 @@
package main package main
import ( import (
"encoding/csv" "net/http"
"encoding/json" "encoding/json"
"github.com/gofrs/uuid" "gopkg.in/yaml.v2"
"github.com/gorilla/mux" "log"
"github.com/robfig/cron" "io/ioutil"
"gopkg.in/yaml.v2" "os"
"io" "time"
"io/ioutil" "github.com/gorilla/mux"
"log"
"net/http"
"os"
"time"
) )
var config = ConfigFile{} var config = ConfigFile{}
func main() { func main() {
data, _ := ioutil.ReadFile("config.yaml") data, _ := ioutil.ReadFile("config.yaml")
err := yaml.Unmarshal(data, &config) yaml.Unmarshal(data, &config)
if err != nil { config.SharedSecret = os.Getenv("SHARED_SECRET")
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")
updateDecentralizedServicesList() router := NewRouter()
http.Handle("/", router)
c := cron.New() log.Fatal(http.ListenAndServe(":8080", router))
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))
} }
func getJson(url string, target interface{}) error { func getJson(url string, target interface{}) error {
r, err := http.Get(url) r, err := http.Get(url)
if err != nil { if err != nil {
return err return err
} }
defer r.Body.Close() 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) { func SpaceDataIndex(w http.ResponseWriter, r *http.Request) {
ReturnJson(w, readSpacedata()) ReturnJson(w, readSpacedata())
} }
func SpaceUrlIndex(w http.ResponseWriter, r *http.Request) { func SpaceUrlIndex(w http.ResponseWriter, r *http.Request) {
ReturnJson(w, readSpaceurl()) ReturnJson(w, readSpaceurl())
} }
func CalendarIndex(w http.ResponseWriter, r *http.Request) { func CalendarIndex(w http.ResponseWriter, r *http.Request) {
ReturnJson(w, readCalendar()) ReturnJson(w, readCalendar())
}
func DecentralizedServicesIndex(w http.ResponseWriter, r *http.Request) {
ReturnJson(w, readServices())
} }
func SpaceUrlAdd(w http.ResponseWriter, r *http.Request) { func SpaceUrlAdd(w http.ResponseWriter, r *http.Request) {
spaceUrl := SpaceUrl{} spaceUrl := SpaceUrl{}
createEntry(&spaceUrl, w, r) createEntry(&spaceUrl, w, r)
spaceUrl.Validated = false spaceUrl.Validated = false
writeSpaceurl(spaceUrl)
generatedUuid, err := uuid.NewV4()
if err != nil {
log.Printf("%v", err)
w.WriteHeader(500)
} else {
spaceUrl.Id = generatedUuid.String()
writeSpaceurl(spaceUrl)
}
} }
func SpaceUrlUpdate(w http.ResponseWriter, r *http.Request) { func SpaceUrlUpdate(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
SharedSecret := vars["SharedSecret"] SharedSecret := vars["SharedSecret"]
if SharedSecret == config.SharedSecret { if(SharedSecret == config.SharedSecret) {
spaceUrl := SpaceUrl{} spaceUrl := SpaceUrl{}
createEntry(&spaceUrl, w, r) createEntry(&spaceUrl, w, r)
updateSpaceurl(spaceUrl) updateSpaceurl(spaceUrl)
} }
} }
func SpaceUrlDelete(w http.ResponseWriter, r *http.Request) { func SpaceUrlDelete(w http.ResponseWriter, r *http.Request) {
@ -102,87 +67,36 @@ func SpaceUrlDelete(w http.ResponseWriter, r *http.Request) {
SharedSecret := vars["SharedSecret"] SharedSecret := vars["SharedSecret"]
Id := vars["id"] Id := vars["id"]
if SharedSecret == config.SharedSecret { if SharedSecret == config.SharedSecret {
err := deleteSpaceurl(Id) deleteSpaceurl(Id)
if err != nil {
w.WriteHeader(500)
} else {
w.WriteHeader(204)
}
} else {
w.WriteHeader(401)
} }
} }
func loadSpaceData() { func loadSpaceData() {
spaceUrls := readSpaceurl() spaceUrls := readSpaceurl()
timestamp := time.Now().Unix() timestamp := time.Now().Unix()
for _, spaceUrl := range spaceUrls { for _, spaceUrl := range spaceUrls {
if spaceUrl.Validated && int64(spaceUrl.LastUpdated+60) < timestamp { if(spaceUrl.Validated && int64(spaceUrl.LastUpdated + 60) < timestamp) {
spaceData := SpaceData{} spaceData := SpaceData{}
err := getJson(spaceUrl.Url, &spaceData) err := getJson(spaceUrl.Url, &spaceData)
if err != nil { if err != nil
log.Println(spaceUrl.Url) {
log.Println(err) log.Println(spaceUrl.Url)
} else { log.Println(err)
writeSpaceData(spaceData) } else {
writeSpaceData(spaceData)
spaceUrl.LastUpdated = timestamp spaceUrl.LastUpdated = timestamp
updateSpaceurl(spaceUrl) updateSpaceurl(spaceUrl)
} }
} }
} }
} }
func refreshData(w http.ResponseWriter, r *http.Request) { func refreshData(w http.ResponseWriter, r *http.Request) {
loadSpaceData() loadSpaceData()
getCalendars() getCalendars()
w.WriteHeader(204) 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"`
}

View file

@ -3,20 +3,21 @@ package main
import "time" import "time"
type Calendar struct { type Calendar struct {
Space string Space string
Events []Event Events []Event
} }
type Event struct { type Event struct {
Start time.Time `json:"start"` Start time.Time `json:"start"`
ImportedId string `json:"importId"` ImportedId string `json:"importId"`
Status string `json:"status"` Status string `json:"status"`
Description string `json:"description"` Description string `json:"description"`
Location string `json:"location"` Location string `json:"location"`
Summary string `json:"summary"` Summary string `json:"summary"`
Rrule string `json:"rrule"` Rrule string `json:"rrule"`
Class string `json:"class"` Class string `json:"class"`
Url string `json:"url"` Url string `json:"url"`
Sequence int `json:"sequence"` Sequence int `json:"sequence"`
WholeDayEvent bool `json:"wholeDayEvent"` WholeDayEvent bool `json:"whileDayEvent"`
}
}

View file

@ -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
)

View file

@ -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=

View file

@ -26,4 +26,4 @@ func logError(err error) {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }

View file

@ -1,9 +1,9 @@
package main package main
import ( import (
"net/http"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http"
) )
type DataObject interface { type DataObject interface {
@ -45,4 +45,4 @@ func createEntry(i interface{}, w http.ResponseWriter, r *http.Request) {
panic(err) panic(err)
} }
} }
} }

View file

@ -1,9 +1,9 @@
package main package main
import ( import (
"net/http"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"log" "log"
"net/http"
) )
func NewRouter() *mux.Router { func NewRouter() *mux.Router {
@ -13,21 +13,21 @@ func NewRouter() *mux.Router {
handler = Logger(route.Handler, route.Name) handler = Logger(route.Handler, route.Name)
router. router.
Methods(route.Method). Methods(route.Method).
Path(route.Pattern). Path(route.Pattern).
Name(route.Name). Name(route.Name).
Handler(handler) Handler(handler)
router. router.
Methods("OPTIONS").
Name("Options Handler").
Handler(http.HandlerFunc(optionsHandler))
}
router.
Methods("OPTIONS"). Methods("OPTIONS").
Name("Options Handler"). Name("Options Handler").
Handler(http.HandlerFunc(optionsHandler)) Handler(http.HandlerFunc(optionsHandler))
}
router.
Methods("OPTIONS").
Name("Options Handler").
Handler(http.HandlerFunc(optionsHandler))
router.NotFoundHandler = http.HandlerFunc(notFound) router.NotFoundHandler = http.HandlerFunc(notFound)
@ -48,4 +48,4 @@ func optionsHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Headers", "Content-Type") w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE") w.Header().Set("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE")
w.WriteHeader(200) w.WriteHeader(200)
} }

View file

@ -9,6 +9,7 @@ type Route struct {
Handler http.HandlerFunc Handler http.HandlerFunc
} }
type Routes []Route type Routes []Route
var IndexRoutes = Routes{ var IndexRoutes = Routes{
@ -36,12 +37,6 @@ var IndexRoutes = Routes{
"/calendar", "/calendar",
CalendarIndex, CalendarIndex,
}, },
Route{
"ServicesIndex",
"GET",
"/services",
DecentralizedServicesIndex,
},
Route{ Route{
"SpaceUrlAdd", "SpaceUrlAdd",
"POST", "POST",
@ -66,4 +61,4 @@ var IndexRoutes = Routes{
"/refresh", "/refresh",
refreshData, refreshData,
}, },
} }

Binary file not shown.

View file

@ -1,78 +1,44 @@
package main 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 Feed struct {
Type string `json:"type"` Type string `json:"type"`
Url string `json:"url"` Url string `json:"url"`
} }
type Feeds struct { type Location struct {
Blog Feed `json:"blog"` Address string `json:"address"`
Wiki Feed `json:"wiki"` Lon float32 `json:"lon"`
Calendar Feed `json:"calendar"` 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 { type SpaceData struct {
Api string `json:"api"` Api string `json:"api"`
Space string `json:"space"` Space string `json:"space"`
Logo string `json:"logo"` Logo string `json:"logo"`
Url string `json:"url"` Url string `json:"url"`
Location Location `json:"location"` Location Location `json:"location"`
SpaceFed SpaceFed `json:"spacefed,omitempty"` Contact Contact `json:"contact"`
Cam []string `json:"cam,omitempty"` IssueReportChannels []string `json:"issue_report_channels"`
Stream *Stream `json:"stream,omitempty"` State State `json:"state"`
State State `json:"state"` Feeds Feeds `json:"feeds"`
// missing: `json:"events,omitempty"` Ext_ccc string `json:"ext_ccc"`
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"`
}

View file

@ -1,8 +1,7 @@
package main package main
type SpaceUrl struct { type SpaceUrl struct {
Id string `json:"id"` Url string `json:"url"`
Url string `json:"url"` Validated bool `json:"validated"`
Validated bool `json:"validated"` LastUpdated int64 `json:"lastUpdated"`
LastUpdated int64 `json:"lastUpdated"` }
}

View file

@ -2,38 +2,16 @@ version: "3"
services: services:
frontend: frontend:
build: ./frontend build: ./frontend
networks:
spaceapi-network:
ipv4_address: 172.16.238.10
image: gidsi/spaceapi-ccc-frontend:latest image: gidsi/spaceapi-ccc-frontend:latest
restart: always
expose:
- "80"
depends_on: depends_on:
- backend - backend
backend: backend:
build: ./backend build: ./backend
networks:
- spaceapi-network
image: gidsi/spaceapi-ccc-backend:latest image: gidsi/spaceapi-ccc-backend:latest
restart: always env_file: .env
environment:
- SHARED_SECRET=${SHARED_SECRET:-secret}
- DOKU_WIKI_USER=${DOKU_WIKI_USER}
- DOKU_WIKI_PASSWORD=${DOKU_WIKI_PASSWORD}
depends_on: depends_on:
- database - database
database: database:
image: mongo:latest image: mongo:latest
networks:
- spaceapi-network
restart: always
volumes: volumes:
- /opt/eva:/data/db - /opt/eva:/data/db
networks:
spaceapi-network:
ipam:
driver: default
config:
- subnet: 172.16.238.0/24

View file

@ -1,4 +1,4 @@
FROM node:16-alpine as builder FROM node as builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .

View file

@ -1,14 +1,11 @@
eva-frontend eve-frontend
======================= =======================
The React frontent running https://spaceapi.ccc.de
Usage Usage
----- -----
``` ```
npm install npm install -g yarn
npm start yarn install
yarn start
```
```

Some files were not shown because too many files have changed in this diff Show more