1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 03:36:16 +00:00

Drop support of icon redefining, use a different url for icons

This commit is contained in:
Timur Ismagilov 2021-05-09 15:07:01 +05:00
parent 662794dd59
commit b53a6d5dff
11 changed files with 82 additions and 41 deletions

9
.gitignore vendored
View File

@ -1,6 +1,9 @@
mycorrhiza mycorrhiza
hyphae/*.gog
# go editors and IDEA folders # VScode and IDEA folders
.idea/
.vscode/ .vscode/
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="CssUnknownTarget" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
</profile>
</component>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mycorrhiza.iml" filepath="$PROJECT_DIR$/.idea/mycorrhiza.iml" />
</modules>
</component>
</project>

9
.idea/mycorrhiza.iml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

7
.idea/vcs.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/metarrhiza" vcs="Git" />
</component>
</project>

View File

@ -228,12 +228,12 @@ main h1:not(.navi-title) {font-size:1.7rem;}
blockquote { margin-left: 0; padding-left: 1rem; } blockquote { margin-left: 0; padding-left: 1rem; }
.wikilink_external::before { display: inline-block; width: 18px; height: 16px; vertical-align: sub; } .wikilink_external::before { display: inline-block; width: 18px; height: 16px; vertical-align: sub; }
/* .wikilink_external { padding-left: 16px; } */ /* .wikilink_external { padding-left: 16px; } */
.wikilink_gopher::before { content: url("/static/icon/gopher"); } .wikilink_gopher::before { content: url("/assets/icon/gopher"); }
.wikilink_http::before { content: url("/static/icon/http"); } .wikilink_http::before { content: url("/assets/icon/http"); }
.wikilink_https::before { content: url("/static/icon/http"); } .wikilink_https::before { content: url("/assets/icon/http"); }
/* .wikilink_https { background: transparent url("/static/icon/http") center left no-repeat; } */ /* .wikilink_https { background: transparent url("/assets/icon/http") center left no-repeat; } */
.wikilink_gemini::before { content: url("/static/icon/gemini"); } .wikilink_gemini::before { content: url("/assets/icon/gemini"); }
.wikilink_mailto::before { content: url("/static/icon/mailto"); } .wikilink_mailto::before { content: url("/assets/icon/mailto"); }
article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; } article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; }
main h1, main h2, main h3, main h4, main h5, main h6 { margin: 1.5rem 0 0 0; } main h1, main h2, main h3, main h4, main h5, main h6 { margin: 1.5rem 0 0 0; }

View File

@ -113,12 +113,12 @@ main h1:not(.navi-title) {font-size:1.7rem;}
blockquote { margin-left: 0; padding-left: 1rem; } blockquote { margin-left: 0; padding-left: 1rem; }
.wikilink_external::before { display: inline-block; width: 18px; height: 16px; vertical-align: sub; } .wikilink_external::before { display: inline-block; width: 18px; height: 16px; vertical-align: sub; }
/* .wikilink_external { padding-left: 16px; } */ /* .wikilink_external { padding-left: 16px; } */
.wikilink_gopher::before { content: url("/static/icon/gopher"); } .wikilink_gopher::before { content: url("/assets/icon/gopher"); }
.wikilink_http::before { content: url("/static/icon/http"); } .wikilink_http::before { content: url("/assets/icon/http"); }
.wikilink_https::before { content: url("/static/icon/http"); } .wikilink_https::before { content: url("/assets/icon/http"); }
/* .wikilink_https { background: transparent url("/static/icon/http") center left no-repeat; } */ /* .wikilink_https { background: transparent url("/assets/icon/http") center left no-repeat; } */
.wikilink_gemini::before { content: url("/static/icon/gemini"); } .wikilink_gemini::before { content: url("/assets/icon/gemini"); }
.wikilink_mailto::before { content: url("/static/icon/mailto"); } .wikilink_mailto::before { content: url("/assets/icon/mailto"); }
article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; } article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; }
main h1, main h2, main h3, main h4, main h5, main h6 { margin: 1.5rem 0 0 0; } main h1, main h2, main h3, main h4, main h5, main h6 { margin: 1.5rem 0 0 0; }

36
main.go
View File

@ -7,6 +7,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/cfg" "github.com/bouncepaw/mycorrhiza/cfg"
"io"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
@ -48,8 +49,6 @@ func HttpErr(w http.ResponseWriter, status int, name, title, errMsg string) {
// This part is present in all html documents. // This part is present in all html documents.
var base = views.BaseHTML var base = views.BaseHTML
// Stop the wiki
func handlerStyle(w http.ResponseWriter, rq *http.Request) { func handlerStyle(w http.ResponseWriter, rq *http.Request) {
prepareRq(rq) prepareRq(rq)
if _, err := os.Stat(cfg.WikiDir + "/static/common.css"); err == nil { if _, err := os.Stat(cfg.WikiDir + "/static/common.css"); err == nil {
@ -69,33 +68,34 @@ func handlerToolbar(w http.ResponseWriter, rq *http.Request) {
w.Write([]byte(assets.ToolbarJS())) w.Write([]byte(assets.ToolbarJS()))
} }
// handlerIcon serves the requested icon. All icons are distributed as part of the Mycorrhiza binary.
//
// See assets/assets/icon/ for icons themselves, see assets/assets.qtpl for their sources.
func handlerIcon(w http.ResponseWriter, rq *http.Request) { func handlerIcon(w http.ResponseWriter, rq *http.Request) {
iconName := strings.TrimPrefix(rq.URL.Path, "/static/icon/") iconName := strings.TrimPrefix(rq.URL.Path, "/assets/icon/")
if iconName == "https" { if iconName == "https" {
iconName = "http" iconName = "http"
} }
files, err := ioutil.ReadDir(WikiDir + "/static/icon")
if err == nil {
for _, f := range files {
if strings.HasPrefix(f.Name(), iconName+"-protocol-icon") {
http.ServeFile(w, rq, WikiDir+"/static/icon/"+f.Name())
return
}
}
}
w.Header().Set("Content-Type", "image/svg+xml") w.Header().Set("Content-Type", "image/svg+xml")
icon := func() string {
switch iconName { switch iconName {
case "gemini": case "gemini":
w.Write([]byte(assets.IconGemini())) return assets.IconGemini()
case "mailto": case "mailto":
w.Write([]byte(assets.IconMailto())) return assets.IconMailto()
case "gopher": case "gopher":
w.Write([]byte(assets.IconGopher())) return assets.IconGopher()
case "feed": case "feed":
w.Write([]byte(assets.IconFeed())) return assets.IconFeed()
default: default:
w.Write([]byte(assets.IconHTTP())) return assets.IconHTTP()
} }
}()
_, err := io.WriteString(w, icon)
if err != nil {
log.Println(err)
}
} }
func handlerUserList(w http.ResponseWriter, rq *http.Request) { func handlerUserList(w http.ResponseWriter, rq *http.Request) {
@ -160,7 +160,7 @@ func main() {
}) })
http.HandleFunc("/static/common.css", handlerStyle) http.HandleFunc("/static/common.css", handlerStyle)
http.HandleFunc("/static/toolbar.js", handlerToolbar) http.HandleFunc("/static/toolbar.js", handlerToolbar)
http.HandleFunc("/static/icon/", handlerIcon) http.HandleFunc("/assets/icon/", handlerIcon)
http.HandleFunc("/robots.txt", handlerRobotsTxt) http.HandleFunc("/robots.txt", handlerRobotsTxt)
http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) {
addr, _ := url.Parse("/hypha/" + cfg.HomeHypha) // Let's pray it never fails addr, _ := url.Parse("/hypha/" + cfg.HomeHypha) // Let's pray it never fails

View File

@ -45,7 +45,7 @@ if err != nil {
recent changes recent changes
</nav> </nav>
<p><img class="icon" width="20" height="20" src="/static/icon/feed">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p> <p><img class="icon" width="20" height="20" src="/assets/icon/feed">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p>
{% comment %} {% comment %}
Here I am, willing to add some accessibility using ARIA. Turns out, Here I am, willing to add some accessibility using ARIA. Turns out,

View File

@ -163,7 +163,7 @@ func StreamRecentChangesHTML(qw422016 *qt422016.Writer, n int) {
recent changes recent changes
</nav> </nav>
<p><img class="icon" width="20" height="20" src="/static/icon/feed">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p> <p><img class="icon" width="20" height="20" src="/assets/icon/feed">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p>
`) `)
//line views/history.qtpl:55 //line views/history.qtpl:55