zenfo

package module
v0.0.0-...-7e6944c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2021 License: AGPL-3.0 Imports: 19 Imported by: 0

README

zenfo.info

screen

About

Zen retreats sound fun, right? But how do you get involved? When is a retreat happening nearby? Is the retreat beginner friendly?

All of these questions (and more!) is what zenfo.info aims to answer. Unless you're actively involved in a community, it may be difficult to learn of new events going on near your area. Even if you are involved in a community, the events you hear of in person are usually just related to that specific group.

What if you're traveling, and wish to attend a short retreat? Many Zen centers have websites, and some list events on a calendar page. However, some groups only notify of events in person or mailing list. Zen groups are typically low budget, and usually not too tech savvy. This is where zenfo.info comes in - simply visit the site to see a compiled list of events going on around the world.

Nitty Gritty

There are three main pieces:

  1. Crawlers

The crawlers gather event information from a list of specific websites. Any information found is stored into Postgres.

  1. HTTP API

A web server provides API endpoints to retreive event information.

  1. UI

React frontend calls API to provide something useable on the browser.

Sources

So far there are two sources:

  1. San Francisco Zen Center (sfzc.org)
  2. Angel City Zen Center (aczc.org)

Sources are scraped by using the Worker interface. All workers share a common HTTP client which provides a custom user agent. And in the future there will need to be rate limiting per site.

Milestones for 1.0 release

  1. Add at least two more sources for crawling. Ideally one from East Bay, and one South Bay.
  2. Add basic frontend UI, ideally something in JS.
  3. Add some sort of detection on when a crawler is completely busted and needs updating.
  4. Add Dockerfile for easy deploy.

Build database and backend API

make docker

make setup

make build

make db

make http-dev

Run frontend

I do this outside of Docker.

npm install

npm run start

License

Currently this project is licensed under AGPL v3.0. See LICENSE for details.

I'm usually not a fan of anything GPL, but with this project it feels right. License may change in the future to something more permissive.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(useLocal bool, name string) http.FileSystem

Dir returns a http.Filesystem for the embedded assets on a given prefix dir. If useLocal is true, the filesystem's contents are instead used.

func FS

func FS(useLocal bool) http.FileSystem

FS returns a http.Filesystem for the embedded assets. If useLocal is true, the filesystem's contents are instead used.

func FSByte

func FSByte(useLocal bool, name string) ([]byte, error)

FSByte returns the named file from the embedded assets. If useLocal is true, the filesystem's contents are instead used.

func FSMustByte

func FSMustByte(useLocal bool, name string) []byte

FSMustByte is the same as FSByte, but panics if name is not present.

func FSMustString

func FSMustString(useLocal bool, name string) string

FSMustString is the string version of FSMustByte.

func FSString

func FSString(useLocal bool, name string) (string, error)

FSString is the string version of FSByte.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API provides HTTP endpoints for serving events

func NewAPI

func NewAPI(dbUser, dbName, cert, key string, dev bool) (*API, error)

NewAPI returns new API object

func (*API) Close

func (api *API) Close() error

Close closes DB handler

func (*API) Run

func (api *API) Run() error

Run starts web server to listen on configured port

type Aczc

type Aczc struct {
	// contains filtered or unexported fields
}

Aczc crawls aczc.org, satisfies Worker interface

func (*Aczc) Desc

func (a *Aczc) Desc() string

Desc returns description for website crawled

func (*Aczc) Events

func (a *Aczc) Events() ([]*Event, error)

Events hits aczc events page and returns slice of Event types https://www.aczc.org/schedule/

func (*Aczc) Init

func (a *Aczc) Init(client *Client, log chan string) error

Init sets HTTP client and defines internal venue map

func (*Aczc) Name

func (a *Aczc) Name() string

Name return human-friendly name for worker for logs

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps http.Client for custom UA string, Getting, etc. TODO Add rate limit per worker

func NewClient

