-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExample_sites.py
More file actions
166 lines (141 loc) · 5.81 KB
/
Example_sites.py
File metadata and controls
166 lines (141 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# sites.py
from django.apps import apps
from django.urls import include
from django.urls import re_path
from django.utils.functional import LazyObject
from django.utils.module_loading import import_string
from wiki.conf import settings
from wiki.core.plugins import registry
class WikiSite:
def __init__(self, name="wiki"):
from wiki.views import accounts, article, deleted_list
self.name = name
self.root_view = getattr(self, "root_view", article.CreateRootView.as_view())
self.root_missing_view = getattr(
self, "root_missing_view", article.MissingRootView.as_view()
)
self.article_view = getattr(self, "article_view", article.ArticleView.as_view())
self.article_create_view = getattr(
self, "article_create_view", article.Create.as_view()
)
self.article_delete_view = getattr(
## ... source file abbreviated to get to include examples ...
re_path(
r"^_accounts/settings/$",
self.profile_update_view,
name="profile_update",
),
]
else:
urlpatterns = []
return urlpatterns
def get_revision_urls(self):
urlpatterns = [
re_path(
r"^change/(?P<revision_id>[0-9]+)/$",
self.revision_change_view,
name="change_revision",
),
re_path(r"^preview/$", self.article_preview_view, name="preview_revision"),
re_path(
r"^merge/(?P<revision_id>[0-9]+)/preview/$",
self.revision_preview_merge_view,
name="merge_revision_preview",
),
]
return [
re_path(r"^_revision/(?P<article_id>[0-9]+)/", include(urlpatterns)),
]
def get_article_urls(self):
urlpatterns = [
re_path(r"^$", self.article_view, name="get"),
re_path(r"^delete/$", self.article_delete_view, name="delete"),
re_path(r"^deleted/$", self.article_deleted_view, name="deleted"),
re_path(r"^edit/$", self.article_edit_view, name="edit"),
re_path(r"^move/$", self.article_move_view, name="move"),
re_path(r"^preview/$", self.article_preview_view, name="preview"),
re_path(r"^history/$", self.article_history_view, name="history"),
re_path(r"^settings/$", self.article_settings_view, name="settings"),
re_path(r"^source/$", self.article_source_view, name="source"),
re_path(
r"^revision/change/(?P<revision_id>[0-9]+)/$",
self.revision_change_view,
name="change_revision",
),
re_path(
r"^revision/merge/(?P<revision_id>[0-9]+)/$",
self.revision_merge_view,
name="merge_revision",
),
re_path(
r"^plugin/(?P<slug>\w+)/$", self.article_plugin_view, name="plugin"
),
]
return [
re_path(r"^(?P<article_id>[0-9]+)/", include(urlpatterns)),
]
def get_article_path_urls(self):
urlpatterns = [
re_path(
r"^(?P<path>.+/|)_create/$", self.article_create_view, name="create"
),
re_path(
r"^(?P<path>.+/|)_delete/$", self.article_delete_view, name="delete"
),
re_path(
r"^(?P<path>.+/|)_deleted/$", self.article_deleted_view, name="deleted"
),
re_path(r"^(?P<path>.+/|)_edit/$", self.article_edit_view, name="edit"),
re_path(r"^(?P<path>.+/|)_move/$", self.article_move_view, name="move"),
re_path(
r"^(?P<path>.+/|)_preview/$", self.article_preview_view, name="preview"
),
re_path(
r"^(?P<path>.+/|)_history/$", self.article_history_view, name="history"
),
re_path(r"^(?P<path>.+/|)_dir/$", self.article_dir_view, name="dir"),
re_path(r"^(?P<path>.+/|)_search/$", self.search_view, name="search"),
re_path(
## ... source file abbreviated to get to include examples ...
name="change_revision",
),
re_path(
r"^(?P<path>.+/|)_revision/merge/(?P<revision_id>[0-9]+)/$",
self.revision_merge_view,
name="merge_revision",
),
re_path(
r"^(?P<path>.+/|)_plugin/(?P<slug>\w+)/$",
self.article_plugin_view,
name="plugin",
),
re_path(r"^(?P<path>.+/|)$", self.article_view, name="get"),
]
return urlpatterns
def get_plugin_urls(self):
urlpatterns = []
for plugin in registry.get_plugins().values():
slug = getattr(plugin, "slug", None)
if slug:
article_urlpatterns = plugin.urlpatterns.get("article", [])
urlpatterns += [
re_path(
r"^(?P<article_id>[0-9]+)/plugin/" + slug + "/",
include(article_urlpatterns),
),
re_path(
r"^(?P<path>.+/|)_plugin/" + slug + "/",
include(article_urlpatterns),
),
]
root_urlpatterns = plugin.urlpatterns.get("root", [])
urlpatterns += [
re_path(r"^_plugin/" + slug + "/", include(root_urlpatterns)),
]
return urlpatterns
class DefaultWikiSite(LazyObject):
def _setup(self):
WikiSiteClass = import_string(apps.get_app_config("wiki").default_site)
self._wrapped = WikiSiteClass()
site = DefaultWikiSite()
## ... source file continues with no further include examples...