aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-05-25 22:10:49 +0700
committerShulhan <m.shulhan@gmail.com>2026-04-09 22:18:07 +0700
commitd0c5be4444ee2c1b8371456adb2f65bf6ef62234 (patch)
treebbd77b90f23619df8bef1ae7c7c9adce61c9c0f3
parent3d13cee518990fcfba0e65a9077a975b94ad209e (diff)
downloadgo-x-proposal-d0c5be4444ee2c1b8371456adb2f65bf6ef62234.tar.xz
cmd/www-go-proposal: static HTTP server to serve proposal with HTML
-rw-r--r--.gitignore4
-rw-r--r--Makefile20
-rw-r--r--assets/go-logo-blue.svg1
-rw-r--r--assets/style.css245
-rw-r--r--cmd/www-go-proposal/main.go38
-rw-r--r--go.mod21
-rw-r--r--go.sum18
-rw-r--r--html.tmpl73
8 files changed, 420 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1936a20
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.html
+/cmd/www-go-proposal/memfs.go
+/design/draft-module-local.md
+/www-go-proposal
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0223d8d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,20 @@
+.PHONY: embed
+embed:
+ ciigo -exclude "(cmd|go.mod|go.sum)" \
+ -template ./html.tmpl \
+ -out cmd/www-go-proposal/memfs.go \
+ embed .
+
+.PHONY: dev
+dev:
+ DEBUG=1 go run ./cmd/www-go-proposal
+
+.PHONY: deploy
+deploy: embed
+ go build ./cmd/www-go-proposal
+ rsync ./www-go-proposal golang-id.org:~/bin/
+
+.PHONY: deploy-vm
+deploy-vm: embed
+ go build ./cmd/www-go-proposal
+ rsync ./www-go-proposal golang-id.local:~/bin/
diff --git a/assets/go-logo-blue.svg b/assets/go-logo-blue.svg
new file mode 100644
index 0000000..da6ea83
--- /dev/null
+++ b/assets/go-logo-blue.svg
@@ -0,0 +1 @@
+<svg height="78" viewBox="0 0 207 78" width="207" xmlns="http://www.w3.org/2000/svg"><g fill="#00acd7" fill-rule="evenodd"><path d="m16.2 24.1c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h35.7c.4 0 .5.3.3.6l-1.7 2.6c-.2.3-.7.6-1 .6z"/><path d="m1.1 33.3c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h45.6c.4 0 .6.3.5.6l-.8 2.4c-.1.4-.5.6-.9.6z"/><path d="m25.3 42.5c-.4 0-.5-.3-.3-.6l1.4-2.5c.2-.3.6-.6 1-.6h20c.4 0 .6.3.6.7l-.2 2.4c0 .4-.4.7-.7.7z"/><g transform="translate(55)"><path d="m74.1 22.3c-6.3 1.6-10.6 2.8-16.8 4.4-1.5.4-1.6.5-2.9-1-1.5-1.7-2.6-2.8-4.7-3.8-6.3-3.1-12.4-2.2-18.1 1.5-6.8 4.4-10.3 10.9-10.2 19 .1 8 5.6 14.6 13.5 15.7 6.8.9 12.5-1.5 17-6.6.9-1.1 1.7-2.3 2.7-3.7-3.6 0-8.1 0-19.3 0-2.1 0-2.6-1.3-1.9-3 1.3-3.1 3.7-8.3 5.1-10.9.3-.6 1-1.6 2.5-1.6h36.4c-.2 2.7-.2 5.4-.6 8.1-1.1 7.2-3.8 13.8-8.2 19.6-7.2 9.5-16.6 15.4-28.5 17-9.8 1.3-18.9-.6-26.9-6.6-7.4-5.6-11.6-13-12.7-22.2-1.3-10.9 1.9-20.7 8.5-29.3 7.1-9.3 16.5-15.2 28-17.3 9.4-1.7 18.4-.6 26.5 4.9 5.3 3.5 9.1 8.3 11.6 14.1.6.9.2 1.4-1 1.7z"/><path d="m107.2 77.6c-9.1-.2-17.4-2.8-24.4-8.8-5.9-5.1-9.6-11.6-10.8-19.3-1.8-11.3 1.3-21.3 8.1-30.2 7.3-9.6 16.1-14.6 28-16.7 10.2-1.8 19.8-.8 28.5 5.1 7.9 5.4 12.8 12.7 14.1 22.3 1.7 13.5-2.2 24.5-11.5 33.9-6.6 6.7-14.7 10.9-24 12.8-2.7.5-5.4.6-8 .9zm23.8-40.4c-.1-1.3-.1-2.3-.3-3.3-1.8-9.9-10.9-15.5-20.4-13.3-9.3 2.1-15.3 8-17.5 17.4-1.8 7.8 2 15.7 9.2 18.9 5.5 2.4 11 2.1 16.3-.6 7.9-4.1 12.2-10.5 12.7-19.1z" fill-rule="nonzero"/></g></g></svg> \ No newline at end of file
diff --git a/assets/style.css b/assets/style.css
new file mode 100644
index 0000000..8700ad2
--- /dev/null
+++ b/assets/style.css
@@ -0,0 +1,245 @@
+body {
+ margin: 0;
+ font-family: Arial, sans-serif;
+ background-color: #fff;
+ line-height: 1.3;
+ text-align: center;
+ color: #222;
+}
+pre,
+code {
+ font-family: Menlo, monospace;
+ font-size: 0.875rem;
+}
+pre {
+ line-height: 1.4;
+ overflow-x: auto;
+ background: #efefef;
+ padding: 0.625rem;
+ border-radius: 0.3125rem;
+}
+a {
+ color: #007d9c;
+ text-decoration: none;
+}
+a.anchor {
+ position: absolute;
+ z-index: 1001;
+ width: 1.5ex;
+ margin-left: -1.5ex;
+ display: block;
+ text-decoration: none !important;
+ visibility: hidden;
+ text-align: center;
+ font-weight: 400;
+}
+a.anchor:hover {
+ cursor: pointer;
+ outline: 0;
+ visibility: visible;
+}
+a.anchor::before {
+ content: "\00A7";
+ font-size: 0.85em;
+ display: block;
+ padding-top: 0.1em;
+}
+
+p,
+li {
+ max-width: 50rem;
+ word-wrap: break-word;
+}
+p,
+pre,
+ul,
+ol {
+ margin: 1.25rem;
+}
+
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ margin: 1.25rem 0 1.25rem;
+ padding: 0.5rem 0.5rem 0.5rem 1.25rem;
+ color: #007d9c;
+ font-weight: bold;
+}
+h1 {
+ padding: 0.5rem 0;
+ font-size: 1.75rem;
+ line-height: 1;
+}
+h1 .text-muted {
+ color: #777;
+}
+h2 {
+ clear: right;
+ font-size: 1.25rem;
+ background: #e0ebf5;
+ line-height: 1.25;
+ font-weight: normal;
+ overflow: auto;
+ overflow-wrap: break-word;
+}
+h2 a {
+ font-weight: bold;
+}
+h3 {
+ font-size: 1.25rem;
+ line-height: 1.25;
+ overflow: auto;
+ overflow-wrap: break-word;
+}
+h3,
+h4 {
+ margin: 1.25rem 0rem;
+}
+h4 {
+ font-size: 1rem;
+}
+
+h2 > span,
+h3 > span {
+ float: right;
+ margin: 0 25px 0 0;
+ font-weight: normal;
+ color: #5279c7;
+}
+h1:hover > a.anchor,
+h2:hover > a.anchor,
+h3:hover > a.anchor,
+h4:hover > a.anchor,
+h5:hover > a.anchor,
+h6:hover > a.anchor {
+ visibility: visible;
+}
+
+dl {
+ margin: 1.25rem;
+}
+dd {
+ margin: 0 0 0 1.25rem;
+}
+dd p {
+ margin: 0.5rem 0 1.25rem 1.25rem;
+}
+td p {
+ margin: 0 0 0 1.25rem;
+}
+
+/**
+ * Custom classes for pages
+ */
+
+.topbar {
+ background: #e0ebf5;
+ height: 4rem;
+ overflow: hidden;
+}
+
+.topbar .top-heading,
+.topbar .menu {
+ padding: 1.313rem 0;
+ font-size: 1.25rem;
+ font-weight: normal;
+}
+.topbar .top-heading {
+ float: left;
+}
+.topbar .top-heading a {
+ color: #222;
+ text-decoration: none;
+}
+
+.top-heading .header-logo {
+ height: 2rem;
+ width: 5.125rem;
+}
+
+.topbar .menu {
+ float: right;
+}
+.topbar .menu a {
+ margin: 0.625rem 0.125rem;
+ padding: 0.625rem;
+ color: white;
+ background: #007d9c;
+ border: 0.0625rem solid #007d9c;
+ border-radius: 5px;
+}
+.topbar .menu form {
+ display: inline-block;
+}
+
+.page {
+ width: 100%;
+}
+
+.page > .container,
+.topbar > .container,
+.footer > .container {
+ margin-left: auto;
+ margin-right: auto;
+ padding: 0 1.25rem;
+ max-width: 59.38rem;
+}
+
+.page > .container {
+ text-align: left;
+}
+
+.container .meta {
+ font-style: italic;
+ margin: 1.25rem;
+}
+
+#footer {
+ display: none;
+}
+.footer {
+ text-align: center;
+ color: #666;
+ font-size: 0.875rem;
+ margin: 2.5rem 0;
+}
+
+/** Custom classes for asciidoc */
+#toctitle {
+ display: none;
+}
+#toc li {
+ list-style: none;
+}
+#toc ul .sectlevel1 {
+ padding: 0px;
+ margin: 4px;
+}
+#toc ul .sectlevel2 {
+ margin: 4px;
+}
+
+.admonitionblock {
+ margin: 0 auto;
+}
+.admonitionblock.note {
+ background-color: #e0ebf5;
+ border-radius: 0.5em;
+}
+.admonitionblock .icon {
+ border-right: 1px solid white;
+ font-weight: bold;
+ padding: 0.5em;
+ text-transform: uppercase;
+}
+.admonitionblock .content {
+ padding: 0.5em;
+}
+@media screen and (max-width: 992px) {
+ #toc {
+ all: unset;
+ }
+}
diff --git a/cmd/www-go-proposal/main.go b/cmd/www-go-proposal/main.go
new file mode 100644
index 0000000..d319a16
--- /dev/null
+++ b/cmd/www-go-proposal/main.go
@@ -0,0 +1,38 @@
+// Copyright 2021, The golang-id.org Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package main
+
+import (
+ "flag"
+ "log"
+ "os"
+
+ "git.sr.ht/~shulhan/ciigo"
+ "github.com/shuLhan/share/lib/memfs"
+)
+
+var memFS *memfs.MemFS
+
+func main() {
+ var port string
+
+ flag.StringVar(&port, `port`, `5001`, `HTTP port server`)
+ flag.Parse()
+
+ var serveOpts = &ciigo.ServeOptions{
+ ConvertOptions: ciigo.ConvertOptions{
+ Root: `.`,
+ Exclude: `(cmd|go.mod|go.sum)`,
+ HtmlTemplate: `html.tmpl`,
+ },
+ Mfs: memFS,
+ Address: `0.0.0.0:` + port,
+ IsDevelopment: len(os.Getenv(`DEBUG`)) > 0,
+ }
+ var err = ciigo.Serve(serveOpts)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..527829b
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,21 @@
+module git.sr.ht/~shulhan/go-x-proposal
+
+go 1.19
+
+require (
+ git.sr.ht/~shulhan/ciigo v0.10.0
+ github.com/shuLhan/share v0.46.0
+)
+
+require (
+ git.sr.ht/~shulhan/asciidoctor-go v0.4.1 // indirect
+ github.com/yuin/goldmark v1.5.4 // indirect
+ github.com/yuin/goldmark-meta v1.1.0 // indirect
+ golang.org/x/net v0.7.0 // indirect
+ golang.org/x/sys v0.5.0 // indirect
+ gopkg.in/yaml.v2 v2.4.0 // indirect
+)
+
+//replace github.com/shuLhan/share => ../share
+
+//replace git.sr.ht/~shulhan/ciigo => ../ciigo
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..abc150f
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,18 @@
+git.sr.ht/~shulhan/asciidoctor-go v0.4.1 h1:Zev0L5HyMjH43sPaoJal8E/Hmbel/akoGOxNykhN4Dw=
+git.sr.ht/~shulhan/asciidoctor-go v0.4.1/go.mod h1:vRHDUl3o3UzDkvVR9dEFYQ0JDqOh0TKpOZWvOh/CGZU=
+git.sr.ht/~shulhan/ciigo v0.10.0 h1:s1SJ3/NzBcbOLmEZ4z1Cx9Vf7ZdDIvm45b7KMCZKzEY=
+git.sr.ht/~shulhan/ciigo v0.10.0/go.mod h1:cG6av+ywJZZp96F43kmLB2QWjm2hYiahbsbeTX/vlgk=
+github.com/shuLhan/share v0.46.0 h1:cF0Ngj7wVA6TIcdSmfrqxOwMB3hZ+4df5cJf4GGCun4=
+github.com/shuLhan/share v0.46.0/go.mod h1:BhnIWJxq84BTOs3Z2gLFAN8ih9mBfhZbRIjqGupGJag=
+github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU=
+github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc=
+github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0=
+golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
+golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
+golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
diff --git a/html.tmpl b/html.tmpl
new file mode 100644
index 0000000..4ab5989
--- /dev/null
+++ b/html.tmpl
@@ -0,0 +1,73 @@
+<!DOCTYPE html lang="id">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="theme-color" content="#375EAB" />
+ <meta name="description" content="Situs komunitas Go Indonesia"/>
+ <meta keywords="komunitas Go indonesia"/>
+ <meta name="robots" content="index,follow"/>
+
+ <title>{{.Title}}</title>
+ <link rel="stylesheet" href="/assets/style.css" />
+
+ {{- range .Styles}}
+ <link rel="stylesheet" href="{{.}}" />
+ {{- end}}
+
+ <!-- Global site tag (gtag.js) - Google Analytics -->
+ <script
+ async
+ src="https://www.googletagmanager.com/gtag/js?id=UA-2502278-10"
+ ></script>
+ <script>
+ window.dataLayer = window.dataLayer || []
+ function gtag() {
+ dataLayer.push(arguments)
+ }
+ gtag("js", new Date())
+
+ gtag("config", "UA-2502278-10")
+ </script>
+ </head>
+ <body>
+ <div class="topbar">
+ <div class="container">
+ <div class="top-heading">
+ <a href="/">
+ <img class="header-logo" src="/assets/go-logo-blue.svg" />
+ </a>
+ </div>
+ <div class="menu">
+ <a href="https://tour.golang-id.org" target="_blank">Tur</a>
+ <a href="/doc">Dokumentasi</a>
+ <a href="/blog">Blog</a>
+ <a href="https://play.golang.org" target="_blank">Coba</a>
+ <form class="item" action="/_internal/search">
+ <input type="text" name="q" placeholder="Cari" />
+ </form>
+ </div>
+ </div>
+ </div>
+
+ <div class="page">
+ <div class="container">
+ {{.Body}}
+ </div>
+ <!-- .container -->
+ </div>
+ <!-- #page -->
+
+ <div class="footer">
+ <div class="container">
+ Halaman situs ini berlisensikan
+ <a href="https://creativecommons.org/licenses/by/3.0/"
+ >Creative Commons Attribution 3.0</a
+ >, dan sumber kode berlisensikan <a href="/LICENSE">BSD</a>.
+ <br />
+ Dibangun menggunakan
+ <a href="https://sr.ht/~shulhan/ciigo">ciigo</a>.
+ </div>
+ </div>
+ </body>
+</html>