ndex file not in category list; index file redirects to category
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Arnas Udovicius 2022-08-30 20:14:05 +03:00
parent 4080d7992f
commit a588e6e573
3 changed files with 7 additions and 1 deletions

View file

@ -19,3 +19,6 @@ __DONE__
* migrate to gRPC
* routing, not found
* template engine
* all other languages under sgs
* index file redirects to category
* index file displayed as intro to category

View file

@ -133,6 +133,9 @@ func process(_ context.Context, w gemini.ResponseWriter, r *gemini.Request) {
renderSearch(lang, w, r, client)
case regexp.MustCompile(`^/(sgs|en)/f/?$`).MatchString(r.URL.Path):
renderAllFiles(lang, w, client)
case regexp.MustCompile(`^/(sgs|en)/f/([\p{L}\d_+.]+/)+[\d\w]+/index.gmi$`).MatchString(r.URL.Path):
urlParts := strings.Split(r.URL.Path, "/")
w.WriteHeader(gemini.StatusPermanentRedirect, strings.Join(urlParts[:(len(urlParts)-2)], "/"))
case regexp.MustCompile(`^/(sgs|en)/f/([\p{L}\d_+.]+/)+[\d\w]+/[\p{L}\d_+.]+.gmi$`).MatchString(r.URL.Path):
renderFile(lang, w, r, client)
case regexp.MustCompile(`^/(sgs|en)/f/[\p{L}\d_+.]+(/[\p{L}\d_+.]+)*/?$`).MatchString(r.URL.Path):

View file

@ -6,7 +6,7 @@
🌙 {{ indexFile.File.Created}}
{{ indexFile.File.Copyright }}{% endif %}
{% for file in tree.RootFiles %}{{ text_url(lang, file) }}
{% for file in tree.RootFiles %}{% if file.Name != "index.md" %}{{ text_url(lang, file) }}{% endif %}
{% endfor %}
{% if tree.Categories %}### {% if lang == "sgs" %}Kateguorėjės{% else %}Categories{% endif %}
{% for cat, count in tree.Categories %}{{ category_url(lang, tree.Path|add:"/"|add:cat, cat, count) }}