bookwyrm/bookwyrm/urls.py

139 lines
5.6 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
2021-01-13 21:36:01 +00:00
from bookwyrm import incoming, settings, views, wellknown
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
2021-01-13 20:08:51 +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),
2021-01-13 21:36:01 +00:00
re_path(r'%s/outbox/?$' % local_user_path, views.Outbox.as_view()),
2020-02-15 19:31:35 +00:00
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-28 08:44:51 +00:00
2021-01-19 00:32:02 +00:00
# polling updates
re_path('^api/updates/notifications/?$', views.Updates.as_view()),
2021-01-12 16:19:08 +00:00
# authentication
re_path(r'^login/?$', views.Login.as_view()),
re_path(r'^register/?$', views.Register.as_view()),
re_path(r'^logout/?$', views.Logout.as_view()),
re_path(r'^password-reset/?$', views.PasswordResetRequest.as_view()),
re_path(r'^password-reset/(?P<code>[A-Za-z0-9]+)/?$',
views.PasswordReset.as_view()),
re_path(r'^change-password/?$', views.ChangePassword),
2021-01-13 20:03:27 +00:00
# invites
2021-01-12 18:19:58 +00:00
re_path(r'^invite/?$', views.ManageInvites.as_view()),
re_path(r'^invite/(?P<code>[A-Za-z0-9]+)/?$', views.Invite.as_view()),
2021-01-12 16:19:08 +00:00
2021-01-13 20:03:27 +00:00
# landing pages
2021-01-12 18:44:17 +00:00
re_path(r'^about/?$', views.About.as_view()),
path('', views.Home.as_view()),
re_path(r'^(?P<tab>home|local|federated)/?$', views.Feed.as_view()),
re_path(r'^discover/?$', views.Discover.as_view()),
2021-01-12 19:07:29 +00:00
re_path(r'^notifications/?$', views.Notifications.as_view()),
re_path(r'^direct-messages/?$', views.DirectMessage.as_view()),
2021-01-13 20:03:27 +00:00
# search
re_path(r'^search/?$', views.Search.as_view()),
2021-01-12 19:28:03 +00:00
# imports
2021-01-12 19:07:29 +00:00
re_path(r'^import/?$', views.Import.as_view()),
2021-01-12 19:28:03 +00:00
re_path(r'^import/(\d+)/?$', views.ImportStatus.as_view()),
2021-01-12 19:07:29 +00:00
2020-03-14 00:57:36 +00:00
# users
2021-01-12 20:05:30 +00:00
re_path(r'%s/?$' % user_path, views.User.as_view()),
re_path(r'%s\.json$' % user_path, views.User.as_view()),
2021-01-13 19:45:08 +00:00
re_path(r'%s/shelves/?$' % user_path, views.user_shelves_page),
2021-01-12 20:05:30 +00:00
re_path(r'%s/followers(.json)?/?$' % user_path, views.Followers.as_view()),
re_path(r'%s/following(.json)?/?$' % user_path, views.Following.as_view()),
re_path(r'^edit-profile/?$', views.EditUser.as_view()),
2020-03-14 00:57:36 +00:00
2021-01-16 19:34:19 +00:00
# reading goals
re_path(r'%s/goal/(?P<year>\d{4})/?$' % user_path, views.Goal.as_view()),
2020-03-14 00:57:36 +00:00
# statuses
2021-01-12 21:47:00 +00:00
re_path(r'%s(.json)?/?$' % status_path, views.Status.as_view()),
re_path(r'%s/activity/?$' % status_path, views.Status.as_view()),
re_path(r'%s/replies(.json)?/?$' % status_path, views.Replies.as_view()),
re_path(r'^post/(?P<status_type>\w+)/?$', views.CreateStatus.as_view()),
re_path(r'^delete-status/(?P<status_id>\d+)/?$',
views.DeleteStatus.as_view()),
2020-03-14 00:57:36 +00:00
2021-01-12 21:47:00 +00:00
# interact
2021-01-13 16:10:50 +00:00
re_path(r'^favorite/(?P<status_id>\d+)/?$', views.Favorite.as_view()),
re_path(r'^unfavorite/(?P<status_id>\d+)/?$', views.Unfavorite.as_view()),
re_path(r'^boost/(?P<status_id>\d+)/?$', views.Boost.as_view()),
re_path(r'^unboost/(?P<status_id>\d+)/?$', views.Unboost.as_view()),
2021-01-12 21:47:00 +00:00
2021-01-12 22:43:59 +00:00
# books
re_path(r'%s(.json)?/?$' % book_path, views.Book.as_view()),
re_path(r'%s/edit/?$' % book_path, views.EditBook.as_view()),
re_path(r'%s/editions(.json)?/?$' % book_path, views.Editions.as_view()),
re_path(r'^upload-cover/(?P<book_id>\d+)/?$', views.upload_cover),
re_path(r'^add-description/(?P<book_id>\d+)/?$', views.add_description),
re_path(r'^resolve-book/?$', views.resolve_book),
re_path(r'^switch-edition/?$', views.switch_edition),
2021-01-13 17:54:35 +00:00
# author
re_path(r'^author/(?P<author_id>\d+)(.json)?/?$', views.Author.as_view()),
re_path(r'^author/(?P<author_id>\d+)/edit/?$', views.EditAuthor.as_view()),
2021-01-13 18:24:24 +00:00
# tags
re_path(r'^tag/(?P<tag_id>.+)\.json/?$', views.Tag.as_view()),
re_path(r'^tag/(?P<tag_id>.+)/?$', views.Tag.as_view()),
re_path(r'^tag/?$', views.AddTag.as_view()),
re_path(r'^untag/?$', views.RemoveTag.as_view()),
2021-01-12 21:47:00 +00:00
2021-01-13 19:45:08 +00:00
# shelf
2020-09-21 17:25:26 +00:00
re_path(r'^%s/shelf/(?P<shelf_identifier>[\w-]+)(.json)?/?$' % \
2021-01-13 19:45:08 +00:00
user_path, views.Shelf.as_view()),
2020-09-21 17:25:26 +00:00
re_path(r'^%s/shelf/(?P<shelf_identifier>[\w-]+)(.json)?/?$' % \
2021-01-13 19:45:08 +00:00
local_user_path, views.Shelf.as_view()),
re_path(r'^create-shelf/?$', views.create_shelf),
re_path(r'^delete-shelf/(?P<shelf_id>\d+)?$', views.delete_shelf),
re_path(r'^shelve/?$', views.shelve),
re_path(r'^unshelve/?$', views.unshelve),
2020-01-28 03:57:17 +00:00
2021-01-13 20:33:48 +00:00
# reading progress
re_path(r'^edit-readthrough/?$', views.edit_readthrough),
re_path(r'^delete-readthrough/?$', views.delete_readthrough),
re_path(r'^create-readthrough/?$', views.create_readthrough),
2020-10-30 17:40:05 +00:00
2021-01-13 20:33:48 +00:00
re_path(r'^start-reading/(?P<book_id>\d+)/?$', views.start_reading),
re_path(r'^finish-reading/(?P<book_id>\d+)/?$', views.finish_reading),
2020-03-28 22:06:16 +00:00
2021-01-13 20:33:48 +00:00
# following
2021-01-13 21:05:16 +00:00
re_path(r'^follow/?$', views.follow),
re_path(r'^unfollow/?$', views.unfollow),
re_path(r'^accept-follow-request/?$', views.accept_follow_request),
re_path(r'^delete-follow-request/?$', views.delete_follow_request),
2020-01-28 06:49:56 +00:00
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)