bookwyrm-mastodon/fedireads/urls.py

70 lines
3.1 KiB
Python
Raw Normal View History

2020-01-28 14:45:27 -05:00
''' url routing for the app and api '''
from django.conf.urls.static import static
2020-01-25 01:32:41 -05:00
from django.contrib import admin
2020-01-29 14:45:19 -05:00
from django.urls import path, re_path
2020-01-28 14:45:27 -05:00
2020-02-15 14:31:35 -05:00
from fedireads import incoming, outgoing, views, settings, wellknown
2020-02-22 17:02:03 -05:00
from fedireads import view_actions as actions
2020-01-28 14:45:27 -05:00
2020-02-23 04:07:00 -05:00
username_regex = r'(?P<username>[\w@\.-]+)'
2020-02-22 17:02:03 -05:00
localname_regex = r'(?P<username>[\w\.-]+)'
user_path = r'^user/%s' % username_regex
local_user_path = r'^user/%s' % localname_regex
2020-03-10 15:04:38 -04:00
status_path = r'%s/(status|review)/(?P<status_id>\d+)' % local_user_path
2020-01-25 01:32:41 -05:00
urlpatterns = [
path('admin/', admin.site.urls),
2020-01-28 03:44:51 -05:00
# federation endpoints
2020-01-29 14:45:19 -05:00
re_path(r'^inbox/?$', incoming.shared_inbox),
2020-03-07 18:28:11 -05:00
re_path(r'%s.json$' % local_user_path, incoming.get_actor),
2020-02-22 17:02:03 -05:00
re_path(r'%s/inbox/?$' % local_user_path, incoming.inbox),
re_path(r'%s/outbox/?$' % local_user_path, outgoing.outbox),
re_path(r'%s/followers/?$' % local_user_path, incoming.get_followers),
re_path(r'%s/following/?$' % local_user_path, incoming.get_following),
2020-03-07 18:28:11 -05:00
re_path(r'%s.json$' % status_path, incoming.get_status),
re_path(r'%s/activity/?$' % status_path, incoming.get_status),
2020-02-22 17:02:03 -05:00
re_path(r'%s/replies/?$' % status_path, incoming.get_replies),
2020-02-15 14:31:35 -05:00
# .well-known endpoints
re_path(r'^.well-known/webfinger/?$', wellknown.webfinger),
2020-02-15 14:40:21 -05:00
re_path(r'^.well-known/nodeinfo/?$', wellknown.nodeinfo_pointer),
re_path(r'^nodeinfo/2\.0/?$', wellknown.nodeinfo),
2020-02-15 14:31:35 -05:00
re_path(r'^api/v1/instance/?$', wellknown.instance_info),
2020-01-29 14:45:19 -05:00
# TODO: re_path(r'^.well-known/host-meta/?$', incoming.host_meta),
2020-01-28 03:44:51 -05:00
# ui views
path('', views.home),
re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab),
2020-01-29 14:45:19 -05:00
re_path(r'^register/?$', views.register),
re_path(r'^login/?$', views.user_login),
re_path(r'^logout/?$', views.user_logout),
2020-03-07 17:50:29 -05:00
re_path(r'^notifications/?', views.notifications_page),
2020-02-22 17:02:03 -05:00
re_path(r'%s/?$' % user_path, views.user_page),
re_path(r'edit_profile_page/?$', views.edit_profile_page),
2020-03-07 18:28:11 -05:00
re_path(r'%s/?$' % status_path, views.status_page),
2020-02-11 00:09:04 -05:00
re_path(r'^book/(?P<book_identifier>\w+)/?$', views.book_page),
re_path(r'^book/(?P<book_identifier>\w+)/(?P<tab>friends|local|federated)?$', views.book_page),
2020-02-11 01:32:03 -05:00
re_path(r'^author/(?P<author_identifier>\w+)/?$', views.author_page),
re_path(r'^tag/(?P<tag_id>.+)/?$', views.tag_page),
2020-02-22 17:02:03 -05:00
re_path(r'^shelf/%s/(?P<shelf_identifier>[\w-]+)/?$' % username_regex, views.shelf_page),
2020-01-27 22:57:17 -05:00
2020-01-28 03:44:51 -05:00
# internal action endpoints
2020-02-22 17:02:03 -05:00
re_path(r'^review/?$', actions.review),
re_path(r'^tag/?$', actions.tag),
re_path(r'^untag/?$', actions.untag),
re_path(r'^comment/?$', actions.comment),
re_path(r'^favorite/(?P<status_id>\d+)/?$', actions.favorite),
re_path(r'^shelve/?$', actions.shelve),
re_path(r'^follow/?$', actions.follow),
re_path(r'^unfollow/?$', actions.unfollow),
re_path(r'^search/?$', actions.search),
re_path(r'^edit_profile/?$', actions.edit_profile),
2020-03-07 17:50:29 -05:00
re_path(r'^clear-notifications/?$', actions.clear_notifications),
2020-01-27 22:57:17 -05:00
re_path(r'^accept_follow_request/?$', actions.accept_follow_request),
re_path(r'^delete_follow_request/?$', actions.delete_follow_request),
2020-01-28 01:49:56 -05:00
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)