瀏覽代碼

added html

bmallred 9 年之前
父節點
當前提交
fabaa7c68a
共有 11 個文件被更改,包括 462 次插入6 次删除
  1. 21 2
      handlers/blog.go
  2. 11 2
      handlers/content.go
  3. 11 2
      handlers/default.go
  4. 12 0
      html/article.html
  5. 29 0
      html/blog.html
  6. 302 0
      html/default.html
  7. 14 0
      html/directory.html
  8. 29 0
      html/loop.html
  9. 二進制
      html/loop.png
  10. 30 0
      html/workspace.html
  11. 3 0
      main.go

+ 21 - 2
handlers/blog.go

@ -1,10 +1,29 @@
1 1
package handlers
2 2
3 3
import (
4
	"fmt"
4
	"html/template"
5 5
	"net/http"
6 6
)
7 7
8
var (
9
	templateBlog = template.Must(template.ParseFiles(
10
		"html/blog.html",
11
		"html/directory.html",
12
	))
13
	templateArticle = template.Must(template.ParseFiles(
14
		"html/blog.html",
15
		"html/article.html",
16
	))
17
)
18
8 19
func BlogHandler(w http.ResponseWriter, r *http.Request) {
9
	fmt.Fprintf(w, "Blog")
20
	if err := templateBlog.Execute(w, nil); err != nil {
21
		http.Error(w, err.Error(), http.StatusInternalServerError)
22
	}
23
}
24
25
func BlogArticleHandler(w http.ResponseWriter, r *http.Request) {
26
	if err := templateArticle.Execute(w, nil); err != nil {
27
		http.Error(w, err.Error(), http.StatusInternalServerError)
28
	}
10 29
}

+ 11 - 2
handlers/content.go

@ -1,10 +1,19 @@
1 1
package handlers
2 2
3 3
import (
4
	"fmt"
4
	"html/template"
5 5
	"net/http"
6 6
)
7 7
8
var (
9
	templateWorkspace = template.Must(template.ParseFiles(
10
		"html/loop.html",
11
		"html/workspace.html",
12
	))
13
)
14
8 15
func ContentHandler(w http.ResponseWriter, r *http.Request) {
9
	fmt.Fprintf(w, "Content")
16
	if err := templateWorkspace.Execute(w, nil); err != nil {
17
		http.Error(w, err.Error(), http.StatusInternalServerError)
18
	}
10 19
}

+ 11 - 2
handlers/default.go

@ -1,10 +1,19 @@
1 1
package handlers
2 2
3 3
import (
4
	"fmt"
4
	"html/template"
5 5
	"net/http"
6 6
)
7 7
8
var (
9
	templateLoop = template.Must(template.ParseFiles(
10
		"html/loop.html",
11
		"html/default.html",
12
	))
13
)
14
8 15
func DefaultHandler(w http.ResponseWriter, r *http.Request) {
9
	fmt.Fprintf(w, "Default")
16
	if err := templateLoop.Execute(w, nil); err != nil {
17
		http.Error(w, err.Error(), http.StatusInternalServerError)
18
	}
10 19
}

+ 12 - 0
html/article.html

@ -0,0 +1,12 @@
1
{{ define "title" }}{{ end }}
2
{{ define "style" }}{{ end }}
3
{{ define "content" }}
4
    <article>
5
        <h3>
6
            {{ .Title }}
7
            <small>{{ .Published }}</small>
8
        </h3>
9
        {{ .Body }}
10
    </article>
11
{{ end }}
12
{{ define "scripts" }}{{ end }}

+ 29 - 0
html/blog.html

@ -0,0 +1,29 @@
1
<!doctype html>
2
<html lang="en">
3
<head>
4
    <meta charset="utf-8">
5
    <meta http-equiv="X-UC-Compatible" content="IE=edge">
6
    <meta name="viewport" content="width=device-width, initial-scale=1">
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8
9
    <title>{{ template "title" . }}</title>
10
11
    <link rel="shortcut icon" type=image/png" href="">
12
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
13
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
14
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
15
    <link href="http://fonts.googleapis.com/css?family=Raleway:700,400" rel="stylesheet" type="text/css">
16
    {{ template "styles" . }}
17
18
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
19
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
20
    <!--[if lt IE 9]>
21
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
22
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
23
    <![endif]-->
24
</head>
25
<body>
26
    {{ template "content" . }}
27
    {{ template "scripts" . }}
28
</body>
29
</html>

+ 302 - 0
html/default.html

@ -0,0 +1,302 @@
1
{{ define "title" }}Loop{{ end }}
2
{{ define "styles" }}
3
    <style type="text/css">
4
        /* Parallax base styles
5
        --------------------------------------------- */
6
7
        .parallax {
8
            height: 500px; /* fallback for older browsers */
9
            height: 100vh;
10
            overflow-x: hidden;
11
            overflow-y: auto;
12
            -webkit-perspective: 300px;
13
                    perspective: 300px;
14
            -webkit-perspective-origin-x: 100%;
15
                    perspective-origin-x: 100%;
16
        }
17
18
        .parallax-group {
19
            position: relative;
20
            height: 500px; /* fallback for older browsers */
21
            height: 100vh;
22
            -webkit-transform-style: preserve-3d;
23
                    transform-style: preserve-3d;
24
        }
25
26
        .parallax-layer {
27
            position: absolute;
28
            top: 0;
29
            left: 0;
30
            right: 0;
31
            bottom: 0;
32
            -webkit-transform-origin-x: 100%;
33
                    transform-origin-x: 100%;
34
        }
35
36
        .parallax-layer-fore {
37
            -webkit-transform: translateZ(90px) scale(.7);
38
                    transform: translateZ(90px) scale(.7);
39
            z-index: 1;
40
        }
41
42
        .parallax-layer-base {
43
            -webkit-transform: translateZ(0);
44
                    transform: translateZ(0);
45
            z-index: 4;
46
        }
47
48
        .parallax-layer-back {
49
            -webkit-transform: translateZ(-300px) scale(2);
50
                    transform: translateZ(-300px) scale(2);
51
            z-index: 3;
52
        }
53
54
        .parallax-layer-deep {
55
            -webkit-transform: translateZ(-600px) scale(3);
56
                    transform: translateZ(-600px) scale(3);
57
            z-index: 2;
58
        }
59
60
        /* Debugger styles - used to show the effect
61
        --------------------------------------------- */
62
63
        .debug {
64
            position: fixed;
65
            bottom: 0;
66
            right: 0;
67
            z-index: 999;
68
            background: rgba(0,0,0,.85);
69
            color: #fff;
70
            padding: .5em;
71
            /*border-radius: 0 0 5px 5px;*/
72
        }
73
        .debug-on .parallax-group {
74
            -webkit-transform: translate3d(800px, 0, -800px) rotateY(30deg);
75
                    transform: translate3d(700px, 0, -800px) rotateY(30deg);
76
        }
77
        .debug-on .parallax-layer {
78
            box-shadow: 0 0 0 2px #000;
79
            opacity: 0.9;
80
        }
81
        .parallax-group {
82
            -webkit-transition: -webkit-transform 0.5s;
83
                    transition: transform 0.5s;
84
        }
85
86
        /* demo styles
87
        --------------------------------------------- */
88
89
        body, html {
90
            overflow: hidden;
91
        }
92
93
        body {
94
            font: 100% / 1.5 Arial;
95
        }
96
97
        * {
98
            margin:0;
99
            padding:0;
100
        }
101
102
        .parallax {
103
            font-size: 200%;
104
            background: rgb(255, 249, 242);
105
        }
106
107
        /* centre the content in the parallax layers */
108
        .title {
109
            text-align: center;
110
            position: absolute;
111
            left: 50%;
112
            top: 50%;
113
            -webkit-transform: translate(-50%, -50%);
114
                    transform: translate(-50%, -50%);
115
        }
116
117
        /* style the groups
118
        --------------------------------------------- */
119
120
        #group1 {
121
            z-index: 5; /* slide over group 2 */
122
        }
123
        #group1 .parallax-layer-base {
124
            background: rgb(255, 249, 242);
125
        }
126
127
        #group2 {
128
            z-index: 3; /* slide under groups 1 and 3 */
129
        }
130
        #group2 .parallax-layer-back {
131
            background: rgb(0, 0, 0);
132
            color: rgb(255, 249, 242);
133
        }
134
135
        #group3 {
136
            z-index: 4; /* slide over group 2 and 4 */
137
        }
138
        #group3 .parallax-layer-base {
139
            background: rgb(255, 249, 242);
140
        }
141
142
        #group4 {
143
            z-index: 2; /* slide under group 3 and 5 */
144
        }
145
        #group4 .parallax-layer-deep {
146
            background: rgb(184, 223, 101);
147
        }
148
149
        #group5 {
150
            z-index: 3; /* slide over group 4 and 6 */
151
        }
152
        #group5 .parallax-layer-base {
153
            background: rgb(214, 229, 100);
154
        }
155
156
        #group6 {
157
            z-index: 2; /* slide under group 5 and 7 */
158
        }
159
        #group6 .parallax-layer-back {
160
            background: rgb(245, 235, 100);
161
        }
162
163
        #group7 {
164
            z-index: 3; /* slide over group 7 */
165
        }
166
        #group7 .parallax-layer-base {
167
            background: rgb(255, 241, 100);
168
        }
169
170
171
        /* misc
172
        --------------------------------------------- */
173
        .demo__info {
174
            position: absolute;
175
            z-index:100;
176
            bottom: 1vh;
177
            top: auto;
178
            font-size:80%;
179
            text-align:center;
180
            width: 100%;
181
        }
182
183
        .fa {
184
            max-width: 55px;
185
        }
186
    </style>
187
{{end}}
188
{{ define "content" }}
189
    <div class="parallax">
190
        <div id="group1" class="parallax-group">
191
            <div class="parallax-layer parallax-layer-base">
192
                <div class="col-sm-6 text-center">
193
                    <img src="loop.png" alt="loop" class="img-responsive img-circle" style="display: inline;" />
194
                </div>
195
                <div class="col-sm-5" style="padding-top: 5em;">
196
                    <h1>Loop</h1>
197
                    <p>Shortening the feedback loop in business and life.</p>
198
199
                    <form action="" method="post" class="form form-horizontal">
200
                        <div class="form-group">
201
                            <div class="col-sm-6">
202
                                <input type="text" id="username" name="u" class="form-control" placeholder="Username" required autofocus />
203
                            </div>
204
                            <div class="col-sm-6">
205
                                <input type="password" id="password" name="p" class="form-control" placeholder="Password" required />
206
                            </div>
207
                        </div>
208
                        <div class="form-group">
209
                            <div class="col-sm-offset-8 col-sm-4">
210
                                <button class="btn btn-lg btn-primary btn-block" type="submit" title="Sign in">Sign in</button>
211
                            </div>
212
                        </div>
213
                    </form>
214
                </div>
215
                <div class="col-sm-1">&nbsp;</div>
216
            </div>
217
        </div>
218
        <div id="group2" class="parallax-group">
219
            <div class="parallax-layer parallax-layer-base">
220
            </div>
221
            <div class="parallax-layer parallax-layer-back">
222
                <div class="title">Features</div>
223
            </div>
224
        </div>
225
        <div id="group3" class="parallax-group">
226
            <div class="parallax-layer parallax-layer-base">
227
                <div class="container" style="padding-top: 5em;">
228
                    <div class="row">
229
                        <div class="col-sm-6">
230
                            <i class="pull-left fa fa-3x fa-cloud-download"></i>
231
                            <h3>Easy to install</h3>
232
                            <p>Compiled to a single binary deploying first-time installs and updates is incredibly simple.</p>
233
                        </div>
234
                        <div class="col-sm-6">
235
                            <i class="pull-left fa fa-3x fa-desktop"></i>
236
                            <h3>Cross-platform</h3>
237
                            <p>Loop runs everywhere! Just download the appropriate binary for one of the following platforms: Linux, Mac OS X, or Windows.</p>
238
                        </div>
239
                    </div>
240
                    <div class="row">
241
                        <div class="col-sm-6">
242
                            <i class="pull-left fa fa-3x fa-paper-plane"></i>
243
                            <h3>Lightweight</h3>
244
                            <p>No additional databases, dependencies on external resources, and on-demand processing keeps minimum requirements low.</p>
245
                        </div>
246
                        <div class="col-sm-6">
247
                            <i class="pull-left fa fa-3x fa-code"></i>
248
                            <h3>Open Source</h3>
249
                            <p>The project is licensed under the GPLv2 and can be tailored to suit your needs.</p>
250
                        </div>
251
                    </div>
252
                    <div class="row">
253
                        <div class="col-sm-6">
254
                            <i class="pull-left fa fa-3x fa-edit"></i>
255
                            <h3>Blogging</h3>
256
                            <p>Whether it is a simple note, todo list, or marketing for your business blogging is made simple by taking advantage of the simplicity of Markdown and ease of publishing.</p>
257
                        </div>
258
                        <div class="col-sm-6">
259
                            <i class="pull-left fa fa-3x fa-line-chart"></i>
260
                            <h3>Metrics</h3>
261
                            <p>Without understanding where you have started you cannot accurately gauge where you have gone. This is why metrics are stored with every action within the system.</p>
262
                        </div>
263
                    </div>
264
                    <div class="row">
265
                        <div class="col-sm-6">
