Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
3b8180d7
Commit
3b8180d7
authored
Jun 03, 2020
by
Steven Fuchs
Browse files
add status_net/config
parent
dbcc1b10
Changes
6
Hide whitespace changes
Inline
Side-by-side
config/config.exs
View file @
3b8180d7
...
...
@@ -420,7 +420,8 @@
providers:
[
Pleroma
.
Web
.
Preload
.
Providers
.
Instance
,
Pleroma
.
Web
.
Preload
.
Providers
.
User
,
Pleroma
.
Web
.
Preload
.
Providers
.
Timelines
Pleroma
.
Web
.
Preload
.
Providers
.
Timelines
,
Pleroma
.
Web
.
Preload
.
Providers
.
StatusNet
]
config
:pleroma
,
:http_security
,
...
...
lib/pleroma/web/preload.ex
View file @
3b8180d7
...
...
@@ -9,7 +9,13 @@ defmodule Pleroma.Web.Preload do
def
build_tags
(
_conn
,
params
)
do
preload_data
=
Enum
.
reduce
(
Pleroma
.
Config
.
get
([
__MODULE__
,
:providers
],
[]),
%{},
fn
parser
,
acc
->
Map
.
merge
(
acc
,
parser
.
generate_terms
(
params
))
terms
=
params
|>
parser
.
generate_terms
()
|>
Enum
.
map
(
fn
{
k
,
v
}
->
{
k
,
Base
.
encode64
(
Jason
.
encode!
(
v
))}
end
)
|>
Enum
.
into
(%{})
Map
.
merge
(
acc
,
terms
)
end
)
rendered_html
=
...
...
@@ -22,8 +28,6 @@ def build_tags(_conn, params) do
end
def
build_script_tag
(
content
)
do
content
=
Base
.
encode64
(
content
)
HTML
.
Tag
.
content_tag
(
:script
,
HTML
.
raw
(
content
),
id:
"initial-results"
,
type:
"application/json"
...
...
lib/pleroma/web/preload/status_net.ex
0 → 100644
View file @
3b8180d7
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma
.
Web
.
Preload
.
Providers
.
StatusNet
do
alias
Pleroma
.
Web
.
TwitterAPI
.
UtilView
alias
Pleroma
.
Web
.
Preload
.
Providers
.
Provider
@behaviour
Provider
@config_url
:"/api/statusnet/config.json"
@impl
Provider
def
generate_terms
(
_params
)
do
%{}
|>
build_config_tag
()
end
defp
build_config_tag
(
acc
)
do
instance
=
Pleroma
.
Config
.
get
(
:instance
)
info_data
=
UtilView
.
status_net_config
(
instance
)
Map
.
put
(
acc
,
@config_url
,
info_data
)
end
end
lib/pleroma/web/twitter_api/controllers/util_controller.ex
View file @
3b8180d7
...
...
@@ -15,6 +15,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
alias
Pleroma
.
User
alias
Pleroma
.
Web
alias
Pleroma
.
Web
.
CommonAPI
alias
Pleroma
.
Web
.
TwitterAPI
.
UtilView
alias
Pleroma
.
Web
.
WebFinger
plug
(
Pleroma
.
Web
.
FederatingPlug
when
action
==
:remote_subscribe
)
...
...
@@ -90,17 +91,7 @@ def notifications_read(%{assigns: %{user: user}} = conn, %{"id" => notification_
def
config
(%{
assigns:
%{
format:
"xml"
}}
=
conn
,
_params
)
do
instance
=
Pleroma
.
Config
.
get
(
:instance
)
response
=
"""
<config>
<site>
<name>#{Keyword.get(instance, :name)}</name>
<site>#{Web.base_url()}</site>
<textlimit>#{Keyword.get(instance, :limit)}</textlimit>
<closed>#{!Keyword.get(instance, :registrations_open)}</closed>
</site>
</config>
"""
response
=
UtilView
.
status_net_config
(
instance
)
conn
|>
put_resp_content_type
(
"application/xml"
)
...
...
lib/pleroma/web/twitter_api/views/util_view.ex
View file @
3b8180d7
...
...
@@ -5,4 +5,18 @@
defmodule
Pleroma
.
Web
.
TwitterAPI
.
UtilView
do
use
Pleroma
.
Web
,
:view
import
Phoenix
.
HTML
.
Form
alias
Pleroma
.
Web
def
status_net_config
(
instance
)
do
"""
<config>
<site>
<name>#{Keyword.get(instance, :name)}</name>
<site>#{Web.base_url()}</site>
<textlimit>#{Keyword.get(instance, :limit)}</textlimit>
<closed>#{!Keyword.get(instance, :registrations_open)}</closed>
</site>
</config>
"""
end
end
test/web/preload/status_net_test.exs
0 → 100644
View file @
3b8180d7
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma
.
Web
.
Preload
.
Providers
.
StatusNetTest
do
use
Pleroma
.
DataCase
alias
Pleroma
.
Web
.
Preload
.
Providers
.
StatusNet
setup
do
:
{
:ok
,
StatusNet
.
generate_terms
(
nil
)}
test
"it renders the info"
,
%{
"/api/statusnet/config.json"
:
info
}
do
assert
info
=~
"<name>Pleroma</name>"
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment