-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
781 lines (460 loc) · 21.7 KB
/
Copy pathindex.html
File metadata and controls
781 lines (460 loc) · 21.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
<!DOCTYPE html>
<html class="no-js">
<head lang="en-us">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1">
<title>Blue Jay | Go Toolkit for the Web</title>
<meta name="generator" content="Hugo 0.15" />
<meta name="description" content="Blue Jay is a toolkit written in Go for the web.">
<link rel="canonical" href="https://blue-jay.github.io/">
<meta name="author" content="Joseph Spurrier">
<meta property="og:url" content="https://blue-jay.github.io/">
<meta property="og:title" content="Blue Jay | Go Toolkit for the Web">
<meta property="og:image" content="https://blue-jay.github.io/images/bluejaylogo.png">
<meta name="apple-mobile-web-app-title" content="Blue Jay | Go Toolkit for the Web">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="shortcut icon" type="image/x-icon" href="https://blue-jay.github.io/images/favicon.ico">
<link rel="icon" type="image/x-icon" href="https://blue-jay.github.io/images/favicon.ico">
<style>
@font-face {
font-family: 'Icon';
src: url('https://blue-jay.github.io/fonts/icon.eot?52m981');
src: url('https://blue-jay.github.io/fonts/icon.eot?#iefix52m981')
format('embedded-opentype'),
url('https://blue-jay.github.io/fonts/icon.woff?52m981')
format('woff'),
url('https://blue-jay.github.io/fonts/icon.ttf?52m981')
format('truetype'),
url('https://blue-jay.github.io/fonts/icon.svg?52m981#icon')
format('svg');
font-weight: normal;
font-style: normal;
}
</style>
<link rel="stylesheet" href="https://blue-jay.github.io/stylesheets/application.css">
<link rel="stylesheet" href="https://blue-jay.github.io/stylesheets/palettes.css">
<link rel="stylesheet" href="https://blue-jay.github.io/stylesheets/highlight/highlight.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Ubuntu:400,700|Ubuntu%2bMono">
<style>
body, input {
font-family: 'Ubuntu', Helvetica, Arial, sans-serif;
}
pre, code {
font-family: 'Ubuntu Mono', 'Courier New', 'Courier', monospace;
}
</style>
<link rel="stylesheet" href="https://blue-jay.github.io/stylesheets/global.css">
<link rel="stylesheet" href="https://blue-jay.github.io/stylesheets/colors.css">
<script src="https://blue-jay.github.io/javascripts/modernizr.js"></script>
<link href="https://blue-jay.github.io/index.xml" rel="alternate" type="application/rss+xml" title="Blue Jay | Go Toolkit for the Web" />
<link href="https://blue-jay.github.io/index.xml" rel="feed" type="application/rss+xml" title="Blue Jay | Go Toolkit for the Web" />
</head>
<body class="palette-primary-jayblue palette-accent-amber">
<div class="backdrop">
<div class="backdrop-paper"></div>
</div>
<input class="toggle" type="checkbox" id="toggle-drawer">
<input class="toggle" type="checkbox" id="toggle-search">
<label class="toggle-button overlay" for="toggle-drawer"></label>
<header class="header">
<nav aria-label="Header">
<div class="bar default">
<div class="button button-menu" role="button" aria-label="Menu">
<label class="toggle-button icon icon-menu" for="toggle-drawer">
<span></span>
</label>
</div>
<div class="stretch">
<div class="title">
Blue Jay | Go Toolkit for the Web
</div>
</div>
<div class="button button-github" role="button" aria-label="GitHub">
<a href="https://github.com/blue-jay" title="@blue-jay on GitHub" target="_blank" class="toggle-button icon icon-github"></a>
</div>
</div>
<div class="bar search">
<div class="button button-close" role="button" aria-label="Close">
<label class="toggle-button icon icon-back" for="toggle-search"></label>
</div>
<div class="stretch">
<div class="field">
<input class="query" type="text" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck>
</div>
</div>
<div class="button button-reset" role="button" aria-label="Search">
<button class="toggle-button icon icon-close" id="reset-search"></button>
</div>
</div>
</nav>
</header>
<main class="main">
<div class="drawer">
<nav aria-label="Navigation">
<a href="https://github.com/blue-jay/blueprint" class="project">
<div class="banner">
<div class="logo">
<img src="https://blue-jay.github.io/images/bluejaylogo.png">
</div>
<div class="name">
<br><strong>blue-jay/blueprint</strong>
<br><span class="version">0.8-delta</span>
</div>
</div>
</a>
<div class="scrollable">
<div class="wrapper">
<ul class="repo">
<li class="repo-download">
<a href="https://github.com/blue-jay/blueprint" target="_blank" title="View Github">
<i class="icon icon-github"></i> GitHub
</a>
</li>
<li class="repo-stars">
<a href="https://github.com/blue-jay/blueprint/stargazers" target="_blank" title="Stargazers" data-action="star">
<i class="icon icon-star"></i> Stars
<span class="count">–</span>
</a>
</li>
</ul>
<hr>
<div class="toc">
<ul>
<li>
<a class="current" title="Blue Jay Overview" href="https://blue-jay.github.io/">
Blue Jay Overview
</a>
<ul id="scrollspy">
</ul>
</li>
<li>
<a title="Structure" href="https://blue-jay.github.io/structure/">
Structure
</a>
</li>
<li>
<a title="Configuration" href="https://blue-jay.github.io/configuration/">
Configuration
</a>
</li>
<li>
<a title="Assets" href="https://blue-jay.github.io/assets/">
Assets
</a>
</li>
<li>
<a title="Routing" href="https://blue-jay.github.io/routing/">
Routing
</a>
</li>
<li>
<a title="Middleware" href="https://blue-jay.github.io/middleware/">
Middleware
</a>
</li>
<li>
<a title="Controllers" href="https://blue-jay.github.io/controllers/">
Controllers
</a>
</li>
<li>
<a title="Models" href="https://blue-jay.github.io/models/">
Models
</a>
</li>
<li>
<a title="Views" href="https://blue-jay.github.io/views/">
Views
</a>
</li>
<li>
<a title="Library" href="https://blue-jay.github.io/library/">
Library
</a>
</li>
<li>
<a title="Jay Overview" href="https://blue-jay.github.io/jay/">
Jay Overview
</a>
</li>
<li>
<a title="Find and Replace" href="https://blue-jay.github.io/find-replace/">
Find and Replace
</a>
</li>
<li>
<a title="Database Migration" href="https://blue-jay.github.io/database-migration/">
Database Migration
</a>
</li>
<li>
<a title="Code Generation" href="https://blue-jay.github.io/generation/">
Code Generation
</a>
</li>
</ul>
<hr>
<span class="section">The author</span>
<ul>
<li>
<a href="https://github.com/blue-jay" target="_blank" title="@blue-jay on GitHub">
@blue-jay on GitHub
</a>
</li>
</ul>
</div>
</div>
</div>
</nav>
</div>
<article class="article">
<div class="wrapper">
<h1>Blue Jay Overview </h1>
<p>Blue Jay is a web toolkit for <a href="https://golang.org/">Go</a>. It’s a collection of command-line tools and a web blueprint that allows you to easily structure your web application. There is no rigid framework to which you have to conform and the tools are easy to start using.</p>
<p>There are a few components:</p>
<ul>
<li><a href="https://github.com/blue-jay/blueprint"><strong>Blueprint</strong></a> is a model-view-controller (MVC) style web skeleton.</li>
<li><a href="https://github.com/blue-jay/jay"><strong>Jay</strong></a> is a command line tool with find/replace, database migrations, and code generation.</li>
<li><a href="https://github.com/blue-jay/core"><strong>Core</strong></a> is a collection of packages used
by Blueprint and Jay that can also be used by other projects.</li>
</ul>
<h2 id="high-level">High Level</h2>
<p>Blueprint is a web application with a built-in web server and MySQL integration.
The application has a public home page, authenticated home page, login page,
register page, about page, and a simple notepad to demonstrate GET, POST,
PATCH, and DELETE operations.</p>
<p>The entrypoint for the web app is <strong>blueprint.go</strong> which uses the <strong>boot</strong>
package to load the application settings, create the session store,
connect to the database, set up the views, load the routes, attach the
middleware, and then start the web server.</p>
<p>The front end is built using <a href="http://getbootstrap.com/">Bootstrap</a> with a few
small changes to fonts and
spacing. The flash messages are customized so they show up at the bottom right
corner of the screen. All of the error and warning messages should display to
the user or in the console. Informational messages are displayed to the user
via flash messages that disappear after 4 seconds.</p>
<p>Blueprint also works well with <a href="https://www.npmjs.com/">npm</a> and
<a href="http://gulpjs.com/">Gulp</a>. A Gulp script is
included that automates the compiling of SASS, concatenation of JavaScript,
generation of favicons, and copying of static assets like Bootstrap and jQuery
(which are managed by npm) to the <strong>asset/static</strong> folder.</p>
<p>Jay is a command-line tool that pairs nicely with Blueprint. It has find/replace
functionality to make code refactoring a little easier. It performs database
migration to easily update your database when sharing code
between teams. Jay provides template-based code generation that allows you to
build files like controllers, models, middleware, or even multiple views.
All templates (*.gen files) are parsed using
the <strong>text/template</strong> package from the Go standard library and all generation
instructions (*.json files) allow you to specify which variables to pass via
<strong>Jay</strong> as well as in which folder to create the templates. You can also build
collections of templates to generate more than one file set which is great when
you want to scaffold out a component with CRUD (create, read, update, and delete).</p>
<h2 id="quick-start-website-with-jay">Quick Start Website with Jay</h2>
<ol>
<li>To download Blueprint, run the following command: <code>go get github.com/blue-jay/blueprint</code></li>
<li>To download Jay, run the following command: <code>go get github.com/blue-jay/jay</code></li>
<li>In your terminal, CD to the <strong>blueprint</strong> folder.</li>
<li>Run this command to create the env.json file from env.json.example: <code>jay env make</code></li>
<li>Set the environment variable, JAYCONFIG, to the env.json file path. For example:
<ul>
<li>On Windows: <code>SET JAYCONFIG=C:\bluejay\workspace\src\github.com\blue-jay\blueprint\env.json</code></li>
<li>On Linux/OS X: <code>export JAYCONFIG=$HOME/workspace/src/github.com/blue-jay/blueprint/env.json</code></li>
</ul></li>
<li>Start a MySQL instance.</li>
<li>Edit the <strong>MySQL</strong> section of env.json to match your database login information.</li>
<li>Create the database and tables using the command: <code>jay migrate:mysql all</code></li>
<li>Run the application: <code>go run blueprint.go</code></li>
<li>Open your web browser to <a href="http://localhost">http://localhost</a> and you should see the welcome page.</li>
<li>Navigate to the register page at <a href="http://localhost/register">http://localhost/register</a> and create a new user.</li>
<li>You can now login at <a href="http://localhost/login">http://localhost/login</a>.</li>
</ol>
<h3 id="os-specific-instructions">OS Specific Instructions</h3>
<p>There are also more detailed guides available by operating system:</p>
<ul>
<li><a href="https://github.com/blue-jay/blueprint/wiki/Blueprint-Setup-for-Amazon-AMI">Setup for Amazon AMI</a></li>
<li><a href="https://github.com/blue-jay/blueprint/wiki/Blueprint-Setup-for-Ubuntu-AMI">Setup for Ubuntu AMI</a></li>
<li><a href="https://github.com/blue-jay/blueprint/wiki/Blueprint-Setup-for-OS-X">Setup for OS X</a></li>
<li><a href="https://github.com/blue-jay/blueprint/wiki/Blueprint-Setup-for-Windows">Setup for Windows</a></li>
</ul>
<h2 id="quick-start-website-without-jay">Quick Start Website without Jay</h2>
<ol>
<li>To download Blueprint, run the following command: <code>go get github.com/blue-jay/blueprint</code></li>
<li>Start a MySQL instance.</li>
<li>Make a copy of env.json.example and name it: <strong>env.json</strong></li>
<li>Edit the <strong>MySQL</strong> section in <strong>env.json</strong> so the connection information matches your MySQL instance.</li>
<li>In the <strong>Session</strong> section, you should generate new passwords for the following keys:
<ul>
<li>AuthKey should be a 64 byte password and then base64 encoded</li>
<li>EncryptKey should be a 32 byte password and then base64 encoded</li>
<li>CSRFKey should be a 32 byte password and then base64 encoded</li>
</ul></li>
<li>Create a database called <strong>blueprint</strong> in MySQL.</li>
<li>Import <strong>migration/mysql/20160630_020000.000000_init.up.sql</strong> to create the tables.</li>
<li>In your terminal, CD to the <strong>blueprint</strong> folder.</li>
<li>Run the application using the command: <code>go run blueprint.go</code></li>
<li>Open your web browser to <a href="http://localhost">http://localhost</a> and you should see the welcome page.</li>
<li>Navigate to the register page at <a href="http://localhost/register">http://localhost/register</a> and create a new user.</li>
<li>You can now login at <a href="http://localhost/login">http://localhost/login</a>.</li>
</ol>
<h2 id="why-blue-jay">Why Blue Jay?</h2>
<p>After 300 stars on GitHub, I realized people really liked the boilerplate
Model-View-Controller (MVC) web application in Go called
<a href="https://github.com/josephspurrier/gowebapp">gowebapp</a> so I rewrote it with
better documentation.</p>
<p>Go is a blast to code in and it’s great being part of a helpful community.
Blue Jay provides a quickstart for developers with a lean web skeleton called
<strong>Blueprint</strong> that demonstrates how to structure a web application with sample
code.</p>
<p>One of the things you’ll notice while using Blueprint is how to abstract out
external packages to make it easy to swap out components. Ultimately, you should
be able to write code once and use it in all of your other projects. The <strong>lib</strong>
folder is a great place for all these packages with very few dependencies.</p>
<p>You’ll also notice certain packages need to be thread-safe when building web applications.
An example is the <strong>github.com/core/view</strong> package which provides thread-safe template caching.</p>
<p>The other reason for Blue Jay is the command-line tool, <strong>jay</strong>, which provides an easy way
to find/replace in a project when refactoring, migrate your database forwards or backwards, and
generate a file or sets or files using the Go <a href="https://golang.org/pkg/html/template/">html/template</a>
package. Code generation can help you build faster and more efficiently with less mistakes.</p>
<h2 id="why-go">Why Go?</h2>
<p>One of the big draws to Go is the rich standard library. The standard library includes a web server,
web-safe templating, and
many other tools necessary to build a web application. Any features missing from the standard library are
written by other Go developers who are happy to contribute to the thriving community.</p>
<p>Go allows you to write code that compiles to the majority of the architectures we use today so all your
code is pretty much portable. Go excels when you want to write command line apps instead of just scripts,
but that’s not the only niche.
The designers of Go wanted to build a language that solved problems between the Google development teams.
It’s a modern language that allows you to easily multi-thread your applications. It’s a “get stuff done”
language.</p>
<h2 id="screenshots">Screenshots</h2>
<h3 id="public-home">Public Home</h3>
<p><img src="https://blue-jay.github.io/images/home_anon.png" alt="Image of Public Home" /></p>
<h3 id="about">About</h3>
<p><img src="https://blue-jay.github.io/images/about.png" alt="Image of About" /></p>
<h3 id="register">Register</h3>
<p><img src="https://blue-jay.github.io/images/register.png" alt="Image of Register" /></p>
<h3 id="login">Login</h3>
<p><img src="https://blue-jay.github.io/images/login.png" alt="Image of Login" /></p>
<h3 id="authenticated-home">Authenticated Home</h3>
<p><img src="https://blue-jay.github.io/images/home_auth.png" alt="Image of Auth Home" /></p>
<h3 id="view-all-notes">View All Notes</h3>
<p><img src="https://blue-jay.github.io/images/notepad_index.png" alt="Image of Notepad View" /></p>
<h3 id="add-note">Add Note</h3>
<p><img src="https://blue-jay.github.io/images/notepad_create.png" alt="Image of Notepad Add" /></p>
<h3 id="view-one-note">View One Note</h3>
<p><img src="https://blue-jay.github.io/images/notepad_view.png" alt="Image of Notepad Edit" /></p>
<h3 id="edit-note">Edit Note</h3>
<p><img src="https://blue-jay.github.io/images/notepad_edit.png" alt="Image of Notepad Edit" /></p>
<h2 id="feedback">Feedback</h2>
<p>All feedback is welcome. Let me know if you have any suggestions, questions, or criticisms.
If something is not idiomatic to Go, please let me know know so we can make it better.</p>
<aside class="copyright" role="note">
© 2017 Released under the MIT license –
Documentation built with
<a href="https://www.gohugo.io" target="_blank">Hugo</a>
using the
<a href="http://github.com/digitalcraftsman/hugo-material-docs" target="_blank">
Material
</a> theme.
</aside>
<footer class="footer">
<nav class="pagination" aria-label="Footer">
<div class="previous">
</div>
<div class="next">
<a href="https://blue-jay.github.io/structure/" title="Structure">
<span class="direction">
Next
</span>
<div class="page">
<div class="stretch">
<div class="title">
Structure
</div>
</div>
<div class="button button-next" role="button" aria-label="Next">
<i class="icon icon-forward"></i>
</div>
</div>
</a>
</div>
</nav>
</footer>
</div>
</article>
<div class="results" role="status" aria-live="polite">
<div class="scrollable">
<div class="wrapper">
<div class="meta"></div>
<div class="list"></div>
</div>
</div>
</div>
</main>
<script>
var base_url = 'https:\/\/blue-jay.github.io\/';
var repo_id = 'blue-jay\/blueprint';
</script>
<script src="https://blue-jay.github.io/javascripts/application.js"></script>
<script>
/* Add headers to scrollspy */
var headers = document.getElementsByTagName("h2");
var scrollspy = document.getElementById('scrollspy');
if(headers.length > 0) {
for(var i = 0; i < headers.length; i++) {
var li = document.createElement("li");
li.setAttribute("class", "anchor");
var a = document.createElement("a");
a.setAttribute("href", "#" + headers[i].id);
a.setAttribute("title", headers[i].innerHTML);
a.innerHTML = headers[i].innerHTML;
li.appendChild(a)
scrollspy.appendChild(li);
}
} else {
scrollspy.parentElement.removeChild(scrollspy)
}
/* Add permanent link next to the headers */
var headers = document.querySelectorAll("h1, h2, h3, h4, h5, h6");
for(var i = 0; i < headers.length; i++) {
var a = document.createElement("a");
a.setAttribute("class", "headerlink");
a.setAttribute("href", "#" + headers[i].id);
a.setAttribute("title", "Permanent link")
a.innerHTML = "#";
headers[i].appendChild(a);
}
</script>
<script>
(function(i,s,o,g,r,a,m){
i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||
[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;
m.parentNode.insertBefore(a,m)
})(window, document,
'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-80295457-1', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
var buttons = document.querySelectorAll('a');
Array.prototype.map.call(buttons, function(item) {
if (item.host != document.location.host) {
item.addEventListener('click', function() {
var action = item.getAttribute('data-action') || 'follow';
ga('send', 'event', 'outbound', action, item.href);
});
}
});
var query = document.querySelector('.query');
query.addEventListener('blur', function() {
if (this.value) {
var path = document.location.pathname;
ga('send', 'pageview', path + '?q=' + this.value);
}
});
</script>
<script src="//gohugo.io/js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>