diff --git a/app/api/alpha/routes.py b/app/api/alpha/routes.py
index f14b7446..5d274d63 100644
--- a/app/api/alpha/routes.py
+++ b/app/api/alpha/routes.py
@@ -406,6 +406,7 @@ def alpha_emoji():
# HTML routes
from flask import abort, render_template
+from app.models import Community
from app.utils import current_theme
import os
@@ -463,3 +464,19 @@ def get_alpha_communities():
return render_template(f'themes/{theme}/{template_name}')
else:
return render_template(template_name)
+
+
+@bp.route('/api/alpha/c/', methods=['GET'])
+def community_profile(actor):
+ if '@' in actor:
+ community = Community.query.filter_by(ap_id=actor.lower(), banned=False).first()
+ else:
+ community = Community.query.filter_by(name=actor, ap_id=None).first()
+
+ template_name = "community.html"
+
+ theme = current_theme()
+ if theme != '' and os.path.exists(f'app/templates/themes/{theme}/{template_name}'):
+ return render_template(f'themes/{theme}/{template_name}', community_id=community.id)
+ else:
+ return render_template(template_name, community_id=community.id)
diff --git a/app/templates/themes/x_api/auth/login.html b/app/templates/themes/x_api/auth/login.html
index b3798f35..18f8d20b 100644
--- a/app/templates/themes/x_api/auth/login.html
+++ b/app/templates/themes/x_api/auth/login.html
@@ -1,7 +1,7 @@
{% extends 'themes/' + theme() + '/base.html' %}
{% block app_content %}
- GET /api/alpha/site
+
JSON
POST /api/alpha/user/login
diff --git a/app/templates/themes/x_api/community.html b/app/templates/themes/x_api/community.html
new file mode 100644
index 00000000..63083251
--- /dev/null
+++ b/app/templates/themes/x_api/community.html
@@ -0,0 +1,12 @@
+{% extends 'themes/' + theme() + '/base.html' %}
+
+{% block app_content %}
+
+ JSON
+
+ JSON
+
+ JSON
+
+
+{% endblock %}
diff --git a/app/templates/themes/x_api/js/community.js b/app/templates/themes/x_api/js/community.js
new file mode 100644
index 00000000..865d70cf
--- /dev/null
+++ b/app/templates/themes/x_api/js/community.js
@@ -0,0 +1,26 @@
+const element = document.getElementById('community_request');
+const community_id = element.getAttribute('data-value');
+
+import { baseUrl } from './site.js';
+const community_api = baseUrl + '/api/alpha/community?id=' + community_id;
+const community_post_list_api = baseUrl + '/api/alpha/post/list?sort=Hot&page=1&community_id=' + community_id;
+
+import { jwt } from './site.js';
+if (jwt != null) {
+ var request = {method: "GET", headers: {Authorization: `Bearer ${jwt}`}};
+} else {
+ var request = {method: "GET"};
+}
+
+fetch(community_api, request)
+ .then(response => response.json())
+ .then(data => {
+ document.querySelector('#community_json').textContent = JSON.stringify(data, null, 2);
+ })
+
+
+fetch(community_post_list_api, request)
+ .then(response => response.json())
+ .then(data => {
+ document.querySelector('#community_post_list_json').textContent = JSON.stringify(data, null, 2);
+ })
diff --git a/app/templates/themes/x_api/js/site.js b/app/templates/themes/x_api/js/site.js
index 35bfc629..4b3f3225 100644
--- a/app/templates/themes/x_api/js/site.js
+++ b/app/templates/themes/x_api/js/site.js
@@ -64,11 +64,11 @@ fetch(api_site, request)
for (let mods of data.my_user.moderates) {
let moderated_community_item = document.createElement('li');
if (mods.community.local) {
- moderated_community_item.innerHTML = '' +
+ moderated_community_item.innerHTML = '' +
mods.community.title + '' + ' (' + mods.community.ap_domain + ')' +
''
} else {
- moderated_community_item.innerHTML = '' +
+ moderated_community_item.innerHTML = '' +
mods.community.title + '' + ' (' + mods.community.ap_domain + ')' +
''
}
@@ -87,11 +87,11 @@ fetch(api_site, request)
for (let follows of data.my_user.follows) {
let followed_community_item = document.createElement('li');
if (follows.community.local) {
- followed_community_item.innerHTML = '' +
+ followed_community_item.innerHTML = '' +
follows.community.title + '' + ' (' + follows.community.ap_domain + ')' +
''
} else {
- followed_community_item.innerHTML = '' +
+ followed_community_item.innerHTML = '' +
follows.community.title + '' + ' (' + follows.community.ap_domain + ')' +
''
}
@@ -117,27 +117,34 @@ fetch(api_site, request)
}
// site info
+ let postlist = document.querySelector('#post_list_request')
if (jwt != null) {
document.querySelector('#site_request').innerHTML = 'GET /api/alpha/site
[LOGGED IN]'
- document.querySelector('#post_list_request').innerHTML = 'GET /api/alpha/post/list?type_=Subscribed&sort=New&page=1
'
+ if (postlist) {
+ postlist.innerHTML = 'GET /api/alpha/post/list?type_=Subscribed&sort=New&page=1
'
+ }
} else {
document.querySelector('#site_request').innerHTML = 'GET /api/alpha/site
[LOGGED OUT]'
- document.querySelector('#post_list_request').innerHTML = 'GET /api/alpha/post/list?type_=Popular&sort=Hot&page=1
'
+ if (postlist) {
+ postlist.innerHTML = 'GET /api/alpha/post/list?type_=Popular&sort=Hot&page=1
'
+ }
}
document.querySelector('#site_json').textContent = JSON.stringify(data, null, 2);
})
-if (jwt != null) {
- var api_postlist = baseUrl + '/api/alpha/post/list?type_=Subscribed&sort=New&page=1';
-} else {
- var api_postlist = baseUrl + '/api/alpha/post/list?type_=Popular&sort=Hot&page=1';
-}
-
-fetch(api_postlist, request)
- .then(response => response.json())
- .then(data => {
- document.querySelector('#post_list_json').textContent = JSON.stringify(data, null, 2);
+let postlist = document.querySelector('#post_list_request');
+if (postlist) {
+ if (jwt != null) {
+ var api_postlist = baseUrl + '/api/alpha/post/list?type_=Subscribed&sort=New&page=1';
+ } else {
+ var api_postlist = baseUrl + '/api/alpha/post/list?type_=Popular&sort=Hot&page=1';
+ }
+ fetch(api_postlist, request)
+ .then(response => response.json())
+ .then(data => {
+ document.querySelector('#post_list_json').textContent = JSON.stringify(data, null, 2);
})
+}
diff --git a/app/templates/themes/x_api/list_communities.html b/app/templates/themes/x_api/list_communities.html
index e078b37b..21b3df21 100644
--- a/app/templates/themes/x_api/list_communities.html
+++ b/app/templates/themes/x_api/list_communities.html
@@ -1,7 +1,7 @@
{% extends 'themes/' + theme() + '/base.html' %}
{% block app_content %}
- GET /api/alpha/site
+
JSON
GET /api/alpha/community/list
JSON