1
0
mirror of https://github.com/writeas/htmlhouse synced 2025-07-18 21:08:16 +00:00

Make thumbnails host configurable

This commit is contained in:
Matt Baer 2018-01-20 15:54:30 -05:00
parent c001ce6eea
commit d924964b36
5 changed files with 16 additions and 13 deletions

View File

@ -52,6 +52,7 @@ DB_USER=dbuser DB_PASSWORD=pass DB_DB=htmlhouse PRIVATE_KEY=keys/dev PUBLIC_KEY=
| `PORT` | Port to run app on | `8080` | | `PORT` | Port to run app on | `8080` |
| `STATIC_DIR` | Relative dir where static files are stored | `static` | | `STATIC_DIR` | Relative dir where static files are stored | `static` |
| `AUTO_APPROVE` | Automatically approves public posts | false | | `AUTO_APPROVE` | Automatically approves public posts | false |
| `PREVIEWS_HOST` | Fully-qualified URL (without trailing slash) of screenshot server | None. |
| `TWITTER_KEY` | Twitter consumer key | `notreal` | | `TWITTER_KEY` | Twitter consumer key | `notreal` |
| `TWITTER_SECRET` | Twitter consumer secret | `notreal` | | `TWITTER_SECRET` | Twitter consumer secret | `notreal` |
| `TWITTER_TOKEN` | Twitter access token of the posting Twitter account | `notreal` | | `TWITTER_TOKEN` | Twitter access token of the posting Twitter account | `notreal` |

View File

@ -18,9 +18,10 @@ type config struct {
HostName string `env:"key=HOST default=https://html.house"` HostName string `env:"key=HOST default=https://html.house"`
ServerPort int `env:"key=PORT default=8080"` ServerPort int `env:"key=PORT default=8080"`
AutoApprove bool `env:"key=AUTO_APPROVE default=false"` AutoApprove bool `env:"key=AUTO_APPROVE default=false"`
AdminPass string `env:"key=ADMIN_PASS default=uhoh"` PreviewsHost string `env:"key=PREVIEWS_HOST`
BrowseItems int `env:"key=BROWSE_ITEMS default=10"` AdminPass string `env:"key=ADMIN_PASS default=uhoh"`
BrowseItems int `env:"key=BROWSE_ITEMS default=10"`
// Twitter configuration // Twitter configuration
TwitterConsumerKey string `env:"key=TWITTER_KEY default=notreal"` TwitterConsumerKey string `env:"key=TWITTER_KEY default=notreal"`

View File

@ -89,7 +89,7 @@ func addPublicAccess(app *app, houseID, html string) error {
data := url.Values{} data := url.Values{}
data.Set("url", fmt.Sprintf("%s/%s.html", app.cfg.HostName, houseID)) data.Set("url", fmt.Sprintf("%s/%s.html", app.cfg.HostName, houseID))
u, err := url.ParseRequestURI("https://peeper.html.house") u, err := url.ParseRequestURI(app.cfg.PreviewsHost)
u.Path = "/" u.Path = "/"
urlStr := fmt.Sprintf("%v", u) urlStr := fmt.Sprintf("%v", u)

View File

@ -7,13 +7,14 @@ import (
type ( type (
PublicHouse struct { PublicHouse struct {
ID string `json:"id"` ID string `json:"id"`
Title string `json:"title"` Title string `json:"title"`
URL string `json:"url"` URL string `json:"url"`
ThumbURL string `json:"thumb_url"` thumbHost string `json:"-"`
Created time.Time `json:"created"` ThumbURL string `json:"thumb_url"`
Updated time.Time `json:"updated"` Created time.Time `json:"created"`
Views int `json:"views"` Updated time.Time `json:"updated"`
Views int `json:"views"`
} }
HouseStats struct { HouseStats struct {
@ -30,6 +31,6 @@ type (
func (h *PublicHouse) process(app *app) { func (h *PublicHouse) process(app *app) {
h.URL = fmt.Sprintf("%s/%s.html", app.cfg.HostName, h.ID) h.URL = fmt.Sprintf("%s/%s.html", app.cfg.HostName, h.ID)
if h.ThumbURL != "" { if h.ThumbURL != "" {
h.ThumbURL = "https://peeper.html.house/" + h.ThumbURL h.ThumbURL = fmt.Sprintf("%s/%s", app.cfg.PreviewsHost, h.ThumbURL)
} }
} }

View File

@ -39,7 +39,7 @@
</header> </header>
{{ range .Houses }}<div class="open-house"> {{ range .Houses }}<div class="open-house">
<a href="/{{.ID}}.html"><img src="https://peeper.html.house/{{.ThumbURL}}" /> <a href="/{{.ID}}.html"><img src="{{.thumbHost}}/{{.ThumbURL}}" />
<div class="house-name">{{.Title}}</div></a> <div class="house-name">{{.Title}}</div></a>
</div>{{end}} </div>{{end}}