Small comment changes

This commit is contained in:
Simon Martens
2025-01-08 15:53:44 +01:00
parent aaf5e8241a
commit a62a09b258
5 changed files with 17 additions and 57 deletions

View File

@@ -21,17 +21,6 @@ const (
DEV_CONFIG = "config.dev.json"
)
// 1. Check if folder exists
// - If not, clone the repo, if possible or throw if error
// 2. If the folder exists, we try to serialize -- and spawn a goroutine to pull.
// Upon pulling, we read in the current state of the repository, even if it's up to date.
// -> If the repo was changed we execute a callback and parse again.
// -> If pulling fails, we retry after a certain amount of time.
// Still we can continue if serialization proceeds.
// -> If serialization fails, we throw an error, log it. We try to pull in the background.
// - setup commit date & hash
// - Setup GitHub webhook if set
func main() {
cfg := providers.NewConfigProvider([]string{DEV_CONFIG, DEFAULT_CONFIG})
if err := cfg.Read(); err != nil {

View File

@@ -17,12 +17,11 @@ var InvalidStateError = errors.New("The GitProvider is not in a valid state. Fix
var NoURLProvidedError = errors.New("No URL provided for GitProvider.")
var NoPathProvidedError = errors.New("No path or branch provided for GitProvider.")
// NOTE: GitProvider does not open XML files, it can only
// - read in information from the repo, given a path
// - clone the repo, given an URL & a path
// - pull the repo, given a path
// In case of success in either case it updates the commit hash and date and closes the repo again.
// The Files are opened and serialized by the FSProvider, which operates on the same file path.
// NOTE: GitProvider does not open any worktree files, it only
// - reads in information from the repo, given a path
// - clones a repo, given an URL & a path
// - pulls a repo, given a path
// In case of success it updates it's state: the commit hash and date. Then it closes the repo.
type GitProvider struct {
mu sync.Mutex

0
scratchpad.md Normal file
View File

View File

@@ -25,7 +25,8 @@ const (
SERVER_TIMEOUT = 16 * time.Second
// INFO: Maybe this is too long/short?
CACHE_TIME = 24 * time.Hour
CACHE_TIME = 24 * time.Hour
CACHE_GC_INTERVAL = 120 * time.Second
)
const (
@@ -99,7 +100,7 @@ func (s *Server) Start() {
if s.cache == nil {
s.cache = memory.New(memory.Config{
GCInterval: 30 * time.Second,
GCInterval: CACHE_GC_INTERVAL,
})
}
@@ -117,7 +118,7 @@ func (s *Server) Start() {
ErrorHandler: fiber.DefaultErrorHandler,
// WARNING: The app must be run in a console, since this uses environment variables:
// It is not trivial to turn this on, since we need to mark goroutines that can be started only once.
// It is not trivial to turn this on, since we need to mark goroutines that must be started only once.
// Prefork: true,
StreamRequestBody: false,
WriteTimeout: REQUEST_TIMEOUT,
@@ -138,8 +139,8 @@ func (s *Server) Start() {
srv.Use(ASSETS_URL_PREFIX, etag.New())
srv.Use(ASSETS_URL_PREFIX, static(&views.StaticFS))
// TODO: Dont cache static assets, bc storage gets huge
// INFO: Maybe fiber does this already?
// TODO: Dont cache static assets, bc storage gets huge on images.
// -> Maybe fiber does this already, automatically?
if s.Config.Debug {
srv.Use(cache.New(cache.Config{
Next: CacheFunc,
@@ -156,9 +157,6 @@ func (s *Server) Start() {
}))
}
// TODO: this is probably a bad idea, since it basically applies to every /XXXX URL
// And probably creates problems with static files, and in case we add a front page later.
// That's why we redirect to /1764 on "/ " and don´t use an optional /:year?
srv.Get("/", func(c *fiber.Ctx) error {
c.Redirect(INDEX_URL)
return nil
@@ -168,8 +166,12 @@ func (s *Server) Start() {
srv.Get(CATEGORY_OVERVIEW_URL, controllers.GetCategory(s.kgpz))
srv.Get(AGENTS_OVERVIEW_URL, controllers.GetAgents(s.kgpz))
// TODO: Same here, this prob applies to all paths with two or three segments, which is bad.
// Prob better to do /ausgabe/:year/:issue/:page? here and /jahrgang/:year? above.
// TODO: YEAR_OVERVIEW_URL being /:year is a bad idea, since it captures basically everything,
// probably creating problems with static files, and also in case we add a front page later.
// That's why we redirect to /1764 on "/ " above and don´t use an optional /:year? paramter.
// -> Check SEO requirements on index pages that are 301 forwarded.
// This applies to all paths with two or three segments without a static prefix:
// Prob better to do /ausgabe/:year/:issue/:page? and /jahrgang/:year? respectively.
srv.Get(YEAR_OVERVIEW_URL, controllers.GetYear(s.kgpz))
srv.Get(ISSSUE_URL, controllers.GetIssue(s.kgpz))
srv.Get(ADDITIONS_URL, controllers.GetIssue(s.kgpz))

View File

@@ -189,33 +189,3 @@ func (p Piece) ReferencesWork(id string) (*WorkRef, bool) {
}
return nil, false
}
// TODO: We can make this fast depending on which category to look for
// but we'll have to define rules for every single category (~35 of them)
func (p Piece) IsCat(k string) bool {
for _, c := range p.CategoryRefs {
if c.Category == k {
return true
}
}
for _, c := range p.WorkRefs {
if c.Category == k {
return true
}
}
for _, c := range p.AgentRefs {
if c.Category == k {
return true
}
}
for _, c := range p.PieceRefs {
if c.Category == k {
return true
}
}
return false
}