''' url routing for the app and api ''' from django.conf.urls.static import static from django.contrib import admin from django.urls import path, re_path from bookwyrm import incoming, outgoing, settings, vviews, views, wellknown from bookwyrm import view_actions as actions from bookwyrm.utils import regex user_path = r'^user/(?P%s)' % regex.username local_user_path = r'^user/(?P%s)' % regex.localname status_types = [ 'status', 'review', 'comment', 'quotation', 'boost', 'generatednote' ] status_path = r'%s/(%s)/(?P\d+)' % \ (user_path, '|'.join(status_types)) book_path = r'^book/(?P\d+)' handler404 = 'bookwyrm.vviews.not_found_page' handler500 = 'bookwyrm.vviews.server_error_page' urlpatterns = [ path('admin/', admin.site.urls), # federation endpoints re_path(r'^inbox/?$', incoming.shared_inbox), re_path(r'%s/inbox/?$' % local_user_path, incoming.inbox), re_path(r'%s/outbox/?$' % local_user_path, outgoing.outbox), # .well-known endpoints re_path(r'^.well-known/webfinger/?$', wellknown.webfinger), re_path(r'^.well-known/nodeinfo/?$', wellknown.nodeinfo_pointer), re_path(r'^nodeinfo/2\.0/?$', wellknown.nodeinfo), re_path(r'^api/v1/instance/?$', wellknown.instance_info), re_path(r'^api/v1/instance/peers/?$', wellknown.peers), # 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[A-Za-z0-9]+)/?$', views.PasswordReset.as_view()), re_path(r'^change-password/?$', views.ChangePassword), #invites re_path(r'^invite/?$', views.ManageInvites.as_view()), re_path(r'^invite/(?P[A-Za-z0-9]+)/?$', views.Invite.as_view()), #landing pages re_path(r'^about/?$', views.About.as_view()), path('', views.Home.as_view()), re_path(r'^(?Phome|local|federated)/?$', views.Feed.as_view()), re_path(r'^discover/?$', views.Discover.as_view()), re_path(r'^notifications/?$', views.Notifications.as_view()), re_path(r'^direct-messages/?$', views.DirectMessage.as_view()), # imports re_path(r'^import/?$', views.Import.as_view()), re_path(r'^import/(\d+)/?$', views.ImportStatus.as_view()), # users 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()), # statuses 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\w+)/?$', views.CreateStatus.as_view()), re_path(r'^delete-status/(?P\d+)/?$', views.DeleteStatus.as_view()), # interact re_path(r'^favorite/(?P\d+)/?$', views.Favorite.as_view()), re_path(r'^unfavorite/(?P\d+)/?$', views.Unfavorite.as_view()), re_path(r'^boost/(?P\d+)/?$', views.Boost.as_view()), re_path(r'^unboost/(?P\d+)/?$', views.Unboost.as_view()), # 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\d+)/?$', views.upload_cover), re_path(r'^add-description/(?P\d+)/?$', views.add_description), re_path(r'^resolve-book/?$', views.resolve_book), re_path(r'^switch-edition/?$', views.switch_edition), re_path(r'^author/(?P[\w\-]+)/edit/?$', vviews.edit_author_page), re_path(r'^tag/?$', actions.tag), re_path(r'^untag/?$', actions.untag), re_path(r'^author/(?P[\w\-]+)(.json)?/?$', vviews.author_page), re_path(r'^tag/(?P.+)\.json/?$', vviews.tag_page), re_path(r'^tag/(?P.+)/?$', vviews.tag_page), re_path(r'^%s/shelf/(?P[\w-]+)(.json)?/?$' % \ user_path, vviews.shelf_page), re_path(r'^%s/shelf/(?P[\w-]+)(.json)?/?$' % \ local_user_path, vviews.shelf_page), re_path(r'^search/?$', vviews.search), re_path(r'^edit-author/(?P\d+)/?$', actions.edit_author), re_path(r'^edit-readthrough/?$', actions.edit_readthrough), re_path(r'^delete-readthrough/?$', actions.delete_readthrough), re_path(r'^create-readthrough/?$', actions.create_readthrough), re_path(r'^create-shelf/?$', actions.create_shelf), re_path(r'^edit-shelf/(?P\d+)?$', actions.edit_shelf), re_path(r'^delete-shelf/(?P\d+)?$', actions.delete_shelf), re_path(r'^shelve/?$', actions.shelve), re_path(r'^unshelve/?$', actions.unshelve), re_path(r'^start-reading/(?P\d+)/?$', actions.start_reading), re_path(r'^finish-reading/(?P\d+)/?$', actions.finish_reading), re_path(r'^follow/?$', actions.follow), re_path(r'^unfollow/?$', actions.unfollow), re_path(r'^accept-follow-request/?$', actions.accept_follow_request), re_path(r'^delete-follow-request/?$', actions.delete_follow_request), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)