moviewyrm/bookwyrm/urls.py

147 lines
6.2 KiB
Python
Raw Normal View History

2020-01-28 19:45:27 +00:00
''' url routing for the app and api '''
from django.conf.urls.static import static
2020-09-21 17:25:26 +00:00
from django.contrib import admin
2020-01-29 19:45:19 +00:00
from django.urls import path, re_path
2020-01-28 19:45:27 +00:00
from bookwyrm import incoming, outgoing, views, settings, wellknown
from bookwyrm import view_actions as actions
2020-12-31 01:36:35 +00:00
from bookwyrm.utils import regex
2020-01-28 19:45:27 +00:00
2020-12-31 01:36:35 +00:00
user_path = r'^user/(?P<username>%s)' % regex.username
local_user_path = r'^user/(?P<username>%s)' % regex.localname
2020-10-17 02:13:18 +00:00
status_types = [
'status',
'review',
'comment',
'quotation',
'boost',
2020-11-01 16:54:10 +00:00
'generatednote'
2020-10-17 02:13:18 +00:00
]
status_path = r'%s/(%s)/(?P<status_id>\d+)' % \
(user_path, '|'.join(status_types))
2020-05-04 00:53:14 +00:00
book_path = r'^book/(?P<book_id>\d+)'
2020-01-25 06:32:41 +00:00
handler404 = 'bookwyrm.views.not_found_page'
handler500 = 'bookwyrm.views.server_error_page'
2020-01-25 06:32:41 +00:00
urlpatterns = [
2020-09-21 17:25:26 +00:00
path('admin/', admin.site.urls),
2020-01-28 08:44:51 +00:00
# federation endpoints
2020-01-29 19:45:19 +00:00
re_path(r'^inbox/?$', incoming.shared_inbox),
2020-02-22 22:02:03 +00:00
re_path(r'%s/inbox/?$' % local_user_path, incoming.inbox),
re_path(r'%s/outbox/?$' % local_user_path, outgoing.outbox),
2020-02-15 19:31:35 +00:00
# .well-known endpoints
re_path(r'^.well-known/webfinger/?$', wellknown.webfinger),
2020-02-15 19:40:21 +00:00
re_path(r'^.well-known/nodeinfo/?$', wellknown.nodeinfo_pointer),
re_path(r'^nodeinfo/2\.0/?$', wellknown.nodeinfo),
2020-02-15 19:31:35 +00:00
re_path(r'^api/v1/instance/?$', wellknown.instance_info),
2020-03-29 07:05:09 +00:00
re_path(r'^api/v1/instance/peers/?$', wellknown.peers),
2020-01-29 19:45:19 +00:00
# TODO: re_path(r'^.well-known/host-meta/?$', incoming.host_meta),
2020-03-29 07:05:09 +00:00
# TODO: robots.txt
2020-01-28 08:44:51 +00:00
# ui views
2020-03-15 21:15:36 +00:00
re_path(r'^login/?$', views.login_page),
re_path(r'^about/?$', views.about_page),
2020-10-02 20:32:19 +00:00
re_path(r'^password-reset/?$', views.password_reset_request),
re_path(r'^password-reset/(?P<code>[A-Za-z0-9]+)/?$', views.password_reset),
2020-09-30 04:45:59 +00:00
re_path(r'^invite/?$', views.manage_invites),
re_path(r'^invite/(?P<code>[A-Za-z0-9]+)/?$', views.invite_page),
2020-03-14 00:57:36 +00:00
path('', views.home),
re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab),
2021-01-03 19:10:04 +00:00
re_path(r'^discover/?$', views.discover_page),
2020-12-14 00:16:12 +00:00
re_path(r'^notifications/?$', views.notifications_page),
re_path(r'^direct-messages/?$', views.direct_messages_page),
2020-11-13 17:02:41 +00:00
re_path(r'^import/?$', views.import_page),
re_path(r'^import-status/(\d+)/?$', views.import_status),
re_path(r'^user-edit/?$', views.edit_profile_page),
2020-03-14 00:57:36 +00:00
2020-03-17 00:45:34 +00:00
# should return a ui view or activitypub json blob as requested
2020-03-14 00:57:36 +00:00
# users
2020-02-22 22:02:03 +00:00
re_path(r'%s/?$' % user_path, views.user_page),
2020-03-14 00:57:36 +00:00
re_path(r'%s\.json$' % local_user_path, views.user_page),
2020-12-02 23:24:43 +00:00
re_path(r'%s/?$' % local_user_path, views.user_page),
2020-03-17 00:29:37 +00:00
re_path(r'%s/shelves/?$' % local_user_path, views.user_shelves_page),
2020-03-28 22:06:16 +00:00
re_path(r'%s/followers(.json)?/?$' % local_user_path, views.followers_page),
re_path(r'%s/following(.json)?/?$' % local_user_path, views.following_page),
2020-03-14 00:57:36 +00:00
# statuses
2020-03-28 22:06:16 +00:00
re_path(r'%s(.json)?/?$' % status_path, views.status_page),
2020-03-14 00:57:36 +00:00
re_path(r'%s/activity/?$' % status_path, views.status_page),
2020-03-28 22:06:16 +00:00
re_path(r'%s/replies(.json)?/?$' % status_path, views.replies_page),
2020-03-14 00:57:36 +00:00
# books
2020-05-10 19:56:59 +00:00
re_path(r'%s(.json)?/?$' % book_path, views.book_page),
2020-03-29 07:05:09 +00:00
re_path(r'%s/edit/?$' % book_path, views.edit_book_page),
re_path(r'^author/(?P<author_id>[\w\-]+)/edit/?$', views.edit_author_page),
2020-11-06 22:25:48 +00:00
re_path(r'%s/editions(.json)?/?$' % book_path, views.editions_page),
2020-03-28 22:06:16 +00:00
re_path(r'^author/(?P<author_id>[\w\-]+)(.json)?/?$', views.author_page),
2020-11-11 05:50:05 +00:00
re_path(r'^tag/(?P<tag_id>.+)\.json/?$', views.tag_page),
re_path(r'^tag/(?P<tag_id>.+)/?$', views.tag_page),
2020-09-21 17:25:26 +00:00
re_path(r'^%s/shelf/(?P<shelf_identifier>[\w-]+)(.json)?/?$' % \
user_path, views.shelf_page),
re_path(r'^%s/shelf/(?P<shelf_identifier>[\w-]+)(.json)?/?$' % \
local_user_path, views.shelf_page),
2020-01-28 03:57:17 +00:00
2020-05-04 04:13:43 +00:00
re_path(r'^search/?$', views.search),
2020-01-28 08:44:51 +00:00
# internal action endpoints
2020-03-15 21:15:36 +00:00
re_path(r'^logout/?$', actions.user_logout),
re_path(r'^user-login/?$', actions.user_login),
2020-09-29 17:21:10 +00:00
re_path(r'^user-register/?$', actions.register),
2020-10-02 20:32:19 +00:00
re_path(r'^reset-password-request/?$', actions.password_reset_request),
re_path(r'^reset-password/?$', actions.password_reset),
2020-10-02 21:42:42 +00:00
re_path(r'^change-password/?$', actions.password_change),
2020-10-02 20:32:19 +00:00
2020-11-11 05:34:26 +00:00
re_path(r'^edit-profile/?$', actions.edit_profile),
2020-03-28 22:06:16 +00:00
2020-12-12 00:57:38 +00:00
re_path(r'^import-data/?$', actions.import_data),
re_path(r'^retry-import/?$', actions.retry_import),
re_path(r'^resolve-book/?$', actions.resolve_book),
re_path(r'^edit-book/(?P<book_id>\d+)/?$', actions.edit_book),
re_path(r'^upload-cover/(?P<book_id>\d+)/?$', actions.upload_cover),
re_path(r'^add-description/(?P<book_id>\d+)/?$', actions.add_description),
re_path(r'^edit-author/(?P<author_id>\d+)/?$', actions.edit_author),
2020-12-12 00:57:38 +00:00
re_path(r'^switch-edition/?$', actions.switch_edition),
re_path(r'^edit-readthrough/?$', actions.edit_readthrough),
re_path(r'^delete-readthrough/?$', actions.delete_readthrough),
2020-10-30 17:40:05 +00:00
2020-04-03 19:43:49 +00:00
re_path(r'^rate/?$', actions.rate),
2020-02-22 22:02:03 +00:00
re_path(r'^review/?$', actions.review),
2020-11-06 21:33:26 +00:00
re_path(r'^quote/?$', actions.quotate),
2020-03-21 23:50:49 +00:00
re_path(r'^comment/?$', actions.comment),
2020-02-22 22:02:03 +00:00
re_path(r'^tag/?$', actions.tag),
re_path(r'^untag/?$', actions.untag),
2020-03-21 23:50:49 +00:00
re_path(r'^reply/?$', actions.reply),
2020-03-28 22:06:16 +00:00
2020-02-22 22:02:03 +00:00
re_path(r'^favorite/(?P<status_id>\d+)/?$', actions.favorite),
2020-03-21 22:21:27 +00:00
re_path(r'^unfavorite/(?P<status_id>\d+)/?$', actions.unfavorite),
re_path(r'^boost/(?P<status_id>\d+)/?$', actions.boost),
2020-11-08 02:59:38 +00:00
re_path(r'^unboost/(?P<status_id>\d+)/?$', actions.unboost),
2020-03-28 22:06:16 +00:00
2020-11-11 05:45:22 +00:00
re_path(r'^delete-status/(?P<status_id>\d+)/?$', actions.delete_status),
2020-10-08 19:32:45 +00:00
2020-11-10 22:52:04 +00:00
re_path(r'^create-shelf/?$', actions.create_shelf),
2020-11-11 04:11:21 +00:00
re_path(r'^edit-shelf/(?P<shelf_id>\d+)?$', actions.edit_shelf),
2020-11-11 04:33:46 +00:00
re_path(r'^delete-shelf/(?P<shelf_id>\d+)?$', actions.delete_shelf),
2020-02-22 22:02:03 +00:00
re_path(r'^shelve/?$', actions.shelve),
2020-10-28 23:52:23 +00:00
re_path(r'^unshelve/?$', actions.unshelve),
2020-11-11 05:45:22 +00:00
re_path(r'^start-reading/(?P<book_id>\d+)/?$', actions.start_reading),
re_path(r'^finish-reading/(?P<book_id>\d+)/?$', actions.finish_reading),
2020-03-28 22:06:16 +00:00
2020-02-22 22:02:03 +00:00
re_path(r'^follow/?$', actions.follow),
re_path(r'^unfollow/?$', actions.unfollow),
2020-11-11 05:34:26 +00:00
re_path(r'^accept-follow-request/?$', actions.accept_follow_request),
re_path(r'^delete-follow-request/?$', actions.delete_follow_request),
2020-03-28 22:06:16 +00:00
re_path(r'^clear-notifications/?$', actions.clear_notifications),
2020-11-11 05:34:26 +00:00
re_path(r'^create-invite/?$', actions.create_invite),
2020-06-03 16:38:30 +00:00
2020-01-28 06:49:56 +00:00
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)