Browse Source

Generalize base template for different platforms

master
Matt Baer 3 years ago
parent
commit
34c3470e14
3 changed files with 35 additions and 9 deletions
  1. +5
    -2
      handlers.go
  2. +23
    -0
      platform/platforms.go
  3. +7
    -7
      templates/base.tmpl

+ 5
- 2
handlers.go View File

@@ -1,6 +1,7 @@
package main package main


import ( import (
"code.as/writeas/developers-site/platform"
"fmt" "fmt"
"github.com/writeas/web-core/log" "github.com/writeas/web-core/log"
"net/http" "net/http"
@@ -55,9 +56,11 @@ func viewPage(w http.ResponseWriter, r *http.Request) {
return return
} }
p := struct { p := struct {
Path string
Path string
Platform platform.Platform
}{ }{
Path: name,
Path: name,
Platform: platform.WriteAs,
} }


err = t.ExecuteTemplate(w, "base", p) err = t.ExecuteTemplate(w, "base", p)


+ 23
- 0
platform/platforms.go View File

@@ -0,0 +1,23 @@
package platform

type Platform struct {
Name string
URL string
LogoURL string
StyleSheetURL string
CodeAsName string
GitHubName string
MatomoID int
}

var (
WriteAs = Platform{
Name: "Write.as",
URL: "https://write.as",
LogoURL: "https://write.as/img/w-sq.svg",
StyleSheetURL: "https://write.as/css/write.css",
CodeAsName: "writeas",
GitHubName: "writeas",
MatomoID: 7,
}
)

+ 7
- 7
templates/base.tmpl View File

@@ -3,14 +3,14 @@
<head> <head>
{{ template "head" . }} {{ template "head" . }}
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="https://write.as/css/write.css" />
<link rel="stylesheet" type="text/css" href="{{.Platform.StyleSheetURL}}" />
<link rel="stylesheet" type="text/css" href="/css/dev.css" /> <link rel="stylesheet" type="text/css" href="/css/dev.css" />
</head> </head>
<body {{template "body-attrs" .}}> <body {{template "body-attrs" .}}>
<header style="margin: 1rem;"> <header style="margin: 1rem;">
<nav id="full-nav" class="solutionize"> <nav id="full-nav" class="solutionize">
<div class="left-side"> <div class="left-side">
<a href="https://write.as" class="dim"><img alt="Write.as - home" src="https://write.as/img/w-sq.svg"/></a>
<a href="{{.Platform.URL}}" class="dim"><img alt="{{.Platform.Name}} - home" src="{{.Platform.LogoURL}}"/></a>
</div> </div>
<nav id="user-nav"> <nav id="user-nav">
<nav class="tabs" aria-label="Main Navigation"> <nav class="tabs" aria-label="Main Navigation">
@@ -38,7 +38,7 @@
(function() { (function() {
var u="https://analytics.write.as/"; var u="https://analytics.write.as/";
_paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '7']);
_paq.push(['setSiteId', '{{.Platform.MatomoID}}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})(); })();
@@ -56,7 +56,7 @@
})(); })();
</script> </script>


<noscript><p><img src="https://analytics.write.as/piwik.php?idsite=7&rec=1" style="border:0;" alt="" /></p></noscript>
<noscript><p><img src="https://analytics.write.as/piwik.php?idsite={{.Platform.MatomoID}}&rec=1" style="border:0;" alt="" /></p></noscript>
</body> </body>
</html>{{end}} </html>{{end}}


@@ -82,8 +82,8 @@
<h3>open source</h3> <h3>open source</h3>
<ul> <ul>
<li><a href="https://writefreely.org">writefreely</a></li> <li><a href="https://writefreely.org">writefreely</a></li>
<li><a href="https://code.as/writeas">code.as</a></li>
<li><a href="https://github.com/writeas">github</a></li>
<li><a href="https://code.as/{{.Platform.CodeAsName}}">code.as</a></li>
{{if .Platform.GitHubName}}<li><a href="https://github.com/{{.Platform.GitHubName}}">github</a></li>{{end}}
</ul> </ul>
</div> </div>
<div class="fourth"> <div class="fourth">
@@ -94,7 +94,7 @@
</ul> </ul>
</div> </div>
<div class="fourth"> <div class="fourth">
<h3><a class="home" style="font-weight: normal" href="https://write.as">write.as</a></h3>
<h3><a class="home" style="font-weight: normal; text-transform: lowercase" href="https://write.as">Write.as</a></h3>
<ul> <ul>
<li><a href="https://write.as/contact">contact</a></li> <li><a href="https://write.as/contact">contact</a></li>
<li><a href="https://write.as/privacy">privacy</a></li> <li><a href="https://write.as/privacy">privacy</a></li>


Loading…
Cancel
Save