소스 검색

Added launch and selection interface

Toby Chui 3 년 전
부모
커밋
23fe8ad1e6

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+*.exe

+ 3 - 0
src/go.mod

@@ -0,0 +1,3 @@
+module tainan-eat.com/tainan-eat
+
+go 1.17

+ 56 - 0
src/main.go

@@ -0,0 +1,56 @@
+package main
+
+import (
+	"flag"
+	"log"
+	"net/http"
+	"os"
+	"os/signal"
+	"syscall"
+)
+
+/*
+	台南吃貨 WebApp
+	License: AGPLv3
+	Author: tobychui
+*/
+
+var (
+	listening = flag.String("l", ":8080", "The default endpoint for request listening")
+)
+
+//Safe shutdown sequence
+func shutdown() {
+
+	os.Exit(0)
+}
+
+//Close handler, close db and clearn up everything before exit
+func SetupCloseHandler() {
+	c := make(chan os.Signal, 2)
+	signal.Notify(c, os.Interrupt, syscall.SIGTERM)
+	go func() {
+		<-c
+		shutdown()
+	}()
+}
+
+//Main start functin
+func main() {
+	//Prase start up flags
+	flag.Parse()
+
+	//Setup Ctrl+C Listener
+	SetupCloseHandler()
+
+	//Start static file server
+	fs := http.FileServer(http.Dir("./web"))
+	http.Handle("/", fs)
+
+	//Register special HTTP requests handler
+
+	//Start WebServer
+	log.Println("Standard (HTTP) Web server listening at " + *listening)
+	http.ListenAndServe(*listening, nil)
+
+}

BIN
src/web/img/logo.png


BIN
src/web/img/logo.psd


BIN
src/web/img/pwa/192.png


BIN
src/web/img/pwa/192.psd


BIN
src/web/img/pwa/512.png


BIN
src/web/img/pwa/512.psd


BIN
src/web/img/small_logo.png


BIN
src/web/img/small_logo.psd


+ 37 - 0
src/web/index.html

@@ -0,0 +1,37 @@
+<html>
+    <head>
+        <title>台南吃貨</title>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+        <link rel="manifest" href="manifest.webmanifest">
+        <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
+        <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.8.8/dist/semantic.min.css">
+        <script src="https://cdn.jsdelivr.net/npm/fomantic-ui@2.8.8/dist/semantic.min.js"></script>
+        <style>
+            body{
+                background-color: #f55e61;
+            }
+        </style>
+    </head>
+    <body>
+        <!-- This page mostly act as a loader template -->
+        <div style="width: 100%; margin-top: calc(50vh - 8em);" align="center">
+            <img class="ui small image" src="img/logo.png">
+            <br><br>
+            <div class="ui active red centered inverted inline loader"></div>
+        </div>
+        <script>
+            //Check connection to server
+            //Just fake this part is ok :)
+
+            //OK! Redirect
+            setTimeout(function(){
+                $('body').transition('swing down', function(){
+                    setTimeout(function(){
+                        window.location.href = "selector.html";
+                    }, 300);
+                });
+            }, 1000)
+        </script>
+    </body>
+</html>

+ 34 - 0
src/web/main.html

@@ -0,0 +1,34 @@
+<html>
+    <head>
+        <title>台南吃貨</title>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+        <link rel="manifest" href="manifest.webmanifest">
+        <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
+        <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.8.8/dist/semantic.min.css">
+        <script src="https://cdn.jsdelivr.net/npm/fomantic-ui@2.8.8/dist/semantic.min.js"></script>
+        <style>
+            .themed.menu{
+                margin-top: 0px !important;
+                padding-top: 14px;
+                background-color: #f55e61 !important;
+                padding-right: 12px;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="ui text menu themed">
+            <a class="active item">
+              <img class="ui small image" src="img/small_logo.png">
+            </a>
+            <div class="right menu">
+                <a class="ui item">
+                    <button class="ui inverted basic icon button" style="border: 0px solid transparent !important; box-shadow: none !important;"><i class="bars icon"></i></button>
+                </a>
+            </div>
+        </div>
+        <script>
+            
+        </script>
+    </body>
+</html>

+ 18 - 0
src/web/manifest.webmanifest

@@ -0,0 +1,18 @@
+{
+    "name": "台南吃貨",
+    "short_name": "台南吃貨",
+    "start_url": "./index.html",
+    "display": "standalone",
+    "background_color": "#f55e60",
+    "description": "台南遊覽找餐廳時的最佳選擇",
+    "icons": [{
+        "src": "img/pwa/192.png",
+        "sizes": "192x192",
+        "type": "image/png" 
+    },
+    {
+        "src": "img/pwa/512.png",
+        "sizes": "512x512",
+        "type": "image/png"
+    }]
+}

+ 74 - 0
src/web/selector.html

@@ -0,0 +1,74 @@
+<html>
+    <head>
+        <title>台南吃貨</title>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+        <link rel="manifest" href="manifest.webmanifest">
+        <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
+        <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.8.8/dist/semantic.min.css">
+        <script src="https://cdn.jsdelivr.net/npm/fomantic-ui@2.8.8/dist/semantic.min.js"></script>
+        <style>
+             body{
+                background-color: #f55e61;
+            }
+
+            .footer{
+                margin-top: 8px;
+                position: fixed;
+                right: 0px;
+                bottom: 1em;
+            }
+            .footer a{
+                color: rgb(255, 255, 255) !important; 
+            }
+        </style>
+    </head>
+    <body>
+        <br>
+        <div class="ui container">
+            <div style="width: 100%;" align="center">
+                <img src="img/small_logo.png" class="ui small image">
+            </div>
+            <div class="ui divider" style="border-top: 1px solid white;"></div>
+            <a href="main.html">
+                <div class="ui raised segment">
+                    <br>
+                    <h2 class="ui icon header"  style="width: 100%;">
+                        <i class="search icon"></i>
+                        <div class="content">
+                            從景點找餐廳
+                            <div class="sub header">Search Restaurant from Point of Interest</div>
+                        </div>
+                    </h2>
+                    <br><br>
+                </div>
+            </a>
+            <br>
+            <a href="location.html">
+                <div class="ui raised segment">
+                    <br>
+                    <h2 class="ui icon header" style="width: 100%;">
+                        <i class="map marked icon"></i>
+                        <div class="content">
+                            推薦附近餐廳
+                            <div class="sub header">Recommend Nearyby Restaurant</div>
+                        </div>
+                    </h2>
+                    <br><br>
+                </div>
+            </a>
+        </div>
+        <div class="footer">
+            <div class="ui container" align="right">
+                <div class="ui breadcrumb">
+                    <a class="section">要求資料更正</a>
+                    <div class="divider"> / </div>
+                    <a class="section">版權資訊</a>
+                    <div class="divider"> / </div>
+                    <a class="section">聯系作者</a>
+                </div>
+            </div>
+          
+        </div>
+    </body>
+</html>