Compare commits
No commits in common. 'drew/lets-go' and 'main' have entirely different histories.
drew/lets-
...
main
@ -1,52 +0,0 @@
|
||||
root = "."
|
||||
testdata_dir = "testdata"
|
||||
tmp_dir = "tmp"
|
||||
|
||||
[build]
|
||||
args_bin = []
|
||||
bin = "./tmp/main"
|
||||
cmd = "go build -o ./tmp/main cmd/ratchetd/main.go"
|
||||
delay = 1000
|
||||
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
|
||||
exclude_file = []
|
||||
exclude_regex = ["_test.go"]
|
||||
exclude_unchanged = false
|
||||
follow_symlink = false
|
||||
full_bin = ""
|
||||
include_dir = []
|
||||
include_ext = ["go", "tpl", "tmpl", "html", "go.tmpl"]
|
||||
include_file = []
|
||||
kill_delay = "0s"
|
||||
log = "build-errors.log"
|
||||
poll = false
|
||||
poll_interval = 0
|
||||
post_cmd = []
|
||||
pre_cmd = []
|
||||
rerun = false
|
||||
rerun_delay = 500
|
||||
send_interrupt = false
|
||||
stop_on_error = false
|
||||
|
||||
[color]
|
||||
app = ""
|
||||
build = "yellow"
|
||||
main = "magenta"
|
||||
runner = "green"
|
||||
watcher = "cyan"
|
||||
|
||||
[log]
|
||||
main_only = false
|
||||
silent = false
|
||||
time = false
|
||||
|
||||
[misc]
|
||||
clean_on_exit = false
|
||||
|
||||
[proxy]
|
||||
app_port = 0
|
||||
enabled = false
|
||||
proxy_port = 0
|
||||
|
||||
[screen]
|
||||
clear_on_rebuild = false
|
||||
keep_scroll = true
|
@ -1,31 +1,7 @@
|
||||
SQL_DATABASE?=./ratchet.db
|
||||
|
||||
test:
|
||||
go test -v ./...
|
||||
PHONEY: test
|
||||
|
||||
serve:
|
||||
go run ./cmd/ratchetd/main.go
|
||||
PHONEY: serve
|
||||
|
||||
|
||||
# SQLite Commands
|
||||
|
||||
sql-cli:
|
||||
sqlite3 $(SQL_DATABASE) -cmd ".headers on" -cmd ".mode column" -cmd ".tables"
|
||||
|
||||
init-db: run-migrate
|
||||
sqlite3 $(SQL_DATABASE) "PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;"
|
||||
|
||||
seed-db:
|
||||
sqlite3 $(SQL_DATABASE) "INSERT INTO snippets (title, content, expires_at) VALUES ('placeholder', 'placeholder content', datetime('now', '+6 months'));"
|
||||
|
||||
run-migrate:
|
||||
migrate -database sqlite3://$(SQL_DATABASE) -path ./migrations up
|
||||
|
||||
# Checks system dependencies needed to run the local dev environment
|
||||
check-system-deps:
|
||||
@echo "Checking system dependencies..."
|
||||
@command -v sqlite3 > /dev/null || (echo "Missing sqlite3 command. brew install sqlite"; exit 1)
|
||||
@command -v migrate > /dev/null || (echo "Missing migrate command. go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest"; exit 1)
|
||||
@echo "System dependencies fulfilled 👍"
|
||||
PHONEY: serve
|
@ -1,48 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.runcible.io/learning/ratchet/internal/logging"
|
||||
"git.runcible.io/learning/ratchet/internal/server"
|
||||
// "git.runcible.io/learning/ratchet"
|
||||
// ratchethttp "git.runcible.io/learning/ratchet/internal"
|
||||
"git.runcible.io/learning/ratchet"
|
||||
)
|
||||
|
||||
// var (
|
||||
// version string
|
||||
// commit string
|
||||
// )
|
||||
var (
|
||||
version string
|
||||
commit string
|
||||
)
|
||||
|
||||
func main() {
|
||||
// CONFIGURATION
|
||||
// Parse command line options
|
||||
addr := flag.String("addr", "0.0.0.0", "HTTP network address")
|
||||
port := flag.String("port", "5001", "HTTP port")
|
||||
logLevel := flag.String("logging", "INFO", "Logging Level. Valid values [INFO, DEBUG, WARN, ERROR].")
|
||||
// must call parse or all values will be the defaults
|
||||
flag.Parse()
|
||||
|
||||
// DEPENDENCY INJECTION FOR HANDLERS
|
||||
// Setup Logging
|
||||
logger := logging.InitLogging(*logLevel)
|
||||
|
||||
// Propagate build information to root package to share globally
|
||||
// ratchet.Version = strings.TrimPrefix(version, "")
|
||||
// ratchet.Commit = commit
|
||||
server := server.NewRatchetServer(logger)
|
||||
|
||||
// START SERVING REQUESTS
|
||||
slog.Debug("Herp dirp!")
|
||||
slog.Info(fmt.Sprintf("Listening on http://%s:%s", *addr, *port))
|
||||
//log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%s", *addr, *port), server))
|
||||
// there is no log.Fatal equivalent. This is an approximation of the behavior
|
||||
err := http.ListenAndServe(fmt.Sprintf("%s:%s", *addr, *port), server)
|
||||
slog.Error(err.Error())
|
||||
os.Exit(1)
|
||||
|
||||
ratchet.Version = strings.TrimPrefix(version, "")
|
||||
ratchet.Commit = commit
|
||||
fmt.Fprintf(os.Stdout, "Version: %s\nCommit: %s\n", ratchet.Version, ratchet.Commit)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package apperror
|
||||
package ratchet
|
||||
|
||||
import (
|
||||
"errors"
|
@ -1,4 +1,4 @@
|
||||
package apperror
|
||||
package ratchet
|
||||
|
||||
import (
|
||||
"errors"
|
@ -1,2 +0,0 @@
|
||||
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
|
||||
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
@ -1,36 +0,0 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func parseLogLevel(levelStr string) slog.Level {
|
||||
switch strings.ToUpper(levelStr) {
|
||||
case "DEBUG":
|
||||
return slog.LevelDebug
|
||||
case "INFO":
|
||||
return slog.LevelInfo
|
||||
case "WARN":
|
||||
return slog.LevelWarn
|
||||
case "ERROR":
|
||||
return slog.LevelError
|
||||
default:
|
||||
return slog.LevelInfo // Default level
|
||||
}
|
||||
}
|
||||
|
||||
// InitLogggin initializes global structured logging for the entire application
|
||||
func InitLogging(level string) *slog.Logger {
|
||||
// Use os.Stderr
|
||||
//
|
||||
// Stderr is used for diagnostics and logging. Stdout is used for program
|
||||
// output. Stderr also have greater likely hood of being seen if a programs
|
||||
// output is being redirected.
|
||||
parsedLogLevel := parseLogLevel(level)
|
||||
loggerHandler := slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{Level: parsedLogLevel, AddSource: true})
|
||||
logger := slog.New(loggerHandler)
|
||||
slog.SetDefault(logger)
|
||||
return logger
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"git.runcible.io/learning/ratchet/internal/domain/user"
|
||||
)
|
||||
|
||||
type RatchetServer struct {
|
||||
http.Handler
|
||||
|
||||
logger *slog.Logger
|
||||
//Services used by HTTP routes
|
||||
UserService user.UserService
|
||||
}
|
||||
|
||||
func NewRatchetServer(logger *slog.Logger) *RatchetServer {
|
||||
rs := new(RatchetServer)
|
||||
rs.logger = logger
|
||||
// TODO implement middleware that disables directory listings
|
||||
fileServer := http.FileServer(http.Dir("./ui/static/"))
|
||||
router := http.NewServeMux()
|
||||
|
||||
// Subtree pattern for static assets
|
||||
router.Handle("GET /static/", http.StripPrefix("/static/", fileServer))
|
||||
|
||||
// /{$} is used to prevent subtree path patterns from acting like a wildcard
|
||||
// resulting in this route requiring an exact match on "/" only
|
||||
// You can only include one HTTP method in a route pattern if you choose
|
||||
// GET will match GET & HEAD http request methods
|
||||
router.HandleFunc("GET /{$}", rs.home)
|
||||
router.HandleFunc("GET /snippet/view/{id}", rs.snippetView)
|
||||
router.HandleFunc("GET /snippet/create", rs.snippetCreate)
|
||||
|
||||
// FYI The http.HandlerFunc() adapter works by automatically adding a ServeHTTP() method to
|
||||
// the passed function
|
||||
router.HandleFunc("POST /snippet/create", rs.snippetCreatePost)
|
||||
|
||||
// Mux Router implements the Handler interface. AKA it has a ServeHTTP receiver.
|
||||
rs.Handler = router
|
||||
return rs
|
||||
}
|
||||
|
||||
func (rs *RatchetServer) home(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO middleware should be able to print out these lines for all routes
|
||||
rs.logger.Info("request received", "method", "GET", "path", "/")
|
||||
|
||||
w.Header().Add("Server", "Go")
|
||||
|
||||
// Initialize a slice containing the paths to the two files. It's important
|
||||
// to note that the file containing our base template must be the *first*
|
||||
// file in the slice.
|
||||
files := []string{
|
||||
"./ui/html/base.go.tmpl",
|
||||
"./ui/html/partials/nav.go.tmpl",
|
||||
"./ui/html/pages/home.go.tmpl",
|
||||
}
|
||||
|
||||
// read template file into template set.
|
||||
ts, err := template.ParseFiles(files...)
|
||||
if err != nil {
|
||||
rs.serverError(w, r, err)
|
||||
return
|
||||
}
|
||||
// Write template content to response body
|
||||
err = ts.ExecuteTemplate(w, "base", nil)
|
||||
if err != nil {
|
||||
// This is the older more verbose way of doing what RatchetServer.serverError does
|
||||
// rs.logger.Error(err.Error())
|
||||
// http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||
rs.serverError(w, r, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (rs *RatchetServer) snippetView(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
id, err := strconv.Atoi(r.PathValue("id"))
|
||||
if err != nil || id < 1 {
|
||||
// http.NotFound(w, r)
|
||||
rs.clientError(w, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
// Set a new cache-control header. If an existing "Cache-Control" header exists
|
||||
// it will be overwritten.
|
||||
w.Header().Set("Cache-Control", "public, max-age=31536000")
|
||||
|
||||
// msg := fmt.Sprintf("Snippet %d...", id)
|
||||
|
||||
// w.Write([]byte(msg))
|
||||
|
||||
// we can rely on the Write() interface to use a differnent
|
||||
// function to write out our response
|
||||
|
||||
fmt.Fprintf(w, "Snippet %d...", id)
|
||||
}
|
||||
|
||||
// snippetCreate handles display of the form used to create snippets
|
||||
func (rs *RatchetServer) snippetCreate(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("Displaying snippetCreate form..."))
|
||||
}
|
||||
|
||||
// snippetCreate handles display of the form used to create snippets
|
||||
func (rs *RatchetServer) snippetCreatePost(w http.ResponseWriter, r *http.Request) {
|
||||
// example of a custom header. Must be done before calling WriteHeader
|
||||
// or they will fail to take effect.
|
||||
w.Header().Add("Server", "Dirp")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
|
||||
w.Write([]byte("Created snippet..."))
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
// serverError helper writes a log entry at Error level (including the request
|
||||
// method and URI as attributes), then sends a generic 500 Internal Server Error
|
||||
// response to the user.
|
||||
func (rs *RatchetServer) serverError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
var (
|
||||
method = r.Method
|
||||
uri = r.URL.RequestURI()
|
||||
// Use debug.Stack() to get the stack trace. This returns a byte slice, which
|
||||
// we need to convert to a string so that it's readable in the log entry.
|
||||
trace = string(debug.Stack())
|
||||
)
|
||||
|
||||
rs.logger.Error(err.Error(), "method", method, "uri", uri, "trace", trace)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
// clientError helper sends a specific status code and corresponding description
|
||||
// to the user. We'll use this later in the book to send responses like 400 "Bad
|
||||
// Request" when there's a problem with the request that the user sent
|
||||
func (rs *RatchetServer) clientError(w http.ResponseWriter, status int) {
|
||||
http.Error(w, http.StatusText(status), status)
|
||||
}
|
@ -1 +0,0 @@
|
||||
DROP TABLE IF EXISTS snippets;
|
@ -1,20 +0,0 @@
|
||||
PRAGMA foreign_keys=1;
|
||||
CREATE TABLE snippets (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
expires_at DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- Add an index on the created column.
|
||||
CREATE INDEX idx_snippets_created ON snippets(created_at);
|
||||
|
||||
-- Add a trigger to keep timestamp updated.
|
||||
CREATE TRIGGER snippet_update_timestamp
|
||||
AFTER UPDATE ON snippets
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE snippets SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
|
||||
END;
|
@ -1,24 +0,0 @@
|
||||
{{define "base" -}}
|
||||
<!doctype html>
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>{{template "title" .}}</title>
|
||||
<link rel='stylesheet' href='/static/css/main.css'>
|
||||
<link rel='shortcut icon' href='/static/img/favicon.ico' type='image/x-icon'>
|
||||
<!-- Also link to some fonts hosted by Google -->
|
||||
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700'>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1><a href='/'>Ratchet</a></h1>
|
||||
</header>
|
||||
{{template "nav" .}}
|
||||
<main>
|
||||
{{template "main" .}}
|
||||
</main>
|
||||
<footer>Powered by <a href='https://golang.org/'>Go</a></footer>
|
||||
<script src='/static/js/main.js' type='text/javascript'></script>
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
@ -1,6 +0,0 @@
|
||||
{{define "title"}}Home{{end}}
|
||||
|
||||
{{define "main" -}}
|
||||
<h2>Latest Snippets</h2>
|
||||
<p>There's nothing to see yet!</p>
|
||||
{{- end -}}
|
@ -1,5 +0,0 @@
|
||||
{{define "nav" -}}
|
||||
<nav>
|
||||
<a href='/'>Home</a>
|
||||
</nav>
|
||||
{{- end}}
|
@ -1,313 +0,0 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 18px;
|
||||
font-family: "Ubuntu Mono", monospace;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
line-height: 1.5;
|
||||
background-color: #F1F3F6;
|
||||
color: #34495E;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
header, nav, main, footer {
|
||||
padding: 2px calc((100% - 800px) / 2) 0;
|
||||
}
|
||||
|
||||
main {
|
||||
margin-top: 54px;
|
||||
margin-bottom: 54px;
|
||||
min-height: calc(100vh - 345px);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
h1 a {
|
||||
font-size: 36px;
|
||||
font-weight: bold;
|
||||
background-image: url("/static/img/logo.png");
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0px 0px;
|
||||
height: 36px;
|
||||
padding-left: 50px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
h1 a:hover {
|
||||
text-decoration: none;
|
||||
color: #34495E;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 22px;
|
||||
margin-bottom: 36px;
|
||||
position: relative;
|
||||
top: -9px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #62CB31;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #4EB722;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
textarea, input:not([type="submit"]) {
|
||||
font-size: 18px;
|
||||
font-family: "Ubuntu Mono", monospace;
|
||||
}
|
||||
|
||||
header {
|
||||
background-image: -webkit-linear-gradient(left, #34495e, #34495e 25%, #9b59b6 25%, #9b59b6 35%, #3498db 35%, #3498db 45%, #62cb31 45%, #62cb31 55%, #ffb606 55%, #ffb606 65%, #e67e22 65%, #e67e22 75%, #e74c3c 85%, #e74c3c 85%, #c0392b 85%, #c0392b 100%);
|
||||
background-image: -moz-linear-gradient(left, #34495e, #34495e 25%, #9b59b6 25%, #9b59b6 35%, #3498db 35%, #3498db 45%, #62cb31 45%, #62cb31 55%, #ffb606 55%, #ffb606 65%, #e67e22 65%, #e67e22 75%, #e74c3c 85%, #e74c3c 85%, #c0392b 85%, #c0392b 100%);
|
||||
background-image: -ms-linear-gradient(left, #34495e, #34495e 25%, #9b59b6 25%, #9b59b6 35%, #3498db 35%, #3498db 45%, #62cb31 45%, #62cb31 55%, #ffb606 55%, #ffb606 65%, #e67e22 65%, #e67e22 75%, #e74c3c 85%, #e74c3c 85%, #c0392b 85%, #c0392b 100%);
|
||||
background-image: linear-gradient(to right, #34495e, #34495e 25%, #9b59b6 25%, #9b59b6 35%, #3498db 35%, #3498db 45%, #62cb31 45%, #62cb31 55%, #ffb606 55%, #ffb606 65%, #e67e22 65%, #e67e22 75%, #e74c3c 85%, #e74c3c 85%, #c0392b 85%, #c0392b 100%);
|
||||
background-size: 100% 6px;
|
||||
background-repeat: no-repeat;
|
||||
border-bottom: 1px solid #E4E5E7;
|
||||
overflow: auto;
|
||||
padding-top: 33px;
|
||||
padding-bottom: 27px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
header a {
|
||||
color: #34495E;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
nav {
|
||||
border-bottom: 1px solid #E4E5E7;
|
||||
padding-top: 17px;
|
||||
padding-bottom: 15px;
|
||||
background: #F7F9FA;
|
||||
height: 60px;
|
||||
color: #6A6C6F;
|
||||
}
|
||||
|
||||
nav a {
|
||||
margin-right: 1.5em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
nav form {
|
||||
display: inline-block;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
nav div {
|
||||
width: 50%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
nav div:last-child {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
nav div:last-child a {
|
||||
margin-left: 1.5em;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
nav a.live {
|
||||
color: #34495E;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
nav a.live:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
nav a.live:after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: relative;
|
||||
left: calc(50% - 7px);
|
||||
top: 9px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
background: #F7F9FA;
|
||||
border-left: 1px solid #E4E5E7;
|
||||
border-bottom: 1px solid #E4E5E7;
|
||||
-moz-transform: rotate(45deg);
|
||||
-webkit-transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
a.button, input[type="submit"] {
|
||||
background-color: #62CB31;
|
||||
border-radius: 3px;
|
||||
color: #FFFFFF;
|
||||
padding: 18px 27px;
|
||||
border: none;
|
||||
display: inline-block;
|
||||
margin-top: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
a.button:hover, input[type="submit"]:hover {
|
||||
background-color: #4EB722;
|
||||
color: #FFFFFF;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
form div {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
form div:last-child {
|
||||
border-top: 1px dashed #E4E5E7;
|
||||
}
|
||||
|
||||
form input[type="radio"] {
|
||||
margin-left: 18px;
|
||||
}
|
||||
|
||||
form input[type="text"], form input[type="password"], form input[type="email"] {
|
||||
padding: 0.75em 18px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
form input[type=text], form input[type="password"], form input[type="email"], textarea {
|
||||
color: #6A6C6F;
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #E4E5E7;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
form label {
|
||||
display: inline-block;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #C0392B;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.error + textarea, .error + input {
|
||||
border-color: #C0392B !important;
|
||||
border-width: 2px !important;
|
||||
}
|
||||
|
||||
textarea {
|
||||
padding: 18px;
|
||||
width: 100%;
|
||||
height: 266px;
|
||||
}
|
||||
|
||||
button {
|
||||
background: none;
|
||||
padding: 0;
|
||||
border: none;
|
||||
color: #62CB31;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
color: #4EB722;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.snippet {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #E4E5E7;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.snippet pre {
|
||||
padding: 18px;
|
||||
border-top: 1px solid #E4E5E7;
|
||||
border-bottom: 1px solid #E4E5E7;
|
||||
}
|
||||
|
||||
.snippet .metadata {
|
||||
background-color: #F7F9FA;
|
||||
color: #6A6C6F;
|
||||
padding: 0.75em 18px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.snippet .metadata span {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.snippet .metadata strong {
|
||||
color: #34495E;
|
||||
}
|
||||
|
||||
.snippet .metadata time {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.snippet .metadata time:first-child {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.snippet .metadata time:last-child {
|
||||
float: right;
|
||||
}
|
||||
|
||||
div.flash {
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
background-color: #34495E;
|
||||
padding: 18px;
|
||||
margin-bottom: 36px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.error {
|
||||
color: #FFFFFF;
|
||||
background-color: #C0392B;
|
||||
padding: 18px;
|
||||
margin-bottom: 36px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
background: white;
|
||||
border: 1px solid #E4E5E7;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td, th {
|
||||
text-align: left;
|
||||
padding: 9px 18px;
|
||||
}
|
||||
|
||||
th:last-child, td:last-child {
|
||||
text-align: right;
|
||||
color: #6A6C6F;
|
||||
}
|
||||
|
||||
tr {
|
||||
border-bottom: 1px solid #E4E5E7;
|
||||
}
|
||||
|
||||
tr:nth-child(2n) {
|
||||
background-color: #F7F9FA;
|
||||
}
|
||||
|
||||
footer {
|
||||
border-top: 1px solid #E4E5E7;
|
||||
padding-top: 17px;
|
||||
padding-bottom: 15px;
|
||||
background: #F7F9FA;
|
||||
height: 60px;
|
||||
color: #6A6C6F;
|
||||
text-align: center;
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.0 KiB |
@ -1,8 +0,0 @@
|
||||
var navLinks = document.querySelectorAll("nav a");
|
||||
for (var i = 0; i < navLinks.length; i++) {
|
||||
var link = navLinks[i]
|
||||
if (link.getAttribute('href') == window.location.pathname) {
|
||||
link.classList.add("live");
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,15 +1,11 @@
|
||||
package user
|
||||
package ratchet
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.runcible.io/learning/ratchet/internal/apperror"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
func TestUserValidation(t *testing.T) {
|
||||
t.Run("user should return invalid", func(t *testing.T) {
|
||||
u := &User{}
|
||||
if apperror.ErrorCode(u.Validate()) != apperror.EINVALID {
|
||||
if ErrorCode(u.Validate()) != EINVALID {
|
||||
t.Errorf("User validation should have failed but passed instead.")
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue