Compare commits

...

3 commits

8 changed files with 47 additions and 14 deletions

1
README
View file

@ -12,6 +12,7 @@ Changes (localhost_custom fork):
- visible edited post time
- visible quoted post (status in status)
- visible profile banner in spoiler
- add media description submit (very woozy way, but it works as possible)
- add schedule status
- add language input form
- add expiry status

View file

@ -64,8 +64,16 @@ type MetaData struct {
}
type FederationInfo struct {
Enabled bool `json:enabled"`
MrfPolicies []string `json:mrf_policies"`
Enabled bool `json:"enabled"`
MrfPolicies []string `json:"mrf_policies"`
MrfSimple MRFSimple `json:"mrf_simple"`
}
type MRFSimple struct {
Reject []string `json:"reject"`
MediaNsfw []string `json:"media_nsfw"`
FederatedTimelineRemoval []string `json:"federated_timeline_removal"`
RejectDeletes []string `json:"reject_deletes"`
}

View file

@ -431,7 +431,7 @@ func (c *Client) Search(ctx context.Context, q string, qType string, limit int,
return &results, nil
}
func (c *Client) UploadMediaFromMultipartFileHeader(ctx context.Context, fh *multipart.FileHeader) (*Attachment, error) {
func (c *Client) UploadMediaFromMultipartFileHeader(ctx context.Context, fh *multipart.FileHeader, descr string) (*Attachment, error) {
f, err := fh.Open()
if err != nil {
return nil, err
@ -441,7 +441,7 @@ func (c *Client) UploadMediaFromMultipartFileHeader(ctx context.Context, fh *mul
var buf bytes.Buffer
mw := multipart.NewWriter(&buf)
fname := filepath.Base(fh.Filename)
err = mw.WriteField("description", fname)
err = mw.WriteField("description", descr)
if err != nil {
return nil, err
}

View file

@ -76,6 +76,14 @@ func generatePollOptions() string {
return pollbuilder
}
func generateMediaDescrForm() string {
var mediadescrbuilder string
for i := 0; i < 20; i++ {
mediadescrbuilder = mediadescrbuilder + `<div><textarea rows="2" id="` + fmt.Sprintf("media-descr-%d", i) + `" name="` + fmt.Sprintf("media-descr-%d", i) + `"></textarea></div>`
}
return mediadescrbuilder
}
var quoteRE = regexp.MustCompile("(?mU)(^|> *|\n)(&gt;.*)(<br|$)")
func statusContentFilter(content string, emojis []mastodon.Emoji, mentions []mastodon.Mention) string {
@ -166,8 +174,9 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
t := template.New("default")
t, err = t.Funcs(template.FuncMap{
"EmojiFilter": emojiFilter,
"Allowed_emoji_page": allowed_emoji_page,
"Allowed_emoji_page": allowed_emoji_page,
"GeneratePollOptions": generatePollOptions,
"GenerateMediaDescrForm": generateMediaDescrForm,
"StatusContentFilter": statusContentFilter,
"DisplayInteractionCount": displayInteractionCount,
"TimeSince": timeSince,

View file

@ -979,11 +979,12 @@ func (s *service) Signout(c *client) (err error) {
func (s *service) Post(c *client, content string, replyToID string,
format string, visibility string, isNSFW bool, spoilerText string,
files []*multipart.FileHeader, edit string, language string, expiresIn int, scheduledAt string,
pollOptions []string, pollExpiresIn int, pollHideTotals bool, pollMultiple bool) (id string, err error) {
pollOptions []string, pollExpiresIn int, pollHideTotals bool, pollMultiple bool,
mediaDescription []string) (id string, err error) {
var mediaIDs []string
for _, f := range files {
a, err := c.UploadMediaFromMultipartFileHeader(c.ctx, f)
for idx, f := range files {
a, err := c.UploadMediaFromMultipartFileHeader(c.ctx, f, mediaDescription[idx])
if err != nil {
return "", err
}

View file

@ -313,6 +313,11 @@ func NewHandler(s *service, verbose bool, staticDir string) http.Handler {
isNSFW := c.r.FormValue("is_nsfw") == "true"
quickReply := c.r.FormValue("quickreply") == "true"
files := c.r.MultipartForm.File["attachments"]
var mediaDescription []string
for i := 0; i < len(files); i++ {
v := c.r.FormValue(fmt.Sprintf("media-descr-%d", i))
mediaDescription = append(mediaDescription, v)
}
edit := c.r.FormValue("edit-status-id")
language := c.r.FormValue("lang-code")
expiresIn, err := strconv.Atoi(c.r.FormValue("expires-in"))
@ -328,7 +333,7 @@ func NewHandler(s *service, verbose bool, staticDir string) http.Handler {
scheduledAt = string(scheduled.UTC().Format(time.RFC3339))
}
var pollOptions []string
for i := 0; i < 16; i++ {
for i := 0; i < 20; i++ {
v := c.r.FormValue(fmt.Sprintf("poll-option-%d", i))
if len(v) == 0 {
continue
@ -342,7 +347,7 @@ func NewHandler(s *service, verbose bool, staticDir string) http.Handler {
pollHideTotals := c.r.FormValue("poll-hide-totals") == "true"
pollMultiple := c.r.FormValue("poll-is-multiple") == "true"
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files, edit, language, expiresIn, scheduledAt, pollOptions, pollExpiresIn, pollHideTotals, pollMultiple)
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files, edit, language, expiresIn, scheduledAt, pollOptions, pollExpiresIn, pollHideTotals, pollMultiple, mediaDescription)
if err != nil {
return err
}

View file

@ -73,10 +73,16 @@
<div>
{{if .Instance.Pleroma}}
<div class="federation-enabled"> Federation enabled: {{.Instance.Pleroma.MetaData.Federation.Enabled}} </div>
<div class="mrf-policies"> MRF Policies </div>
{{range .Instance.Pleroma.MetaData.Federation.MrfPolicies}}
{{.}}<br>
{{end}}
<h6> MRF Policies </h6>
{{range .Instance.Pleroma.MetaData.Federation.MrfPolicies}}{{.}}<br>{{end}}
<h6> Rejected instances </h6>
{{range .Instance.Pleroma.MetaData.Federation.MrfSimple.Reject}}{{.}}<br>{{end}}
<h6> Force NSFW instances </h6>
{{range .Instance.Pleroma.MetaData.Federation.MrfSimple.MediaNsfw}}{{.}}<br>{{end}}
<h6> Hiden from federated timeline instances </h6>
{{range .Instance.Pleroma.MetaData.Federation.MrfSimple.FederatedTimelineRemoval}}{{.}}<br>{{end}}
<h6> Rejected deletion activities </h6>
{{range .Instance.Pleroma.MetaData.Federation.MrfSimple.RejectDeletes}}{{.}}<br>{{end}}
{{end}}
<details>
<summary>Current peers ({{.Instance.Stats.DomainCount}})</summary>

View file

@ -43,6 +43,9 @@
<div>
<span class="post-form-field">
<input id="post-file-picker" type="file" name="attachments" multiple accesskey="A" title="Attachments (A)">
<details><summary> Descriptions for media attachments </summary>
{{GenerateMediaDescrForm | Raw}}
</details>
</span>
</div>
<button type="submit" accesskey="P" title="Post (P)"> Post </button>