2020-01-28 14:45:27 -05:00
|
|
|
''' url routing for the app and api '''
|
|
|
|
from django.conf.urls.static import static
|
2020-09-21 13:25:26 -04: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
|
|
|
|
2021-01-12 11:08:43 -05:00
|
|
|
from bookwyrm import incoming, outgoing, settings, vviews, views, wellknown
|
2020-09-21 11:10:37 -04:00
|
|
|
from bookwyrm import view_actions as actions
|
2020-12-30 20:36:35 -05:00
|
|
|
from bookwyrm.utils import regex
|
2020-01-28 14:45:27 -05:00
|
|
|
|
2020-12-30 20:36:35 -05:00
|
|
|
user_path = r'^user/(?P<username>%s)' % regex.username
|
|
|
|
local_user_path = r'^user/(?P<username>%s)' % regex.localname
|
2020-09-17 16:02:52 -04:00
|
|
|
|
2020-10-16 22:13:18 -04:00
|
|
|
status_types = [
|
|
|
|
'status',
|
|
|
|
'review',
|
|
|
|
'comment',
|
|
|
|
'quotation',
|
|
|
|
'boost',
|
2020-11-01 11:54:10 -05:00
|
|
|
'generatednote'
|
2020-10-16 22:13:18 -04:00
|
|
|
]
|
2020-09-17 16:02:52 -04:00
|
|
|
status_path = r'%s/(%s)/(?P<status_id>\d+)' % \
|
2020-12-30 19:10:32 -05:00
|
|
|
(user_path, '|'.join(status_types))
|
2020-09-17 16:02:52 -04:00
|
|
|
|
2020-05-03 20:53:14 -04:00
|
|
|
book_path = r'^book/(?P<book_id>\d+)'
|
2020-01-25 01:32:41 -05:00
|
|
|
|
2021-01-12 11:08:43 -05:00
|
|
|
handler404 = 'bookwyrm.vviews.not_found_page'
|
|
|
|
handler500 = 'bookwyrm.vviews.server_error_page'
|
2020-01-25 01:32:41 -05:00
|
|
|
urlpatterns = [
|
2020-09-21 13:25:26 -04:00
|
|
|
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-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),
|
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-03-29 03:05:09 -04:00
|
|
|
re_path(r'^api/v1/instance/peers/?$', wellknown.peers),
|
2020-01-29 14:45:19 -05:00
|
|
|
# TODO: re_path(r'^.well-known/host-meta/?$', incoming.host_meta),
|
2020-03-29 03:05:09 -04:00
|
|
|
# TODO: robots.txt
|
2020-01-28 03:44:51 -05:00
|
|
|
|
2021-01-12 11:19:08 -05:00
|
|
|
# authentication
|
2021-01-12 11:48:31 -05:00
|
|
|
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-12 13:19:58 -05:00
|
|
|
#invites
|
|
|
|
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 11:19:08 -05:00
|
|
|
|
2021-01-12 13:44:17 -05:00
|
|
|
#landing pages
|
|
|
|
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 14:07:29 -05:00
|
|
|
re_path(r'^notifications/?$', views.Notifications.as_view()),
|
2021-01-12 13:44:17 -05:00
|
|
|
|
2021-01-12 14:07:29 -05:00
|
|
|
re_path(r'^direct-messages/?$', views.DirectMessage.as_view()),
|
|
|
|
|
2021-01-12 14:28:03 -05:00
|
|
|
# imports
|
2021-01-12 14:07:29 -05:00
|
|
|
re_path(r'^import/?$', views.Import.as_view()),
|
2021-01-12 14:28:03 -05:00
|
|
|
re_path(r'^import/(\d+)/?$', views.ImportStatus.as_view()),
|
2021-01-12 14:07:29 -05:00
|
|
|
|
2020-03-13 20:57:36 -04:00
|
|
|
|
|
|
|
# users
|
2021-01-12 15:05:30 -05:00
|
|
|
re_path(r'%s/?$' % user_path, views.User.as_view()),
|
|
|
|
re_path(r'%s\.json$' % user_path, views.User.as_view()),
|
|
|
|
re_path(r'%s/shelves/?$' % user_path, vviews.user_shelves_page),
|
|
|
|
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-13 20:57:36 -04:00
|
|
|
|
|
|
|
# statuses
|
2021-01-12 11:08:43 -05:00
|
|
|
re_path(r'%s(.json)?/?$' % status_path, vviews.status_page),
|
|
|
|
re_path(r'%s/activity/?$' % status_path, vviews.status_page),
|
|
|
|
re_path(r'%s/replies(.json)?/?$' % status_path, vviews.replies_page),
|
2020-03-13 20:57:36 -04:00
|
|
|
|
|
|
|
# books
|
2021-01-12 11:08:43 -05:00
|
|
|
re_path(r'%s(.json)?/?$' % book_path, vviews.book_page),
|
|
|
|
re_path(r'%s/edit/?$' % book_path, vviews.edit_book_page),
|
|
|
|
re_path(r'^author/(?P<author_id>[\w\-]+)/edit/?$', vviews.edit_author_page),
|
|
|
|
re_path(r'%s/editions(.json)?/?$' % book_path, vviews.editions_page),
|
|
|
|
|
|
|
|
re_path(r'^author/(?P<author_id>[\w\-]+)(.json)?/?$', vviews.author_page),
|
|
|
|
re_path(r'^tag/(?P<tag_id>.+)\.json/?$', vviews.tag_page),
|
|
|
|
re_path(r'^tag/(?P<tag_id>.+)/?$', vviews.tag_page),
|
2020-09-21 13:25:26 -04:00
|
|
|
re_path(r'^%s/shelf/(?P<shelf_identifier>[\w-]+)(.json)?/?$' % \
|
2021-01-12 11:08:43 -05:00
|
|
|
user_path, vviews.shelf_page),
|
2020-09-21 13:25:26 -04:00
|
|
|
re_path(r'^%s/shelf/(?P<shelf_identifier>[\w-]+)(.json)?/?$' % \
|
2021-01-12 11:08:43 -05:00
|
|
|
local_user_path, vviews.shelf_page),
|
2020-01-27 22:57:17 -05:00
|
|
|
|
2021-01-12 11:08:43 -05:00
|
|
|
re_path(r'^search/?$', vviews.search),
|
2020-05-04 00:13:43 -04:00
|
|
|
|
2020-01-28 03:44:51 -05:00
|
|
|
# internal action endpoints
|
2020-03-28 18:06:16 -04:00
|
|
|
|
2020-12-11 19:57:38 -05:00
|
|
|
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),
|
2020-12-22 12:26:40 -05:00
|
|
|
re_path(r'^edit-author/(?P<author_id>\d+)/?$', actions.edit_author),
|
2020-12-11 19:57:38 -05: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),
|
2021-01-10 13:51:56 -05:00
|
|
|
re_path(r'^create-readthrough/?$', actions.create_readthrough),
|
2020-10-30 13:40:05 -04:00
|
|
|
|
2020-04-03 15:43:49 -04:00
|
|
|
re_path(r'^rate/?$', actions.rate),
|
2020-02-22 17:02:03 -05:00
|
|
|
re_path(r'^review/?$', actions.review),
|
2020-11-06 16:33:26 -05:00
|
|
|
re_path(r'^quote/?$', actions.quotate),
|
2020-03-21 19:50:49 -04:00
|
|
|
re_path(r'^comment/?$', actions.comment),
|
2020-02-22 17:02:03 -05:00
|
|
|
re_path(r'^tag/?$', actions.tag),
|
|
|
|
re_path(r'^untag/?$', actions.untag),
|
2020-03-21 19:50:49 -04:00
|
|
|
re_path(r'^reply/?$', actions.reply),
|
2020-03-28 18:06:16 -04:00
|
|
|
|
2020-02-22 17:02:03 -05:00
|
|
|
re_path(r'^favorite/(?P<status_id>\d+)/?$', actions.favorite),
|
2020-03-21 18:21:27 -04:00
|
|
|
re_path(r'^unfavorite/(?P<status_id>\d+)/?$', actions.unfavorite),
|
2020-03-30 10:13:32 -04:00
|
|
|
re_path(r'^boost/(?P<status_id>\d+)/?$', actions.boost),
|
2020-11-07 21:59:38 -05:00
|
|
|
re_path(r'^unboost/(?P<status_id>\d+)/?$', actions.unboost),
|
2020-03-28 18:06:16 -04:00
|
|
|
|
2020-11-11 00:45:22 -05:00
|
|
|
re_path(r'^delete-status/(?P<status_id>\d+)/?$', actions.delete_status),
|
2020-10-08 15:32:45 -04:00
|
|
|
|
2020-11-10 17:52:04 -05:00
|
|
|
re_path(r'^create-shelf/?$', actions.create_shelf),
|
2020-11-10 23:11:21 -05:00
|
|
|
re_path(r'^edit-shelf/(?P<shelf_id>\d+)?$', actions.edit_shelf),
|
2020-11-10 23:33:46 -05:00
|
|
|
re_path(r'^delete-shelf/(?P<shelf_id>\d+)?$', actions.delete_shelf),
|
2020-02-22 17:02:03 -05:00
|
|
|
re_path(r'^shelve/?$', actions.shelve),
|
2020-10-28 19:52:23 -04:00
|
|
|
re_path(r'^unshelve/?$', actions.unshelve),
|
2020-11-11 00:45:22 -05: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 18:06:16 -04:00
|
|
|
|
2020-02-22 17:02:03 -05:00
|
|
|
re_path(r'^follow/?$', actions.follow),
|
|
|
|
re_path(r'^unfollow/?$', actions.unfollow),
|
2020-11-11 00:34:26 -05:00
|
|
|
re_path(r'^accept-follow-request/?$', actions.accept_follow_request),
|
|
|
|
re_path(r'^delete-follow-request/?$', actions.delete_follow_request),
|
2020-03-13 10:34:40 -04:00
|
|
|
|
|
|
|
|
2020-06-03 12:38:30 -04:00
|
|
|
|
2020-01-28 01:49:56 -05:00
|
|
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|