266
                            <i class="pull-left fa fa-3x fa-credit-card"></i>
267
                            <h3>Payments</h3>
268
                            <p>Internal invoicing has never been so easy with built-in handling to Stripe.</p>
269
                        </div>
270
                        <div class="col-sm-6">
271
                            <i class="pull-left fa fa-3x fa-archive"></i>
272
                            <h3>Data storage</h3>
273
                            <p>Containers can store any file type making it simple to organize and store data privately in the cloud.</p>
274
                        </div>
275
                    </div>
276
                </div>
277
            </div>
278
            <div class="parallax-layer parallax-layer-back"></div>
279
        </div>
280
        <div id="group4" class="parallax-group">
281
            <div class="parallax-layer parallax-layer-base"></div>
282
            <div class="parallax-layer parallax-layer-deep">
283
            </div>
284
        </div>
285
    </div>
286
287
    <div class="debug">
288
        <label>
289
            <input id="debugToggle" type="checkbox" />Debug
290
        </label>
291
    </div>
292
{{ end }}
293
{{ define "scripts" }}
294
    <script type="text/javascript">
295
        var debugInput = document.getElementById("debugToggle");
296
        function updateDebugState() {
297
            document.body.classList.toggle('debug-on', debugInput.checked);
298
        }
299
        debugInput.addEventListener("click", updateDebugState);
300
        updateDebugState();
301
    </script>
302
{{ end }}

+ 14 - 0
html/directory.html

@ -0,0 +1,14 @@
1
{{ define "title" }}{{ end }}
2
{{ define "style" }}{{ end }}
3
{{ define "content" }}
4
    {{ range . }}
5
    <article>
6
        <h3>
7
            {{ .Title }}
8
            <small>{{ .Published }}</small>
9
        </h3>
10
        <p>{{ .Body }}</p>
11
    </article>
12
    {{ end }}
13
{{ end }}
14
{{ define "scripts" }}{{ end }}

+ 29 - 0
html/loop.html

@ -0,0 +1,29 @@
1
<!doctype html>
2
<html lang="en">
3
<head>
4
    <meta charset="utf-8">
5
    <meta http-equiv="X-UC-Compatible" content="IE=edge">
6
    <meta name="viewport" content="width=device-width, initial-scale=1">
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8
9
    <title>{{ template "title" . }}</title>
10
11
    <link rel="shortcut icon" type=image/png" href="">
12
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
13
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
14
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
15
    <link href="http://fonts.googleapis.com/css?family=Raleway:700,400" rel="stylesheet" type="text/css">
16
    {{ template "styles" . }}
17
18
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
19
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
20
    <!--[if lt IE 9]>
21
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
22
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
23
    <![endif]-->
24
</head>
25
<body>
26
    {{ template "content" . }}
27
    {{ templates "scripts" . }}
28
</body>
29
</html>

二進制
html/loop.png


+ 30 - 0
html/workspace.html

@ -0,0 +1,30 @@
1
{{ define "title" }}Workspace{{ end }}
2
{{ define "style" }}{{ end }}
3
{{ define "content" }}
4
    <div class="row">
5
        <div class="col-sm-12">
6
            <!-- Toolbar of stuffs -->
7
        </div>
8
    </div>
9
    <div class="row">
10
        <div class="col-sm-4">
11
            <!-- Directory of stuffs -->
12
        </div>
13
        <div class="col-sm-8">
14
            <!-- Editor and main content -->
15
            <pre id="editor"></pre>
16
        </div>
17
    </div>
18
{{ end }}
19
{{ define "scripts" }}
20
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.8/ace.js"></script>
21
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.8/theme-chrome.js"></script>
22
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.8/mode-markdown.js"></script>
23
    <script type="text/javascript">
24
        (function () {
25
            var editor = ace.edit('editor');
26
            editor.setTheme('ace/theme/chrome');
27
            editor.getSession().setMode('ace/mode/markdown');
28
        })();
29
    </script>
30
{{ end }}

+ 3 - 0
main.go

@ -24,6 +24,9 @@ func main() {
24 24
	content := r.PathPrefix("/{username}/content").Subrouter()
25 25
	content.Methods("GET").HandlerFunc(handlers.ContentHandler)
26 26
27
	article := r.PathPrefix("/{username}/blog/{article}").Subrouter()
28
	article.Methods("GET").HandlerFunc(handlers.BlogArticleHandler)
29
27 30
	blog := r.PathPrefix("/{username}/blog").Subrouter()
28 31
	blog.Methods("GET").HandlerFunc(handlers.BlogHandler)
29 32