12 Commits
Author SHA1 Message Date
Matt Baer f54ee176fc Remove commentsEnabled AP extension
This isn't used.
2019-11-11 21:56:08 +09:00
Matt Baer 45b1985b97 Change Write.as -> WriteFreely in README 2019-11-11 21:48:19 +09:00
Matt Baer 46304124ec Document posts.ExtractTitle func 2019-05-30 10:12:34 -04:00
Matt Baer 1f29da565f Include calling filename and line # in error logs
...instead of the filename and line number of the Printf call in
log.Error()
2019-05-23 06:59:22 -04:00
Matt BaerandGitHub 8dbb4ebdc5 Merge pull request #3 from gytisrepecka/master
Added phrases_lt.go
2019-05-08 09:51:00 -04:00
Gytis Repečka c5dba02ee6 Added Lithuanian localization. 2019-05-08 08:18:35 +03:00
Matt Baer 7b4bf5c1b2 Include extensions when building Create & Update activities 2019-04-04 16:57:46 -04:00
Matt Baer 78107a0269 Merge branch 'master' of github.com:writeas/web-core 2019-04-04 16:36:11 -04:00
Matt Baer 528e59e922 Update README to explain use in WriteFreely 2019-04-04 16:35:50 -04:00
Matt Baer ad1a4272b0 Support new commentsEnabled property
This adds a CommentsEnabled field to the activitystreams.Object struct,
as well as the Extensions needed in the Context field in order to
describe the field.

This is a field previously supported by PeerTube, and just recently
added in PixelFed.
2019-04-04 16:29:00 -04:00
Matt BaerandGitHub 9884cdaa8a Merge pull request #2 from SamWhited/support_modules
Support Go Modules
2019-02-01 17:30:18 +01:00
Sam Whited cee61547fa Support Go Modules
Fixes #1
2019-02-01 10:28:46 -06:00
8 changed files with 105 additions and 5 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
Write.as web core
=================
WriteFreely web core
====================
[![GoDoc](https://godoc.org/github.com/writeas/web-core?status.svg)](https://godoc.org/github.com/writeas/web-core)
[![Build Status](https://travis-ci.org/writeas/web-core.svg)](https://travis-ci.org/writeas/web-core)
[![#writefreely on freenode](https://img.shields.io/badge/freenode-%23writefreely-blue.svg)](http://webchat.freenode.net/?channels=writefreely)
[![Discuss on our forum](https://img.shields.io/discourse/https/discuss.write.as/users.svg?label=forum)](https://discuss.write.as/c/development)
web-core holds components of the [Write.as](https://write.as) web application.
web-core holds components of the [WriteFreely](https://writefreely.org) web application, and is shared with other [Write.as](https://write.as) products, like [Snap.as](https://snap.as).
+7
View File
@@ -11,6 +11,8 @@ const (
toPublic = "https://www.w3.org/ns/activitystreams#Public"
)
var Extensions = map[string]string{}
// Activity describes actions that have either already occurred, are in the
// process of occurring, or may occur in the future.
type Activity struct {
@@ -38,6 +40,7 @@ func NewCreateActivity(o *Object) *Activity {
BaseObject: BaseObject{
Context: []interface{}{
Namespace,
Extensions,
},
ID: o.ID,
Type: "Create",
@@ -56,6 +59,7 @@ func NewUpdateActivity(o *Object) *Activity {
BaseObject: BaseObject{
Context: []interface{}{
Namespace,
Extensions,
},
ID: o.ID,
Type: "Update",
@@ -113,6 +117,9 @@ type Object struct {
Content string `json:"content"`
ContentMap map[string]string `json:"contentMap,omitempty"`
Tag []Tag `json:"tag"`
// Extensions
// NOTE: add extensions here
}
// NewNoteObject creates a basic Note object that includes the public
+18
View File
@@ -0,0 +1,18 @@
module github.com/writeas/web-core
go 1.10
require (
github.com/kr/pretty v0.1.0 // indirect
github.com/kylemcc/twitter-text-go v0.0.0-20180726194232-7f582f6736ec
github.com/microcosm-cc/bluemonday v1.0.2
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/writeas/impart v1.1.0
github.com/writeas/nerds v1.0.0
github.com/writeas/openssl-go v1.0.0
github.com/writeas/saturday v1.6.0
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 // indirect
)
+29
View File
@@ -0,0 +1,29 @@
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylemcc/twitter-text-go v0.0.0-20180726194232-7f582f6736ec h1:ZXWuspqypleMuJy4bzYEqlMhJnGAYpLrWe5p7W3CdvI=
github.com/kylemcc/twitter-text-go v0.0.0-20180726194232-7f582f6736ec/go.mod h1:voECJzdraJmolzPBgL9Z7ANwXf4oMXaTCsIkdiPpR/g=
github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s=
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/writeas/impart v1.1.0 h1:nPnoO211VscNkp/gnzir5UwCDEvdHThL5uELU60NFSE=
github.com/writeas/impart v1.1.0/go.mod h1:g0MpxdnTOHHrl+Ca/2oMXUHJ0PcRAEWtkCzYCJUXC9Y=
github.com/writeas/nerds v1.0.0 h1:ZzRcCN+Sr3MWID7o/x1cr1ZbLvdpej9Y1/Ho+JKlqxo=
github.com/writeas/nerds v1.0.0/go.mod h1:Gn2bHy1EwRcpXeB7ZhVmuUwiweK0e+JllNf66gvNLdU=
github.com/writeas/openssl-go v1.0.0 h1:YXM1tDXeYOlTyJjoMlYLQH1xOloUimSR1WMF8kjFc5o=
github.com/writeas/openssl-go v1.0.0/go.mod h1:WsKeK5jYl0B5y8ggOmtVjbmb+3rEGqSD25TppjJnETA=
github.com/writeas/saturday v1.6.0 h1:HNUtX8TVJJnSdxE8vaAgtHiAJVt+Of5AJYlm62pmVlI=
github.com/writeas/saturday v1.6.0/go.mod h1:ETE1EK6ogxptJpAgUbcJD0prAtX48bSloie80+tvnzQ=
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613 h1:MQ/ZZiDsUapFFiMS+vzwXkCTeEKaum+Do5rINYJDmxc=
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
+27
View File
@@ -0,0 +1,27 @@
package l10n
var phrasesLT = map[string]string{
"Anonymous post": "Anoniminis įrašas",
"Blogs": "Tinklaraščiai",
"Enter": "Įvesti",
"Newer": "Naujesni",
"Older": "Senesni",
"Posts": "Įrašai",
"Publish to...": "Publikuoti į...",
"Publish": "Publikuoti",
"Read more...": "Skaityti daugiau...",
"This blog requires a password.": "Šis tinklaraštis reikalauja slaptažodžio.",
"Toggle theme": "Keisti temą",
"View posts": "Peržiūrėti įrašus",
"delete": "ištrinti",
"edit": "koreguoti",
"move to...": "perkelti į...",
"pin": "prisegti",
"published with write.as": "publikuojama su write.as",
"share modal ending": "Siųskite draugui, dalinkitės internete ar per Twitter. Sužinokite daugiau.",
"share modal introduction": "Kiekvienas publikuotas įrašas turi slaptą, unikalų URL kuriuo galite pasidalinti su bet kuo. Šis URL yra:",
"share modal title": "Dalintis šiuo įrašu",
"share": "dalintis",
"unpin": "atsegti",
"title dash": "–",
}
+2
View File
@@ -24,6 +24,8 @@ func Strings(lang string) map[string]string {
return phrasesIT
case "ja":
return phrasesJA
case "lt":
return phrasesLT
case "mk":
return phrasesMK
case "pl":
+17 -2
View File
@@ -2,8 +2,10 @@
package log
import (
"fmt"
"log"
"os"
"runtime"
)
var (
@@ -13,7 +15,7 @@ var (
func init() {
InfoLog = log.New(os.Stdout, "", log.Ldate|log.Ltime)
ErrorLog = log.New(os.Stderr, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
ErrorLog = log.New(os.Stderr, "ERROR: ", log.Ldate|log.Ltime)
}
// Info logs an informational message to Stdout.
@@ -23,5 +25,18 @@ func Info(s string, v ...interface{}) {
// Error logs an error to Stderr.
func Error(s string, v ...interface{}) {
ErrorLog.Printf(s, v...)
// Include original caller information
_, file, line, _ := runtime.Caller(1)
// Determine short filename (from standard log package)
short := file
for i := len(file) - 1; i > 0; i-- {
if file[i] == '/' {
short = file[i+1:]
break
}
}
file = short
ErrorLog.Printf(fmt.Sprintf("%s:%d: ", short, line)+s, v...)
}
+2
View File
@@ -4,6 +4,8 @@ import (
"strings"
)
// ExtractTitle takes the given raw post text and returns a title, if explicitly
// provided, and a body.
func ExtractTitle(content string) (title string, body string) {
if hashIndex := strings.Index(content, "# "); hashIndex == 0 {
eol := strings.IndexRune(content, '\n')