Quellcode durchsuchen

Merge branch 'master' of ssh://phabricator.write.as/diffusion/HH/htmlhouse

tags/v1.0
Matt Baer vor 8 Jahren
Ursprung
Commit
a39e8c4d5b
14 geänderte Dateien mit 191 neuen und 10 gelöschten Zeilen
  1. +4
    -0
      README.md
  2. +1
    -0
      app.go
  3. +33
    -0
      construction.go
  4. +6
    -0
      models.go
  5. +2
    -2
      static/404.html
  6. +2
    -2
      static/about.html
  7. +55
    -0
      static/contact.html
  8. +25
    -0
      static/css/core.less
  9. +0
    -2
      static/default.html
  10. +2
    -2
      static/houses.html
  11. +1
    -0
      templates.go
  12. +55
    -0
      templates/browse.html
  13. +2
    -2
      templates/editor.html
  14. +3
    -0
      templates/stats.html

+ 4
- 0
README.md Datei anzeigen

@@ -11,6 +11,8 @@ No user signup is required -- authorization to modify an individual published pa

It is also available as a [Chrome extension](https://chrome.google.com/webstore/detail/htmlhouse/aljfacibkadhobknaalpfbclcpoepopi).

[![Public Slack discussion](http://slack.write.as/badge.svg)](http://slack.write.as/)

## Development

### Requirements
@@ -45,6 +47,8 @@ DB_USER=dbuser DB_PASSWORD=pass DB_DB=htmlhouse PRIVATE_KEY=keys/dev PUBLIC_KEY=
| `DB_PASSWORD` | Database password | None. **Required** |
| `DB_DB` | Database name | None. **Required** |
| `DB_HOST` | Database host | `localhost` |
| `PRIVATE_KEY` | Generated private key | None. **Required** |
| `PUBLIC_KEY` | Generated public key | None. **Required** |
| `PORT` | Port to run app on | `8080` |
| `STATIC_DIR` | Relative dir where static files are stored | `static` |



+ 1
- 0
app.go Datei anzeigen

@@ -61,6 +61,7 @@ func (app *app) initRouter() {
app.router.HandleFunc("/edit/{house:[A-Za-z0-9.-]{8}}.html", app.handler(getEditor)).Methods("GET").Name("edit")
app.router.HandleFunc("/stats/{house:[A-Za-z0-9.-]{8}}.html", app.handler(viewHouseStats)).Methods("GET").Name("stats")
app.router.HandleFunc("/{house:[A-Za-z0-9.-]{8}}.html", app.handler(getHouse)).Methods("GET").Name("get")
app.router.HandleFunc("/browse", app.handler(viewHouses)).Methods("GET").Name("browse")
app.router.PathPrefix("/").Handler(http.FileServer(http.Dir(app.cfg.StaticDir)))
}



+ 33
- 0
construction.go Datei anzeigen

@@ -188,3 +188,36 @@ func viewHouseStats(app *app, w http.ResponseWriter, r *http.Request) error {

return nil
}

func viewHouses(app *app, w http.ResponseWriter, r *http.Request) error {
houses, err := getPublicHouses(app)
if err != nil {
fmt.Fprintf(w, ":(")
return err
}

app.templates["browse"].ExecuteTemplate(w, "browse", struct{ Houses *[]PublicHouse }{houses})

return nil
}

func getPublicHouses(app *app) (*[]PublicHouse, error) {
houses := []PublicHouse{}
rows, err := app.db.Query("SELECT house_id, title, thumb_url FROM publichouses WHERE approved = 1 ORDER BY updated DESC LIMIT 10")
switch {
case err == sql.ErrNoRows:
return nil, impart.HTTPError{http.StatusNotFound, "Return to sender. Address unknown."}
case err != nil:
fmt.Printf("Couldn't fetch: %v\n", err)
return nil, err
}
defer rows.Close()

house := &PublicHouse{}
for rows.Next() {
err = rows.Scan(&house.ID, &house.Title, &house.ThumbURL)
houses = append(houses, *house)
}

return &houses, nil
}

+ 6
- 0
models.go Datei anzeigen

@@ -1,6 +1,12 @@
package htmlhouse

type (
PublicHouse struct {
ID string
Title string
ThumbURL string
}

HouseStats struct {
ID string
Stats []Stat


+ 2
- 2
static/404.html Datei anzeigen

@@ -17,9 +17,9 @@
<h1>HTMLlot</h1>
<nav>
<a class="home" href="/">&lt;&#8962;/&gt;</a>
<a href="/browse">browse</a>
<a href="/about.html">about</a>
<a href="mailto:hello@write.as">contact</a>
<a target="_blank" href="https://twitter.com/htmlhouse">@HTMLhouse</a>
<a href="/contact.html">contact</a>
</nav>
</header>



+ 2
- 2
static/about.html Datei anzeigen

@@ -31,9 +31,9 @@
<h1>HTMLhouse</h1>
<nav>
<a class="home" href="/">&lt;&#8962;/&gt;</a>
<a href="/browse">browse</a>
<a class="current" href="/about.html">about</a>
<a href="mailto:hello@write.as">contact</a>
<a target="_blank" href="https://twitter.com/htmlhouse">@HTMLhouse</a>
<a href="/contact.html">contact</a>
</nav>
</header>



+ 55
- 0
static/contact.html Datei anzeigen

@@ -0,0 +1,55 @@
<!DOCTYPE HTML>
<html>
<head>

<title>Contact HTMLhouse</title>
<link rel="stylesheet" type="text/css" href="/css/house.css" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="icon" type="image/png" href="/img/favicon-chrome.png" sizes="192x192">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#888888" />

<meta name="description" content="Contact the team at HTMLhouse.">
<meta name="application-name" content="HTMLhouse">
<meta name="application-url" content="https://html.house">
<meta itemprop="name" content="Contact HTMLhouse">
<meta itemprop="description" content="Contact the team at HTMLhouse.">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Contact HTMLhouse">
<meta name="twitter:description" content="Contact the team at HTMLhouse.">
<meta property="og:title" content="Contact HTMLhouse" />
<meta property="og:site_name" content="HTMLhouse" />
<meta property="og:type" content="object" />
<meta property="og:url" content="https://html.house/contact.html" />
<meta property="og:description" content="Contact the team at HTMLhouse." />

</head>
<body>
<header>
<h1>HTMLhouse</h1>
<nav>
<a class="home" href="/">&lt;&#8962;/&gt;</a>
<a href="/browse">browse</a>
<a href="/about.html">about</a>
<a class="current" href="/contact.html">contact</a>
</nav>
</header>

<div id="wrapper">
<h2>Contact Us</h2>
<p>Have a question or some feedback? Let us know through <a href="mailto:hello@write.as?subject=Feedback+on+HTMLhouse">email</a>, <a href="https://twitter.com/htmlhouse">Twitter</a>, or the <strong>#htmlhouse</strong> channel in our <a href="http://slack.write.as/">Slack group</a>.</p>
</div>

<script type="text/javascript">
(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-47877053-8', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>

+ 25
- 0
static/css/core.less Datei anzeigen

@@ -159,6 +159,31 @@ body {
}
}

.open-house {
display: inline;
margin: 2em;
float: left;

img {
border: 1px solid #ccc;
display: block;
max-width: 320px;
max-height: 240px;
.opacity(.6);
.transition-duration(0.3s);
}
a:hover img {
.opacity(1);
}

.house-name {
margin-top: 1em;
font-size: 1.4em;
text-align: center;
display: block;
}
}

#editor, #preview-wrap {
position: absolute;
top: 5em;


+ 0
- 2
static/default.html Datei anzeigen

@@ -1,7 +1,6 @@
<!DOCTYPE html>
<html>
<head>

<title>HTMLhouse</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

@@ -15,7 +14,6 @@
max-width: 100%;
}
</style>

</head>
<body>
<h1>HTMLhouse</h1>


+ 2
- 2
static/houses.html Datei anzeigen

@@ -31,9 +31,9 @@
<h1>my pages</h1>
<nav>
<a class="home" href="/">&lt;&#8962;/&gt;</a>
<a href="/browse">browse</a>
<a href="/about.html">about</a>
<a href="mailto:hello@write.as">contact</a>
<a target="_blank" href="https://twitter.com/htmlhouse">@HTMLhouse</a>
<a href="/contact.html">contact</a>
</nav>
</header>



+ 1
- 0
templates.go Datei anzeigen

@@ -21,4 +21,5 @@ func (app *app) initTemplates() {
// Initialize dynamic pages
initTemplate(app, "editor")
initTemplate(app, "stats")
initTemplate(app, "browse")
}

+ 55
- 0
templates/browse.html Datei anzeigen

@@ -0,0 +1,55 @@
{{define "browse"}}<!DOCTYPE HTML>
<html>
<head>

<title>Browse HTMLhouses</title>
<link rel="stylesheet" type="text/css" href="/css/house.css" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="icon" type="image/png" href="/img/favicon-chrome.png" sizes="192x192">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#888888" />

<meta name="description" content="Browse HTMLhouses.">
<meta name="application-name" content="HTMLhouse">
<meta name="application-url" content="https://html.house">
<meta itemprop="name" content="Browse HTMLhouses">
<meta itemprop="description" content="">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Browse HTMLhouses">
<meta name="twitter:description" content="">
<meta property="og:title" content="Browse HTMLhouses" />
<meta property="og:site_name" content="HTMLhouse" />
<meta property="og:type" content="object" />
<meta property="og:url" content="https://browse.html.house" />
<meta property="og:description" content="" />

</head>
<body>
<header>
<h1>Browse</h1>
<nav>
<a class="home" href="/">&lt;&#8962;/&gt;</a>
<a class="current" href="/browse">browse</a>
<a href="/about.html">about</a>
<a href="/contact.html">contact</a>
</nav>
</header>

{{ range .Houses }}<div class="open-house">
<a href="https://html.house/{{.ID}}"><img src="http://peeper.html.house/{{.ThumbURL}}" />
<div class="house-name">{{.Title}}</div></a>
</div>{{end}}

<script type="text/javascript">
(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-47877053-8', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>{{end}}

+ 2
- 2
templates/editor.html Datei anzeigen

@@ -31,9 +31,9 @@
<h1>HTMLhouse</h1>
<nav>
{{if .ID}}<a class="home" href="/">&lt;&#8962;/&gt;</a>{{end}}
<a href="/browse">browse</a>
<a href="/about.html">about</a>
<a href="mailto:hello@write.as">contact</a>
<a target="_blank" href="https://twitter.com/htmlhouse">@HTMLhouse</a>
<a href="/contact.html">contact</a>
</nav>
{{if .ID}}<a href="/{{.ID}}.html">view</a>{{end}}
<a id="publish" href="#">{{if .ID}}update{{else}}publish{{end}}</a>


+ 3
- 0
templates/stats.html Datei anzeigen

@@ -31,6 +31,9 @@
<h1>{{.ID}}.html stats</h1>
<nav>
<a class="home" href="/">&lt;&#8962;/&gt;</a>
<a href="/browse">browse</a>
<a href="/about.html">about</a>
<a href="/contact.html">contact</a>
</nav>
<a href="/{{.ID}}.html">view</a>
<a href="/edit/{{.ID}}.html">edit</a>


Laden…
Abbrechen
Speichern