Skip to content

Commit

Permalink
feat: add lyrics
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Nov 11, 2020
1 parent 2b0e64f commit f920cfe
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 105 deletions.
1 change: 1 addition & 0 deletions api/sgtm.proto
Expand Up @@ -164,6 +164,7 @@ message Post {
int64 provider_updated_at = 49;
string provider_metadata = 50;
string tags = 51; // comma separated list of tags
string lyrics = 52;

// soundcloud post
string soundcloud_secret_token = 80 [(go.field) = {name: 'SoundCloudSecretToken'}];
Expand Down
2 changes: 1 addition & 1 deletion gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions pkg/sgtm/page_post-edit.tmpl.html
Expand Up @@ -21,13 +21,19 @@ <h1><a href="{{.PostEdit.Post.CanonicalURL}}">{{.PostEdit.Post.Title}}</a> &gt;
<div class="form-group row">
<label for="staticDescription" class="col-sm-2 col-form-label">Description</label>
<div class="col-sm-10">
<textarea maxlength="500" name="body" class="form-control" placeholder="{{.PostEdit.Post.ProviderDescription}}" id="staticDescription" rows="9">{{.PostEdit.Post.Body}}</textarea>
<textarea maxlength="5000" name="body" class="form-control" placeholder="{{.PostEdit.Post.ProviderDescription}}" id="staticDescription" rows="9">{{.PostEdit.Post.Body}}</textarea>
</div>
</div>
<div class="form-group row">
<label for="staticLyrics" class="col-sm-2 col-form-label">Lyrics</label>
<div class="col-sm-10">
<textarea maxlength="5000" name="lyrics" class="form-control" id="staticLyrics" rows="9">{{.PostEdit.Post.Lyrics}}</textarea>
</div>
</div>
<div class="text-right">
<!--<button name="submit" type="submit" value="published" class="invisible"></button>
<button name="submit" type="submit" value="draft" class="btn btn-light text-muted mb-2 my-3" disabled>Save draft</button>-->
<button name="submit" type="submit" value="published" class="btn btn-primary mb-2 my-3">🤟 Update</button>
<button name="submit" type="submit" value="published" class="btn btn-primary mb-2 my-3">{{":metal:" | emojify}} Update</button>
</div>
</form>
</div>
Expand Down
1 change: 1 addition & 0 deletions pkg/sgtm/page_post.go
Expand Up @@ -244,6 +244,7 @@ func (svc *Service) postEditPage(box *packr.Box) func(w http.ResponseWriter, r *
// FIXME: blacklist, etc
fields := map[string]interface{}{}
fields["body"] = strings.TrimSpace(r.Form.Get("body"))
fields["lyrics"] = strings.TrimSpace(r.Form.Get("lyrics"))
if data.PostEdit.Post.Provider == sgtmpb.Provider_IPFS {
fields["title"] = r.Form.Get("title")
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/sgtm/page_post.tmpl.html
Expand Up @@ -40,7 +40,15 @@ <h1>{{.Post.Post.Title}}</h1>
<code>audio</code> element.
</audio>
{{end}}{{end}}
{{with .Post.Post.SafeDescription}}{{. | markdownify}}{{end}}
{{with .Post.Post.SafeDescription}}
<p>{{. | markdownify}}</p>
{{end}}
{{with .Post.Post.SafeLyrics}}
<div>
Lyrics:
<pre class="border p-2">{{.}}</pre>
</div>
{{end}}
{{with .Post.Post.TagList}}<div>📁 Tags: {{range .}}<span class="badge badge-secondary">{{.}}</span> {{end}}</div>{{end}}
{{if .Post.Post.Duration}}<div>⏱ Duration: <span data-toggle="tooltip" data-placement="right" title="{{.Post.Post.GoDuration}}">{{.Post.Post.GoDuration | prettyDuration}}</span></div>{{end}}
{{with .Post.Post.BPM}}
Expand Down
4 changes: 4 additions & 0 deletions pkg/sgtmpb/helpers.go
Expand Up @@ -42,6 +42,10 @@ func (p *Post) SafeDescription() string {
return p.ProviderDescription
}

func (p *Post) SafeLyrics() string {
return strings.TrimSpace(p.Lyrics)
}

func (p *Post) Filter() {
p.ProviderMetadata = ""
p.DownloadURL = ""
Expand Down

0 comments on commit f920cfe

Please sign in to comment.