mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 19:56:39 +00:00
Compare commits
5 commits
54e06449e3
...
027516fea8
Author | SHA1 | Date | |
---|---|---|---|
027516fea8 | |||
d3d6e3f920 | |||
8bd8c6fb45 | |||
f550f596fa | |||
2cd5abfdcf |
|
@ -950,7 +950,12 @@ definitions:
|
|||
with "direct message" visibility.
|
||||
properties:
|
||||
accounts:
|
||||
description: Participants in the conversation.
|
||||
description: |-
|
||||
Participants in the conversation.
|
||||
|
||||
If this is a conversation between no accounts (ie., a self-directed DM),
|
||||
this will include only the requesting account itself. Otherwise, it will
|
||||
include every other account in the conversation *except* the requester.
|
||||
items:
|
||||
$ref: '#/definitions/account'
|
||||
type: array
|
||||
|
|
|
@ -27,6 +27,10 @@ type Conversation struct {
|
|||
// Is the conversation currently marked as unread?
|
||||
Unread bool `json:"unread"`
|
||||
// Participants in the conversation.
|
||||
//
|
||||
// If this is a conversation between no accounts (ie., a self-directed DM),
|
||||
// this will include only the requesting account itself. Otherwise, it will
|
||||
// include every other account in the conversation *except* the requester.
|
||||
Accounts []Account `json:"accounts"`
|
||||
// The last status in the conversation. May be `null`.
|
||||
LastStatus *Status `json:"last_status"`
|
||||
|
|
|
@ -112,7 +112,7 @@ func (c *sqliteConn) Close() (err error) {
|
|||
raw := c.connIface.(sqlite3driver.Conn).Raw()
|
||||
|
||||
// see: https://www.sqlite.org/pragma.html#pragma_optimize
|
||||
const onClose = "PRAGMA analysis_limit=1000; PRAGMA optimize;"
|
||||
const onClose = "PRAGMA optimize;"
|
||||
_ = raw.Exec(onClose)
|
||||
|
||||
// Finally, close.
|
||||
|
|
|
@ -247,6 +247,12 @@ func (p *Processor) GetVisibleAPIStatuses(
|
|||
continue
|
||||
}
|
||||
|
||||
if apiStatus == nil {
|
||||
// Status was
|
||||
// filtered out.
|
||||
continue
|
||||
}
|
||||
|
||||
// Append converted status to return slice.
|
||||
apiStatuses = append(apiStatuses, *apiStatus)
|
||||
}
|
||||
|
|
|
@ -1832,46 +1832,23 @@ func (c *Converter) NotificationToAPINotification(
|
|||
func (c *Converter) ConversationToAPIConversation(
|
||||
ctx context.Context,
|
||||
conversation *gtsmodel.Conversation,
|
||||
requestingAccount *gtsmodel.Account,
|
||||
requester *gtsmodel.Account,
|
||||
filters []*gtsmodel.Filter,
|
||||
mutes *usermute.CompiledUserMuteList,
|
||||
) (*apimodel.Conversation, error) {
|
||||
apiConversation := &apimodel.Conversation{
|
||||
ID: conversation.ID,
|
||||
Unread: !*conversation.Read,
|
||||
Accounts: []apimodel.Account{},
|
||||
}
|
||||
for _, account := range conversation.OtherAccounts {
|
||||
var apiAccount *apimodel.Account
|
||||
blocked, err := c.state.DB.IsEitherBlocked(ctx, requestingAccount.ID, account.ID)
|
||||
if err != nil {
|
||||
return nil, gtserror.Newf(
|
||||
"DB error checking blocks between accounts %s and %s: %w",
|
||||
requestingAccount.ID,
|
||||
account.ID,
|
||||
err,
|
||||
)
|
||||
}
|
||||
if blocked || account.IsSuspended() {
|
||||
apiAccount, err = c.AccountToAPIAccountBlocked(ctx, account)
|
||||
} else {
|
||||
apiAccount, err = c.AccountToAPIAccountPublic(ctx, account)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, gtserror.Newf(
|
||||
"error converting account %s to API representation: %w",
|
||||
account.ID,
|
||||
err,
|
||||
)
|
||||
}
|
||||
apiConversation.Accounts = append(apiConversation.Accounts, *apiAccount)
|
||||
}
|
||||
|
||||
// Populate most recent status in convo;
|
||||
// can be nil if this status is filtered.
|
||||
if conversation.LastStatus != nil {
|
||||
var err error
|
||||
apiConversation.LastStatus, err = c.StatusToAPIStatus(
|
||||
ctx,
|
||||
conversation.LastStatus,
|
||||
requestingAccount,
|
||||
requester,
|
||||
statusfilter.FilterContextNotifications,
|
||||
filters,
|
||||
mutes,
|
||||
|
@ -1885,6 +1862,60 @@ func (c *Converter) ConversationToAPIConversation(
|
|||
}
|
||||
}
|
||||
|
||||
// If no other accounts are involved in this convo,
|
||||
// just include the requesting account and return.
|
||||
//
|
||||
// See: https://github.com/superseriousbusiness/gotosocial/issues/3385#issuecomment-2394033477
|
||||
otherAcctsLen := len(conversation.OtherAccounts)
|
||||
if otherAcctsLen == 0 {
|
||||
apiAcct, err := c.AccountToAPIAccountPublic(ctx, requester)
|
||||
if err != nil {
|
||||
err := gtserror.Newf(
|
||||
"error converting account %s to API representation: %w",
|
||||
requester.ID, err,
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiConversation.Accounts = []apimodel.Account{*apiAcct}
|
||||
return apiConversation, nil
|
||||
}
|
||||
|
||||
// Other accounts are involved in the
|
||||
// convo. Convert each to API model.
|
||||
apiConversation.Accounts = make([]apimodel.Account, otherAcctsLen)
|
||||
for i, account := range conversation.OtherAccounts {
|
||||
blocked, err := c.state.DB.IsEitherBlocked(ctx,
|
||||
requester.ID, account.ID,
|
||||
)
|
||||
if err != nil {
|
||||
err := gtserror.Newf(
|
||||
"db error checking blocks between accounts %s and %s: %w",
|
||||
requester.ID, account.ID, err,
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// API account model varies depending
|
||||
// on status of conversation participant.
|
||||
var apiAcct *apimodel.Account
|
||||
if blocked || account.IsSuspended() {
|
||||
apiAcct, err = c.AccountToAPIAccountBlocked(ctx, account)
|
||||
} else {
|
||||
apiAcct, err = c.AccountToAPIAccountPublic(ctx, account)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
err := gtserror.Newf(
|
||||
"error converting account %s to API representation: %w",
|
||||
account.ID, err,
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiConversation.Accounts[i] = *apiAcct
|
||||
}
|
||||
|
||||
return apiConversation, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -3358,6 +3358,321 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
|
|||
}`, string(b))
|
||||
}
|
||||
|
||||
func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() {
|
||||
var (
|
||||
ctx = context.Background()
|
||||
requester = suite.testAccounts["local_account_1"]
|
||||
lastStatus = suite.testStatuses["local_account_1_status_1"]
|
||||
filters []*gtsmodel.Filter = nil
|
||||
mutes *usermute.CompiledUserMuteList = nil
|
||||
)
|
||||
|
||||
convo := >smodel.Conversation{
|
||||
ID: "01J9C6K86PKZ5GY5WXV94DGH6R",
|
||||
CreatedAt: testrig.TimeMustParse("2022-06-10T15:22:08Z"),
|
||||
UpdatedAt: testrig.TimeMustParse("2022-06-10T15:22:08Z"),
|
||||
AccountID: requester.ID,
|
||||
Account: requester,
|
||||
OtherAccounts: nil,
|
||||
LastStatus: lastStatus,
|
||||
Read: util.Ptr(true),
|
||||
}
|
||||
|
||||
apiConvo, err := suite.typeconverter.ConversationToAPIConversation(
|
||||
ctx,
|
||||
convo,
|
||||
requester,
|
||||
filters,
|
||||
mutes,
|
||||
)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
b, err := json.MarshalIndent(apiConvo, "", " ")
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// No other accounts involved, so we should only
|
||||
// have our own account in the "accounts" field.
|
||||
suite.Equal(`{
|
||||
"id": "01J9C6K86PKZ5GY5WXV94DGH6R",
|
||||
"unread": false,
|
||||
"accounts": [
|
||||
{
|
||||
"id": "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||
"username": "the_mighty_zork",
|
||||
"acct": "the_mighty_zork",
|
||||
"display_name": "original zork (he/they)",
|
||||
"locked": false,
|
||||
"discoverable": true,
|
||||
"bot": false,
|
||||
"created_at": "2022-05-20T11:09:18.000Z",
|
||||
"note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
|
||||
"url": "http://localhost:8080/@the_mighty_zork",
|
||||
"avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
|
||||
"avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
|
||||
"avatar_description": "a green goblin looking nasty",
|
||||
"header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
|
||||
"header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
|
||||
"header_description": "A very old-school screenshot of the original team fortress mod for quake",
|
||||
"followers_count": 2,
|
||||
"following_count": 2,
|
||||
"statuses_count": 8,
|
||||
"last_status_at": "2024-01-10T09:24:00.000Z",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
}
|
||||
],
|
||||
"last_status": {
|
||||
"id": "01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||
"created_at": "2021-10-20T10:40:37.000Z",
|
||||
"in_reply_to_id": null,
|
||||
"in_reply_to_account_id": null,
|
||||
"sensitive": true,
|
||||
"spoiler_text": "introduction post",
|
||||
"visibility": "public",
|
||||
"language": "en",
|
||||
"uri": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||
"url": "http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||
"replies_count": 2,
|
||||
"reblogs_count": 1,
|
||||
"favourites_count": 1,
|
||||
"favourited": false,
|
||||
"reblogged": false,
|
||||
"muted": false,
|
||||
"bookmarked": false,
|
||||
"pinned": false,
|
||||
"content": "hello everyone!",
|
||||
"reblog": null,
|
||||
"application": {
|
||||
"name": "really cool gts application",
|
||||
"website": "https://reallycool.app"
|
||||
},
|
||||
"account": {
|
||||
"id": "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||
"username": "the_mighty_zork",
|
||||
"acct": "the_mighty_zork",
|
||||
"display_name": "original zork (he/they)",
|
||||
"locked": false,
|
||||
"discoverable": true,
|
||||
"bot": false,
|
||||
"created_at": "2022-05-20T11:09:18.000Z",
|
||||
"note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
|
||||
"url": "http://localhost:8080/@the_mighty_zork",
|
||||
"avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
|
||||
"avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
|
||||
"avatar_description": "a green goblin looking nasty",
|
||||
"header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
|
||||
"header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
|
||||
"header_description": "A very old-school screenshot of the original team fortress mod for quake",
|
||||
"followers_count": 2,
|
||||
"following_count": 2,
|
||||
"statuses_count": 8,
|
||||
"last_status_at": "2024-01-10T09:24:00.000Z",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
"tags": [],
|
||||
"emojis": [],
|
||||
"card": null,
|
||||
"poll": null,
|
||||
"text": "hello everyone!",
|
||||
"interaction_policy": {
|
||||
"can_favourite": {
|
||||
"always": [
|
||||
"public",
|
||||
"me"
|
||||
],
|
||||
"with_approval": []
|
||||
},
|
||||
"can_reply": {
|
||||
"always": [
|
||||
"public",
|
||||
"me"
|
||||
],
|
||||
"with_approval": []
|
||||
},
|
||||
"can_reblog": {
|
||||
"always": [
|
||||
"public",
|
||||
"me"
|
||||
],
|
||||
"with_approval": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
func (suite *InternalToFrontendTestSuite) TestConversationToAPI() {
|
||||
var (
|
||||
ctx = context.Background()
|
||||
requester = suite.testAccounts["local_account_1"]
|
||||
lastStatus = suite.testStatuses["local_account_1_status_1"]
|
||||
filters []*gtsmodel.Filter = nil
|
||||
mutes *usermute.CompiledUserMuteList = nil
|
||||
)
|
||||
|
||||
convo := >smodel.Conversation{
|
||||
ID: "01J9C6K86PKZ5GY5WXV94DGH6R",
|
||||
CreatedAt: testrig.TimeMustParse("2022-06-10T15:22:08Z"),
|
||||
UpdatedAt: testrig.TimeMustParse("2022-06-10T15:22:08Z"),
|
||||
AccountID: requester.ID,
|
||||
Account: requester,
|
||||
OtherAccounts: []*gtsmodel.Account{
|
||||
suite.testAccounts["local_account_2"],
|
||||
},
|
||||
LastStatus: lastStatus,
|
||||
Read: util.Ptr(false),
|
||||
}
|
||||
|
||||
apiConvo, err := suite.typeconverter.ConversationToAPIConversation(
|
||||
ctx,
|
||||
convo,
|
||||
requester,
|
||||
filters,
|
||||
mutes,
|
||||
)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
b, err := json.MarshalIndent(apiConvo, "", " ")
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// One other account is involved, so they
|
||||
// should in the "accounts" field and not us.
|
||||
suite.Equal(`{
|
||||
"id": "01J9C6K86PKZ5GY5WXV94DGH6R",
|
||||
"unread": true,
|
||||
"accounts": [
|
||||
{
|
||||
"id": "01F8MH5NBDF2MV7CTC4Q5128HF",
|
||||
"username": "1happyturtle",
|
||||
"acct": "1happyturtle",
|
||||
"display_name": "happy little turtle :3",
|
||||
"locked": true,
|
||||
"discoverable": false,
|
||||
"bot": false,
|
||||
"created_at": "2022-06-04T13:12:00.000Z",
|
||||
"note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e",
|
||||
"url": "http://localhost:8080/@1happyturtle",
|
||||
"avatar": "",
|
||||
"avatar_static": "",
|
||||
"header": "http://localhost:8080/assets/default_header.webp",
|
||||
"header_static": "http://localhost:8080/assets/default_header.webp",
|
||||
"followers_count": 1,
|
||||
"following_count": 1,
|
||||
"statuses_count": 8,
|
||||
"last_status_at": "2021-07-28T08:40:37.000Z",
|
||||
"emojis": [],
|
||||
"fields": [
|
||||
{
|
||||
"name": "should you follow me?",
|
||||
"value": "maybe!",
|
||||
"verified_at": null
|
||||
},
|
||||
{
|
||||
"name": "age",
|
||||
"value": "120",
|
||||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
}
|
||||
],
|
||||
"last_status": {
|
||||
"id": "01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||
"created_at": "2021-10-20T10:40:37.000Z",
|
||||
"in_reply_to_id": null,
|
||||
"in_reply_to_account_id": null,
|
||||
"sensitive": true,
|
||||
"spoiler_text": "introduction post",
|
||||
"visibility": "public",
|
||||
"language": "en",
|
||||
"uri": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||
"url": "http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||
"replies_count": 2,
|
||||
"reblogs_count": 1,
|
||||
"favourites_count": 1,
|
||||
"favourited": false,
|
||||
"reblogged": false,
|
||||
"muted": false,
|
||||
"bookmarked": false,
|
||||
"pinned": false,
|
||||
"content": "hello everyone!",
|
||||
"reblog": null,
|
||||
"application": {
|
||||
"name": "really cool gts application",
|
||||
"website": "https://reallycool.app"
|
||||
},
|
||||
"account": {
|
||||
"id": "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||
"username": "the_mighty_zork",
|
||||
"acct": "the_mighty_zork",
|
||||
"display_name": "original zork (he/they)",
|
||||
"locked": false,
|
||||
"discoverable": true,
|
||||
"bot": false,
|
||||
"created_at": "2022-05-20T11:09:18.000Z",
|
||||
"note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
|
||||
"url": "http://localhost:8080/@the_mighty_zork",
|
||||
"avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
|
||||
"avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
|
||||
"avatar_description": "a green goblin looking nasty",
|
||||
"header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
|
||||
"header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
|
||||
"header_description": "A very old-school screenshot of the original team fortress mod for quake",
|
||||
"followers_count": 2,
|
||||
"following_count": 2,
|
||||
"statuses_count": 8,
|
||||
"last_status_at": "2024-01-10T09:24:00.000Z",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
"tags": [],
|
||||
"emojis": [],
|
||||
"card": null,
|
||||
"poll": null,
|
||||
"text": "hello everyone!",
|
||||
"interaction_policy": {
|
||||
"can_favourite": {
|
||||
"always": [
|
||||
"public",
|
||||
"me"
|
||||
],
|
||||
"with_approval": []
|
||||
},
|
||||
"can_reply": {
|
||||
"always": [
|
||||
"public",
|
||||
"me"
|
||||
],
|
||||
"with_approval": []
|
||||
},
|
||||
"can_reblog": {
|
||||
"always": [
|
||||
"public",
|
||||
"me"
|
||||
],
|
||||
"with_approval": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
func TestInternalToFrontendTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(InternalToFrontendTestSuite))
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ func (m *Module) indexHandler(c *gin.Context) {
|
|||
Instance: instance,
|
||||
OGMeta: apiutil.OGBase(instance),
|
||||
Stylesheets: []string{cssAbout, cssIndex},
|
||||
Extra: map[string]any{"showStrap": true},
|
||||
Extra: map[string]any{"showStrap": true, "showLoginButton": true},
|
||||
}
|
||||
|
||||
apiutil.TemplateWebPage(c, page)
|
||||
|
|
63
internal/web/login.go
Normal file
63
internal/web/login.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
// GoToSocial
|
||||
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
)
|
||||
|
||||
const (
|
||||
loginPath = "/login"
|
||||
)
|
||||
|
||||
func (m *Module) loginGETHandler(c *gin.Context) {
|
||||
instance, errWithCode := m.processor.InstanceGetV1(c.Request.Context())
|
||||
if errWithCode != nil {
|
||||
apiutil.WebErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
// Return instance we already got from the db,
|
||||
// don't try to fetch it again when erroring.
|
||||
instanceGet := func(ctx context.Context) (*apimodel.InstanceV1, gtserror.WithCode) {
|
||||
return instance, nil
|
||||
}
|
||||
|
||||
// We only serve text/html at this endpoint.
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.TextHTML); err != nil {
|
||||
apiutil.WebErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), instanceGet)
|
||||
return
|
||||
}
|
||||
|
||||
page := apiutil.WebPage{
|
||||
Template: "login.tmpl",
|
||||
Instance: instance,
|
||||
OGMeta: apiutil.OGBase(instance),
|
||||
Stylesheets: []string{cssLogin},
|
||||
Extra: map[string]any{
|
||||
"showStrap": false,
|
||||
},
|
||||
}
|
||||
|
||||
apiutil.TemplateWebPage(c, page)
|
||||
}
|
|
@ -61,6 +61,7 @@
|
|||
cssFA = assetsPathPrefix + "/Fork-Awesome/css/fork-awesome.min.css"
|
||||
cssAbout = distPathPrefix + "/about.css"
|
||||
cssIndex = distPathPrefix + "/index.css"
|
||||
cssLogin = distPathPrefix + "/login.css"
|
||||
cssStatus = distPathPrefix + "/status.css"
|
||||
cssThread = distPathPrefix + "/thread.css"
|
||||
cssProfile = distPathPrefix + "/profile.css"
|
||||
|
@ -119,6 +120,7 @@ func (m *Module) Route(r *router.Router, mi ...gin.HandlerFunc) {
|
|||
r.AttachHandler(http.MethodPost, confirmEmailPath, m.confirmEmailPOSTHandler)
|
||||
r.AttachHandler(http.MethodGet, robotsPath, m.robotsGETHandler)
|
||||
r.AttachHandler(http.MethodGet, aboutPath, m.aboutGETHandler)
|
||||
r.AttachHandler(http.MethodGet, loginPath, m.loginGETHandler)
|
||||
r.AttachHandler(http.MethodGet, domainBlockListPath, m.domainBlockListGETHandler)
|
||||
r.AttachHandler(http.MethodGet, tagsPath, m.tagGETHandler)
|
||||
r.AttachHandler(http.MethodGet, signupPath, m.signupGETHandler)
|
||||
|
|
119
web/source/css/login.css
Normal file
119
web/source/css/login.css
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) GoToSocial Authors admin@gotosocial.org
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
.about-section.settings {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
padding-top: 1rem !important;
|
||||
padding-bottom: 1rem !important;
|
||||
|
||||
p.settings-text {
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
flex: auto;
|
||||
}
|
||||
|
||||
.settings-button {
|
||||
flex: auto;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Reuse about styling, but rework it
|
||||
to separate sections a bit more.
|
||||
*/
|
||||
.about {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
padding: 0;
|
||||
|
||||
background: initial;
|
||||
box-shadow: initial;
|
||||
border: initial;
|
||||
border-radius: initial;
|
||||
|
||||
.about-section {
|
||||
padding: 2rem;
|
||||
background: $bg-accent;
|
||||
box-shadow: $boxshadow;
|
||||
border: $boxshadow-border;
|
||||
border-radius: $br;
|
||||
|
||||
h3 {
|
||||
margin-top: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.apps {
|
||||
align-self: start;
|
||||
|
||||
.applist {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 0.5rem;
|
||||
align-content: start;
|
||||
|
||||
.applist-entry {
|
||||
display: grid;
|
||||
grid-template-columns: 25% 1fr;
|
||||
grid-template-areas: "logo text";
|
||||
gap: 1.5rem;
|
||||
padding: 0.5rem;
|
||||
|
||||
.applist-logo {
|
||||
grid-area: logo;
|
||||
align-self: center;
|
||||
justify-self: center;
|
||||
width: 100%;
|
||||
object-fit: contain;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.applist-logo.redraw {
|
||||
fill: $fg;
|
||||
stroke: $fg;
|
||||
}
|
||||
|
||||
.applist-text {
|
||||
grid-area: text;
|
||||
|
||||
a {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
.apps .applist {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
|
@ -116,3 +116,9 @@
|
|||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.login {
|
||||
position: absolute;
|
||||
top: 2vh;
|
||||
right: 2vh;
|
||||
}
|
||||
|
|
28
web/template/login.tmpl
Normal file
28
web/template/login.tmpl
Normal file
|
@ -0,0 +1,28 @@
|
|||
{{- /*
|
||||
// GoToSocial
|
||||
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ -}}
|
||||
|
||||
<main class="about">
|
||||
<section role="region" class="about-section settings">
|
||||
<p class="settings-text">
|
||||
Looking to configure your profile and other settings?
|
||||
</p>
|
||||
<a href="/settings" class="settings-button button with-icon">Settings</a>
|
||||
</section>
|
||||
{{- include "index_apps.tmpl" . | indent 1 }}
|
||||
</main>
|
22
web/template/login_button.tmpl
Normal file
22
web/template/login_button.tmpl
Normal file
|
@ -0,0 +1,22 @@
|
|||
{{- /*
|
||||
// GoToSocial
|
||||
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ -}}
|
||||
|
||||
{{- if .showLoginButton }}
|
||||
<div class="login"><a href="/login" class="button with-icon">Log in</a></div>
|
||||
{{- end }}
|
|
@ -71,7 +71,9 @@ image/webp
|
|||
{{- end }}
|
||||
<title>{{- template "instanceTitle" . -}}</title>
|
||||
</head>
|
||||
<body class="page">
|
||||
<body>
|
||||
{{- include "login_button.tmpl" . | indent 3 }}
|
||||
<div class="page">
|
||||
<header class="page-header">
|
||||
{{- include "page_header.tmpl" . | indent 3 }}
|
||||
</header>
|
||||
|
@ -81,5 +83,6 @@ image/webp
|
|||
<footer class="page-footer">
|
||||
{{- include "page_footer.tmpl" . | indent 3 }}
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue