Skip to content
Permalink
Browse files

Merge branch 'develop' into T572-check-updates

  • Loading branch information
thebaer committed Feb 14, 2020
2 parents 38f3eec + 8ce7d4c commit 8364dce39873f15e263926bd1089b088297a29b2
Showing with 3,968 additions and 246 deletions.
  1. +1 −1 .travis.yml
  2. +25 −5 Makefile
  3. +47 −9 account.go
  4. +195 −0 account_import.go
  5. +117 −12 activitypub.go
  6. +77 −6 admin.go
  7. +56 −2 app.go
  8. +2 −1 author/author.go
  9. +11 −2 cmd/writefreely/main.go
  10. +70 −8 collections.go
  11. +25 −3 config/config.go
  12. +15 −0 config/funcs.go
  13. +5 −1 database-lib.go
  14. +13 −1 database-no-sqlite.go
  15. +12 −0 database-sqlite.go
  16. +247 −56 database.go
  17. +50 −0 database_test.go
  18. +52 −0 db/alter.go
  19. +56 −0 db/alter_test.go
  20. +244 −0 db/create.go
  21. +146 −0 db/create_test.go
  22. +76 −0 db/dialect.go
  23. +53 −0 db/index.go
  24. +9 −0 db/raw.go
  25. +26 −0 db/tx.go
  26. +8 −4 errors.go
  27. +12 −2 feed.go
  28. +15 −11 go.mod
  29. +44 −12 go.sum
  30. +52 −2 handle.go
  31. +12 −1 invites.go
  32. +29 −3 less/core.less
  33. +10 −0 less/post-temp.less
  34. +153 −0 main_test.go
  35. +7 −2 migrations/migrations.go
  36. +29 −0 migrations/v3.go
  37. +46 −0 migrations/v4.go
  38. +67 −0 migrations/v5.go
  39. +29 −0 migrations/v6.go
  40. +291 −0 oauth.go
  41. +10 −0 oauth/state.go
  42. +218 −0 oauth_signup.go
  43. +180 −0 oauth_slack.go
  44. +253 −0 oauth_test.go
  45. +114 −0 oauth_writeas.go
  46. +19 −4 pad.go
  47. +48 −1 pages/login.tmpl
  48. +174 −0 pages/signup-oauth.tmpl
  49. +34 −1 postrender.go
  50. +117 −22 posts.go
  51. +8 −6 read.go
  52. +18 −5 routes.go
  53. +17 −5 scripts/upgrade-server.sh
  54. BIN static/img/sign_in_with_slack.png
  55. BIN static/img/sign_in_with_slack@2x.png
  56. +16 −0 static/js/localdate.js
  57. +8 −4 templates.go
  58. +3 −3 templates/base.tmpl
  59. +6 −12 templates/chorus-collection-post.tmpl
  60. +5 −1 templates/chorus-collection.tmpl
  61. +6 −2 templates/collection-post.tmpl
  62. +5 −1 templates/collection-tags.tmpl
  63. +5 −1 templates/collection.tmpl
  64. +4 −0 templates/edit-meta.tmpl
  65. +2 −2 templates/include/posts.tmpl
  66. +5 −1 templates/pad.tmpl
  67. +4 −1 templates/post.tmpl
  68. +3 −3 templates/read.tmpl
  69. +2 −0 templates/user/admin/users.tmpl
  70. +74 −1 templates/user/admin/view-user.tmpl
  71. +11 −4 templates/user/articles.tmpl
  72. +3 −0 templates/user/collection.tmpl
  73. +3 −0 templates/user/collections.tmpl
  74. +64 −0 templates/user/import.tmpl
  75. +4 −4 templates/user/include/header.tmpl
  76. +5 −0 templates/user/include/silenced.tmpl
  77. +8 −16 templates/user/invite.tmpl
  78. +3 −0 templates/user/settings.tmpl
  79. +3 −0 templates/user/stats.tmpl
  80. +12 −0 users.go
  81. +60 −2 webfinger.go
@@ -1,7 +1,7 @@
language: go

go:
- "1.11.x"
- "1.13.x"

env:
- GO111MODULE=on
@@ -25,28 +25,40 @@ build-no-sqlite: assets-no-sqlite deps-no-sqlite

build-linux: deps
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u github.com/karalabe/xgo; \
$(GOGET) -u src.techknowlogick.com/xgo; \
fi
xgo --targets=linux/amd64, -dest build/ $(LDFLAGS) -tags='sqlite' -out writefreely ./cmd/writefreely

build-windows: deps
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u github.com/karalabe/xgo; \
$(GOGET) -u src.techknowlogick.com/xgo; \
fi
xgo --targets=windows/amd64, -dest build/ $(LDFLAGS) -tags='sqlite' -out writefreely ./cmd/writefreely

build-darwin: deps
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u github.com/karalabe/xgo; \
$(GOGET) -u src.techknowlogick.com/xgo; \
fi
xgo --targets=darwin/amd64, -dest build/ $(LDFLAGS) -tags='sqlite' -out writefreely ./cmd/writefreely

build-arm6: deps
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u src.techknowlogick.com/xgo; \
fi
xgo --targets=linux/arm-6, -dest build/ $(LDFLAGS) -tags='sqlite' -out writefreely ./cmd/writefreely

build-arm7: deps
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u github.com/karalabe/xgo; \
$(GOGET) -u src.techknowlogick.com/xgo; \
fi
xgo --targets=linux/arm-7, -dest build/ $(LDFLAGS) -tags='sqlite' -out writefreely ./cmd/writefreely

build-arm64: deps
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GOGET) -u src.techknowlogick.com/xgo; \
fi
xgo --targets=linux/arm64, -dest build/ $(LDFLAGS) -tags='sqlite' -out writefreely ./cmd/writefreely

build-docker :
$(DOCKERCMD) build -t $(IMAGE_NAME):latest -t $(IMAGE_NAME):$(GITREV) .

@@ -79,10 +91,18 @@ release : clean ui assets
mv build/$(BINARY_NAME)-linux-amd64 $(BUILDPATH)/$(BINARY_NAME)
tar -cvzf $(BINARY_NAME)_$(GITREV)_linux_amd64.tar.gz -C build $(BINARY_NAME)
rm $(BUILDPATH)/$(BINARY_NAME)
$(MAKE) build-arm6
mv build/$(BINARY_NAME)-linux-arm-6 $(BUILDPATH)/$(BINARY_NAME)
tar -cvzf $(BINARY_NAME)_$(GITREV)_linux_arm6.tar.gz -C build $(BINARY_NAME)
rm $(BUILDPATH)/$(BINARY_NAME)
$(MAKE) build-arm7
mv build/$(BINARY_NAME)-linux-arm-7 $(BUILDPATH)/$(BINARY_NAME)
tar -cvzf $(BINARY_NAME)_$(GITREV)_linux_arm7.tar.gz -C build $(BINARY_NAME)
rm $(BUILDPATH)/$(BINARY_NAME)
$(MAKE) build-arm64
mv build/$(BINARY_NAME)-linux-arm64 $(BUILDPATH)/$(BINARY_NAME)
tar -cvzf $(BINARY_NAME)_$(GITREV)_linux_arm64.tar.gz -C build $(BINARY_NAME)
rm $(BUILDPATH)/$(BINARY_NAME)
$(MAKE) build-darwin
mv build/$(BINARY_NAME)-darwin-10.6-amd64 $(BUILDPATH)/$(BINARY_NAME)
tar -cvzf $(BINARY_NAME)_$(GITREV)_macos_amd64.tar.gz -C build $(BINARY_NAME)
@@ -135,7 +155,7 @@ $(TMPBIN)/go-bindata: deps $(TMPBIN)
$(GOBUILD) -o $(TMPBIN)/go-bindata github.com/jteeuwen/go-bindata/go-bindata

$(TMPBIN)/xgo: deps $(TMPBIN)
$(GOBUILD) -o $(TMPBIN)/xgo github.com/karalabe/xgo
$(GOBUILD) -o $(TMPBIN)/xgo src.techknowlogick.com/xgo

ci-assets : $(TMPBIN)/go-bindata
$(TMPBIN)/go-bindata -pkg writefreely -ignore=\\.gitignore -tags="!wflib" schema.sql sqlite.sql
@@ -156,17 +156,9 @@ func signupWithRegistration(app *App, signup userRegistration, w http.ResponseWr
Username: signup.Alias,
HashedPass: hashedPass,
HasPass: createdWithPass,
Email: zero.NewString("", signup.Email != ""),
Email: prepareUserEmail(signup.Email, app.keys.EmailKey),
Created: time.Now().Truncate(time.Second).UTC(),
}
if signup.Email != "" {
encEmail, err := data.Encrypt(app.keys.EmailKey, signup.Email)
if err != nil {
log.Error("Unable to encrypt email: %s\n", err)
} else {
u.Email.String = string(encEmail)
}
}

// Create actual user
if err := app.db.CreateUser(app.cfg, u, desiredUsername); err != nil {
@@ -314,12 +306,16 @@ func viewLogin(app *App, w http.ResponseWriter, r *http.Request) error {
Message template.HTML
Flashes []template.HTML
LoginUsername string
OauthSlack bool
OauthWriteAs bool
}{
pageForReq(app, r),
r.FormValue("to"),
template.HTML(""),
[]template.HTML{},
getTempInfo(app, "login-user", r, w),
app.Config().SlackOauth.ClientID != "",
app.Config().WriteAsOauth.ClientID != "",
}

if earlyError != "" {
@@ -750,14 +746,20 @@ func viewArticles(app *App, u *User, w http.ResponseWriter, r *http.Request) err
log.Error("unable to fetch collections: %v", err)
}

silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil {
log.Error("view articles: %v", err)
}
d := struct {
*UserPage
AnonymousPosts *[]PublicPost
Collections *[]Collection
Silenced bool
}{
UserPage: NewUserPage(app, r, u, u.Username+"'s Posts", f),
AnonymousPosts: p,
Collections: c,
Silenced: silenced,
}
d.UserPage.SetMessaging(u)
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
@@ -779,18 +781,25 @@ func viewCollections(app *App, u *User, w http.ResponseWriter, r *http.Request)
uc, _ := app.db.GetUserCollectionCount(u.ID)
// TODO: handle any errors

silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil {
log.Error("view collections %v", err)
return fmt.Errorf("view collections: %v", err)
}
d := struct {
*UserPage
Collections *[]Collection

UsedCollections, TotalCollections int

NewBlogsDisabled bool
Silenced bool
}{
UserPage: NewUserPage(app, r, u, u.Username+"'s Blogs", f),
Collections: c,
UsedCollections: int(uc),
NewBlogsDisabled: !app.cfg.App.CanCreateBlogs(uc),
Silenced: silenced,
}
d.UserPage.SetMessaging(u)
showUserPage(w, "collections", d)
@@ -808,13 +817,20 @@ func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Reques
return ErrCollectionNotFound
}

silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil {
log.Error("view edit collection %v", err)
return fmt.Errorf("view edit collection: %v", err)
}
flashes, _ := getSessionFlashes(app, w, r, nil)
obj := struct {
*UserPage
*Collection
Silenced bool
}{
UserPage: NewUserPage(app, r, u, "Edit "+c.DisplayTitle(), flashes),
Collection: c,
Silenced: silenced,
}

showUserPage(w, "collection", obj)
@@ -976,17 +992,24 @@ func viewStats(app *App, u *User, w http.ResponseWriter, r *http.Request) error
titleStats = c.DisplayTitle() + " "
}

silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil {
log.Error("view stats: %v", err)
return err
}
obj := struct {
*UserPage
VisitsBlog string
Collection *Collection
TopPosts *[]PublicPost
APFollowers int
Silenced bool
}{
UserPage: NewUserPage(app, r, u, titleStats+"Stats", flashes),
VisitsBlog: alias,
Collection: c,
TopPosts: topPosts,
Silenced: silenced,
}
if app.cfg.App.Federation {
folls, err := app.db.GetAPFollowers(c)
@@ -1020,11 +1043,13 @@ func viewSettings(app *App, u *User, w http.ResponseWriter, r *http.Request) err
Email string
HasPass bool
IsLogOut bool
Silenced bool
}{
UserPage: NewUserPage(app, r, u, "Account Settings", flashes),
Email: fullUser.EmailClear(app.keys),
HasPass: passIsSet,
IsLogOut: r.FormValue("logout") == "1",
Silenced: fullUser.IsSilenced(),
}

showUserPage(w, "settings", obj)
@@ -1068,3 +1093,16 @@ func getTempInfo(app *App, key string, r *http.Request, w http.ResponseWriter) s
// Return value
return s
}

func prepareUserEmail(input string, emailKey []byte) zero.String {
email := zero.NewString("", input != "")
if len(input) > 0 {
encEmail, err := data.Encrypt(emailKey, input)
if err != nil {
log.Error("Unable to encrypt email: %s\n", err)
} else {
email.String = string(encEmail)
}
}
return email
}

0 comments on commit 8364dce

Please sign in to comment.
You can’t perform that action at this time.