-
Notifications
You must be signed in to change notification settings - Fork 5
/
xadmin.js.html
344 lines (279 loc) · 10.3 KB
/
xadmin.js.html
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!doctype html>
<html lang="zh_CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=1024" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>Django Xadmin</title>
<meta name="description" content="Django admin的可持续发展之道 :-0" />
<meta name="author" content="[email protected]" />
<link href="xadmin.js.css" rel="stylesheet" />
<link rel="shortcut icon" href="favicon.png" />
<link rel="apple-touch-icon" href="apple-touch-icon.png" />
<link rel="stylesheet" href="js/default.min.css">
<link rel="stylesheet" href="js/tomorrow-night.css">
<script src="js/highlight.min.js"></script>
<script src="js/python.js"></script>
<script src="js/django.js"></script>
</head>
<body class="impress-supported">
<div id="impress">
<div id="old-1" class="step slide" data-y='-1500'>
<h1>Django-(x)admin</h1>
<h3 class="intro">Admin的可持续发展之道 :-0</h3>
<p class="author">[email protected]</p>
</div>
<div id="old-2" class="step slide" data-x='1000' data-y='-1500'>
<h2>什么是Django admin?</h2>
<h3>Django吸引入门者的利器</h3>
<ul>
<li>根据Model自动生成Admin系统</li>
<li>增删改查功能一个都不少</li>
<li>Model变化后系统可以实时变化</li>
</ul>
</div>
<div class="step slide" data-x='2000' data-y='-1500'>
<h3>MODEL:</h3>
<pre class="python django"><code>
class User(models.Model):
name = models.CharField(max_length=64)
description = models.TextField()
</code></pre>
</div>
<div class="step slide" data-x='3000' data-y='-1500'>
<h3>ADMIN:</h3>
<pre class="python django"><code>
from django.contrib import admin
class UserAdmin(admin.ModelAdmin):
list_display = ('name', 'description')
list_display_links = ('name',)
admin.site.register(User, UserAdmin)
</code></pre>
</div>
<div class="step slide" data-x='4000' data-y='-1500'>
<h3>Django Admin效果</h3>
<img src="imgs/django-admin3.png" alt="django admin 的演示图片">
<img src="imgs/django-admin2.jpg" alt="django admin 的演示图片">
</div>
<div class="step slide" data-x='5000' data-y='-1500'>
<h3>如何实现?</h3>
<p>注册 AdminObject </p>
<p>根据 Model Fields</p>
<p>使用 Django Form等...</p>
</div>
<div class="step slide" data-x='6000' data-y='-1500'>
<h1>谢谢 ;)</h1>
</div>
<div class="step hidden" data-scale='10'>
<p>新事物往往是因为人们对旧事物的某些方面不爽</p>
<img src="imgs/x3.jpg" alt="例如小三" height="300">
</div>
<div class="step hidden" data-scale='0.7' data-x="2000" data-y='-1600'>
<h1 style="font-size: 300px;">不爽?</h1>
</div>
<div class="step" data-x="2000" data-y='500'>
<h2>Django Admin的一些小问题::</h2>
</div>
<div class="step" data-x="2000" data-y='500' data-scale="0.8">
<h3>界面像上个世纪的作品</h3>
<img class="show" src="imgs/django-admin3.png"/>
</div>
<div class="step" data-x="2000" data-y='600' data-scale="0.6">
<h3>蹩脚的过滤器机制</h3>
</div>
<div class="step" data-x="2000" data-y='700' data-scale="0.4">
<h3>想要扩展总是看上去很美</h3>
<pre class="python django"><code>
from django.contrib import admin
class UserAdmin(admin.ModelAdmin):
def do_some_field(self, obj):
# How to get request
admin.site.register(User, UserAdmin)
</code></pre>
</div>
<div class="step" data-x="2000" data-y='800' data-scale="0.2">
<h3>导致几乎没有 django admin 插件这个概念</h3>
<pre class="python django"><code>
from django.contrib import admin
class UserAdmin(NewListAdmin, CoolAdmin, XXXadmin, admin.ModelAdmin):
"""What the Fxxk!!"""
</code></pre>
</div>
<div class="step" data-scale='8'>
<h1>xadmin?</h1>
<h3>不得已而为之</h3>
<img class="show" src="imgs/crazy.gif"/>
</div>
<div class="step" data-x='3000' data-y='3000'>
<h3>xadmin的核心特性</h3>
</div>
<div class="step" data-x='3500' data-y='3500' data-scale="2" data-rotate="90">
<h4><b>1</b> 使用bootstrap作为UI</h4>
</div>
<div class="step" data-x='4000' data-y='4000' data-scale="4" data-rotate="180">
<h4><b>2</b> 使用 Class Base View 解决扩展的问题</h4>
</div>
<div class="step" data-x='4000' data-y='4000' data-z="-100" data-rotate="180">
<p>Tornado中使用的View方式</p>
<p>每次请求会创建一个view对象来处理请求</p>
<p>该对象是面向请求的, 所以可以随意使用self</p>
<pre class="python django"><code>
class UserAdmin(object):
def do_some_field(self, obj):
# Easy get request
user = self.request.user
# Yes
xadmin.site.register(User, UserAdmin)
</code></pre>
</div>
<div class="step" data-x='4500' data-y='4500' data-scale="6" data-rotate="270">
<h4><b>3</b> 使用<span>元类</span>动态创建 AdminClass</h4>
</div>
<div class="step" data-x='4500' data-y='4500' data-scale="1.2" data-rotate="270">
<b>创建类的类</b>
<p>xadmin创建 AdminClass 的流程</p>
<pre class="python django"><code>
UserAdmin + ModelBaseAdmin + Plugins = FinalAdminClass
</code></pre>
</div>
<div class="step" data-x='5000' data-y='5000' data-scale="8" data-rotate="360">
<h4><b>4</b> 内建的插件机制</h4>
<p>借鉴自 Wordpress</p>
<p>使用装饰器实现方法拦截</p>
</div>
<div class="step" data-x='5000' data-y='5000' data-scale="2" data-rotate="360">
<pre style="font-size: 20px;" class="python django"><code>
from django.template import loader
from exadmin.sites import site
from exadmin.views import BaseAdminPlugin, ListAdminView
REFRESH_VAR = '_refresh'
class RefreshPlugin(BaseAdminPlugin):
refresh_times = []
# Media
def get_media(self, media):
if self.refresh_times and self.request.GET.get(REFRESH_VAR):
media.add_js([self.static('exadmin/js/refresh.js')])
return media
site.register_plugin(RefreshPlugin, ListAdminView)
</code></pre>
</div>
<div class="step" data-x='-1000' data-y='-1000' data-rotate="0">
<h2>xadmin目前实现的功能</h2>
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-45" data-rotate-y="45">
<h4><b>1</b> 简单图表功能</h4>
<img class="show" src="imgs/fs/chart.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-90" data-rotate-y="90">
<h4><b>2</b> 数据详情页面</h4>
<p>为什么django-admin没有view页面及权限?</p>
<img class="show" src="imgs/fs/details.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-135" data-rotate-y="135">
<h4><b>3</b> 过滤器强化</h4>
<p>不仅仅是一个列表选择器而已</p>
<img class="show" src="imgs/fs/filter.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-180" data-rotate-y="180">
<h4><b>4</b> 书签</h4>
<p>实现定制化的列表</p>
<img class="show" src="imgs/fs/bookmark.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-225" data-rotate-y="225">
<h4><b>5</b> 导出数据</h4>
<p>csv, xml, json, excel一个都不能少</p>
<img class="show" src="imgs/fs/export.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-270" data-rotate-y="270">
<h4><b>6</b> 动态显示列</h4>
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-315" data-rotate-y="315">
<h4><b>7</b> 关联数据查询</h4>
<img class="show" src="imgs/fs/relate.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="0" data-rotate-y="0">
<h4><b>8</b> 数据添加向导</h4>
<img class="show" src="imgs/fs/wizard.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-45" data-rotate-y="45">
<h4><b>9</b> 随意布局</h4>
<img class="show" src="imgs/fs/form.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-90" data-rotate-y="90">
<h4><b>10</b> dashboard页面</h4>
<img class="show" src="imgs/fs/dashboard.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-135" data-rotate-y="135">
<h4><b>11</b> 定义图标</h4>
<img class="show" src="imgs/fs/icon.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-180" data-rotate-y="180">
<h4><b>12</b> 系统主题功能</h4>
<p>Admin系统也要主题?</p>
<img class="show" src="imgs/fs/theme.png" alt="">
</div>
<div class="step feature" data-x='-1000' data-y='-1000' data-rotate-x="-225" data-rotate-y="225">
<h4><b>13</b> 数据版本</h4>
<p>关键数据跑不了</p>
<img class="show" src="imgs/fs/version.png" alt="">
</div>
<div class="step hidden">
<h3>xadmin的在线资源</h3>
<a href="https://github.com/sshwsfc/django-exadmin">https://github.com/sshwsfc/django-exadmin</a><br/>
<a href="http://exadmin.herokuapp.com">http://exadmin.herokuapp.com</a>
</div>
<div class="step hidden">
<h3>开源项目的心得</h3>
</div>
<div id="github" class="step hidden">
<h4>Github</h4>
<img src="imgs/github.png" alt="" height="400">
</div>
<div class="step hidden">
<h4>heroku.com</h4>
<p>免费的建站方式</p>
<img src="imgs/heroku.png" alt="">
</div>
<div class="step hidden">
<h4>travis-ci.org</h4>
<p>自动化测试助手</p>
<img src="imgs/ti.png" alt="">
</div>
<div class="step hidden">
<h4>c9.io</h4>
<p>让你随时随地coding</p>
<img src="imgs/logo_cloud9.png" alt="">
</div>
<div class="step hidden">
<h3>目前xadmin的问题</h3>
</div>
<div class="step" data-y='-500' data-rotate-x="-180">
<h4>细节优化</h4>
</div>
<div class="step" data-y='-1000' data-rotate-x="0">
<h4>语言问题</h4>
</div>
<div class="step" data-y='-1500' data-rotate-x="180">
<h4>时间和精力</h4>
</div>
<div class="step hidden">
<h3>我的工作?</h3>
<p>www.wiyun.com</p>
</div>
<div class="step hidden">
<h1>谢谢!</h1>
<a href="https://github.com/sshwsfc/django-xadmin-ppt">https://github.com/sshwsfc/django-xadmin-ppt</a>
</div>
<div id="overview" class="step hidden slide" data-scale="15">
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/impress.js"></script>
<script src="js/speed-script.js"></script>
<script>
$(document).ready(function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});
</script>
</body>
</html>