func NewClient() *Client

NewClient returns new Client object

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

Get wraps core http GET functionality with custom UA string

type Event

type Event struct {
	ID    int       `json:"id"`
	Name  string    `json:"name"`
	Blurb string    `json:"blurb"`
	Desc  string    `json:"desc"`
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
	URL   string    `json:"url"`
	Venue *Venue    `json:"venue"`
}

Event represents events for DB store and web API

type Fz

type Fz struct {
	// contains filtered or unexported fields
}

Fz crawls floatingzendo.org, satisfies Worker interface

func (*Fz) Desc

func (f *Fz) Desc() string

Desc returns description for website crawled

func (*Fz) Events

func (f *Fz) Events() ([]*Event, error)

Events hits floating zendo events page and returns slice of Event types http://www.floatingzendo.org/events/

func (*Fz) Init

func (f *Fz) Init(client *Client, log chan string) error

Init sets HTTP client and defines internal venue map

func (*Fz) Name

func (f *Fz) Name() string

Name returns human-friendly name for worker logs

type Jikoji

type Jikoji struct {
	// contains filtered or unexported fields
}

Jikoji crawls jikoji.org, satisfies Worker interface

func (*Jikoji) Desc

func (j *Jikoji) Desc() string

Desc returns description for website crawled

func (*Jikoji) Events

func (j *Jikoji) Events() ([]*Event, error)

Events hits jikoji events page and returns slice of Event types https://www.jikoji.org/jikoji-events

func (*Jikoji) Init

func (j *Jikoji) Init(client *Client, log chan string) error

Init sets HTTP client and defines internal venue map

func (*Jikoji) Name

func (j *Jikoji) Name() string

Name returns human-friendly name for worker logs

type Manager

type Manager struct {
	DryRun     bool
	DeleteRows bool
	// contains filtered or unexported fields
}

Manager handles running all workers

func NewManager

func NewManager(dbName, dbUser string) (*Manager, error)

NewManager builds internal worker map and returns new Mananger object

func (*Manager) Run

func (m *Manager) Run() error

Run iterates all workers for execution

type Sfzc

type Sfzc struct {
	// contains filtered or unexported fields
}

Sfzc crawls sfzc.org, satisfies Worker interface

func (*Sfzc) Desc

func (s *Sfzc) Desc() string

Desc returns description for website crawled

func (*Sfzc) Events

func (s *Sfzc) Events() ([]*Event, error)

Events hits sfcz JSON API and returns slice of Event types

func (*Sfzc) Init

func (s *Sfzc) Init(client *Client, log chan string) error

Init sets HTTP client and defines internal venue map

func (*Sfzc) Name

func (s *Sfzc) Name() string

Name return human-friendly name for worker for logs

type Venue

type Venue struct {
	ID      int     `json:"id"`
	Name    string  `json:"name"`
	Addr    string  `json:"addr"`
	Lat     float32 `json:"lat"`
	Lng     float32 `json:"lng"`
	Website string  `json:"website"`
	Phone   string  `json:"phone"`
	Email   string  `json:"email"`
}

Venue represents a venue entry for DB store and web API

type Vz

type Vz struct {
	// contains filtered or unexported fields
}

Vz crawls villagezendo.org, satisfies Worker interface

func (*Vz) Desc

func (v *Vz) Desc() string

Desc returns description for website crawled

func (*Vz) Events

func (v *Vz) Events() ([]*Event, error)

Events hits JSON API and returns slice of Event types

func (*Vz) Init

func (v *Vz) Init(client *Client, log chan string) error

Init sets HTTP client and defines internal venue map

func (*Vz) Name

func (v *Vz) Name() string

Name return human-friendly name for worker for logs

type Worker

type Worker interface {
	Name() string
	Init(*Client, chan string) error
	Desc() string
	Events() ([]*Event, error)
}

Worker provides interface for plugin-like crawlers per source

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL