-
Notifications
You must be signed in to change notification settings - Fork 9
/
PageDownload.py
349 lines (282 loc) · 14.5 KB
/
PageDownload.py
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
344
345
346
347
348
349
# -*- Mode: python; coding: utf-8 -*-
#
# Cherokee Web Site
#
# Authors:
# Alvaro Lopez Ortega <[email protected]>
#
# Copyright (C) 2001-2011 Alvaro Lopez Ortega
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
import re
import os
import CTK
import Page
import Downloads
import Mirror_Sites
MACOSX_TITLE = N_("Download Cherokee for MacOS X")
LINUX_TITLE = N_("Download Cherokee for Linux")
SOURCE_TITLE = N_("Install Cherokee for the Source Code")
WINDOWS_TITLE = N_("Download Cherokee for Window")
FREEBSD_TITLE = N_("Download cherokee for FreeBSD")
URL_BASE = "/downloads"
URL_MACOSX = "/downloads/macosx"
URL_MACOSX_2 = "/downloads/macosx/2"
URL_LINUX = "/downloads/linux"
URL_WINDOWS = "/downloads/windows"
URL_FREEBSD = "/download/freebsd"
URL_SOURCE = "/downloads/source"
URL_VIDEO1 = "/downloads/video/1"
OS_OPTIONS = [
('macosx', N_('MacOS X')),
('linux', N_('Linux')),
('windows', N_('Windows')),
('freebsd', N_('FreeBSD')),
('source', N_('Source Code')),
]
DOC_APTGET = 'http://www.cherokee-project.com/doc/basics_installation_unix.html#APT'
DOC_EPEL_URL = 'http://fedoraproject.org/wiki/EPEL'
DOC_FEDORA_PACKAGE_URL = 'https://admin.fedoraproject.org/community/?package=cherokee#package_maintenance'
class OS_Panel (CTK.Box):
class OS_Icon (CTK.Image):
def __init__ (self, os_code, os_name, os_selected):
CTK.Image.__init__ (self, {'src': '/static/images/os_%s.png'%(os_code), 'title': os_name, 'class': ['','os-selected'][os_code==os_selected]})
def __init__ (self):
CTK.Box.__init__ (self)
self.os_selected = None
# Detect the OS
agent = CTK.request.headers.get ('HTTP_USER_AGENT').lower()
if 'linux' in agent:
self.os_selected = 'linux'
if not self.os_selected:
for key in ('macintosh', 'mac os', 'macos'):
if key in agent:
self.os_selected = 'macosx'
break
if not self.os_selected:
for key in ('windows', 'net clr'):
if key in agent:
self.os_selected = 'windows'
break
if not self.os_selected:
for key in ('freebsd', 'bsd'):
if key in agent:
self.os_selected = 'freebsd'
break
if not self.os_selected:
for key in ('sunos', 'solaris'):
if key in agent:
self.os_selected = 'source'
break
if not self.os_selected:
self.os_selected = 'source'
# Build the widget content
self.combo = CTK.Combobox ({'style': 'display:none;', 'selected': self.os_selected}, OS_OPTIONS)
self += self.combo
for e in OS_OPTIONS:
code, name = e
img = self.OS_Icon (code, name, self.os_selected)
img.bind ('click', "$('#%s').val('%s').trigger('change'); $('.os-selected').removeClass('os-selected'); $(this).addClass('os-selected');"%(self.combo.id, code))
self += img
class Download_MacOSX:
def __call__ (self):
# Find the DMG file
dmg_refs = Downloads.get_latest_macosx_dmg()
# No MacOS package found
if not dmg_refs:
content = CTK.Container()
content += CTK.RawHTML ("<h3>%s</h3>" %(_("Could not find the MacOS X package")))
content += CTK.RawHTML ("<p>%s</p>" %(_("It seems that the MacOS X package for the latest version has not been compiled yet.")))
content += CTK.RawHTML ("<p>%s</p>" %(_("Due the circunstances, we encourage you to download the source code and compile it by hand.")))
return CTK.HTTP_Cacheable (60, body = content.Render().toStr())
dmg_local, dmg_web = dmg_refs
dmg_url = "http://www.cherokee-project.com%s"%(dmg_web)
if os.path.exists (dmg_local):
mbs = os.path.getsize (dmg_local) / (1024**2)
else:
mbs = 0
ver = re.findall (r'(\d+\.\d+\.\d+)', dmg_web)[0]
download_button = CTK.Button ('Get Cherokee %s DMG'%(ver)) # ??? %sMb'%(mbs))
download_button.bind ('click', CTK.DruidContent__JS_to_goto (download_button.id, URL_MACOSX_2))
content = CTK.Container()
content += CTK.RawHTML ('<h3>Binary Package</h3>')
content += CTK.RawHTML ('<p>%s</p>'%(_("A binary package for MacOS X (Intel) is available for download: %sMb"%(mbs))))
content += download_button
return CTK.HTTP_Cacheable (60, body=content.Render().toStr())
class Download_MacOSX_2:
def __call__ (self):
content = CTK.Box({'id': 'macosx-steps'})
content += CTK.RawHTML ('<h3>MacOS X (Intel)</h3>')
# Find the DMG file
dmg_refs = Downloads.get_latest_macosx_dmg()
dmg_local, dmg_web = dmg_refs
dmg_url = "http://www.cherokee-project.com%s"%(dmg_web)
content += CTK.RawHTML (js='setTimeout(function(){ %s }, 2000);' %(CTK.JS.GotoURL(dmg_url)))
# Step 1
box = CTK.Box({'class': 'macosx-step'})
box += CTK.Image({'src': "/static/images/dmg1.png"})
box += CTK.RawHTML ('<strong>%s</strong>' %(_("Step 1")))
box += CTK.RawHTML ('<span>%s</span>' %(_("Save and Open the Cherokee installer")))
content += box
# Step 2
box = CTK.Box({'class': 'macosx-step'})
box += CTK.Image({'src': "/static/images/dmg2.png"})
box += CTK.RawHTML ('<strong>%s</strong>' %(_("Step 2")))
box += CTK.RawHTML ('<span>%s</span>' %(_("Install the package")))
content += box
# Step 3
box = CTK.Box({'class': 'macosx-step'})
box += CTK.Image({'src': "/static/images/dmg3.png"})
box += CTK.RawHTML ('<strong>%s</strong>' %(_("Step 3")))
box += CTK.RawHTML ('<span>%s</span>' %(_("Drag Cherokee Admin to your application folder")))
content += box
# Step 4
box = CTK.Box({'class': 'macosx-step'})
box += CTK.Image({'src': "/static/images/dmg4.png"})
box += CTK.RawHTML ('<strong>%s</strong>' %(_("Step 4")))
box += CTK.RawHTML ('<span>%s</span>' %(_("Open Cherokee Admin")))
content += box
return CTK.HTTP_Cacheable (60, body=content.Render().toStr())
class Download_Source:
def __call__ (self):
tarball_refs = Downloads.get_latest_tarball()
tar_local, tar_web = tarball_refs
# Automatic
content = CTK.Container()
content += CTK.RawHTML ("<h3>%s</h3>" %(_("Option 1: Automatic installation")))
box = CTK.Box()
box += CTK.RawHTML ('<p>%s</p>' %(_('Open a terminal and enter:')))
box += CTK.RawHTML ('<pre class="terminal">wget http://cherokee-project.com/install && python install</pre>')
box += CTK.RawHTML ('<p>%s</p>' %(_('or')))
box += CTK.RawHTML ('<pre class="terminal">curl -LO http://cherokee-project.com/install && python install</pre>')
box += CTK.RawHTML ('<p>%s</p>' %(_('This will download and install Cherokee under /opt/cherokee')))
content += box
# By hand
content += CTK.RawHTML ("<h3>%s</h2>" %(_("Option 2: Compile it by hand")))
sources = CTK.Box()
sources += CTK.RawHTML ('%s '%(_("Download")))
sources += CTK.Link (tar_web, CTK.RawHTML (_("latest source code package")))
sources += CTK.RawHTML (', and install it by hand doing the <i>./configure, make, make install</i> dance.')
sources += CTK.RawHTML ('<pre class="terminal">configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc<br/>make && sudo make install</pre>')
sources += CTK.RawHTML ('Older releases are also available at our <a href="/download/">Downloads archive</a>.')
content += sources
return CTK.HTTP_Cacheable (60, body=content.Render().toStr())
class Download_Windows:
def __call__ (self):
content = CTK.Container()
content += CTK.RawHTML ("<h3>%s</h3>" %(_("The Windows port is an ongoing effort...")))
content += CTK.RawHTML ("<p>%s</p>" %(_('Even though the source code of the Cherokee Web Server can be compiled on Windows (<i>with the mingw + msys</i>), it is not stable enough to be considered production ready.')))
content += CTK.RawHTML ("<p>%s</p>" %(_('Developers are welcome to join the effort of finishing the port of Cherokee to Windows. Do not hesitate to <a href="http://git.cherokee-project.com/" target="_blank">join us</a>!')))
return CTK.HTTP_Cacheable (60, body=content.Render().toStr())
class Download_FreeBSD:
def __call__ (self):
content = CTK.Container()
# FreeBSD
box = CTK.Box({'class': 'platform', 'id': 'platform-freebsd'})
box += CTK.RawHTML ('<h3>FreeBSD</h3>')
box += CTK.RawHTML ('Open a terminal and enter:')
box += CTK.RawHTML ('<pre class="terminal">sudo cd /usr/ports/www/cherokee && make install clean</pre>')
box += CTK.RawHTML ('If using pkgng:')
box += CTK.RawHTML ('<pre class="terminal">sudo pkg install cherokee</pre>')
box += CTK.RawHTML ("If you just want the package:")
box += CTK.RawHTML ('<pre class="terminal">sudo pkg_add -r cherokee (Will soon be defuncted) </pre>')
content += box
return CTK.HTTP_Cacheable (60, body=content.Render().toStr())
class Download_Linux:
# Ubuntu
box = CTK.Box({'class': 'platform', 'id': 'platform-ubuntu'})
box += CTK.RawHTML ('<h3>Ubuntu</h3>')
box += CTK.RawHTML ('Open a terminal and enter:')
box += CTK.RawHTML ('<pre class="terminal">sudo add-apt-repository ppa:cherokee-webserver/ppa</pre>')
box += CTK.RawHTML ('After that, you should tell your system to pull down the latest list of software from each archive it knows about, including the PPA you just added:')
box += CTK.RawHTML ('<pre class="terminal">sudo apt-get update</pre>')
box += CTK.RawHTML ("Now you're ready to install Cherokee from the PPA:")
box += CTK.RawHTML ('<pre class="terminal">sudo apt-get install cherokee cherokee-admin</pre>')
content += box
# Debian
box = CTK.Box({'class': 'platform', 'id': 'platform-debian'})
box += CTK.RawHTML ('<h3>Debian</h3>')
box += CTK.RawHTML ('Install Cherokee from the apt repository')
box += CTK.RawHTML ('<pre class="terminal">apt-get install cherokee cherokee-admin</pre>')
details = CTK.Box({'class': 'platform-details'})
details += CTK.RawHTML ('%s '%(_('Please, check the documentation for further')))
details += CTK.LinkWindow (DOC_APTGET, CTK.RawHTML(_('details')))
details += CTK.RawHTML ('.')
box += details
content += box
#EPEL
box = CTK.Box({'class': 'platform', 'id': 'platform-epel'})
box += CTK.RawHTML ('<h3>Red Hat Enterprise Linux (RHEL)/CentOS</h3>')
box += CTK.RawHTML ('Install Cherokee from the EPEL (Extra Packages for Enterprise Linux) repository')
box += CTK.RawHTML ('<pre class="terminal">yum install cherokee</pre>')
details = CTK.Box({'class': 'platform-details'})
details += CTK.RawHTML ('Check the ')
details += CTK.LinkWindow (DOC_EPEL_URL, CTK.RawHTML('EPEL documentation'))
details += CTK.RawHTML (' for details on making EPEL repositories available on your system.')
box += details
content += box
#Fedora
box = CTK.Box({'class': 'platform', 'id': 'platform-fedora'})
box += CTK.RawHTML ('<h3>Fedora</h3>')
box += CTK.RawHTML ('Install Cherokee from Fedora\'s Yum repository')
box += CTK.RawHTML ('<pre class="terminal">yum install cherokee</pre>')
details = CTK.Box({'class': 'platform-details'})
details += CTK.RawHTML ('See Fedora\'s ')
details += CTK.LinkWindow (DOC_FEDORA_PACKAGE_URL, CTK.RawHTML('package information'))
details += CTK.RawHTML (' for later versions than what\'s included with the latest distribution.')
box += details
content += box
return CTK.HTTP_Cacheable (60, body=content.Render().toStr())
class Development_Version (CTK.Box):
def __init__ (self):
CTK.Box.__init__ (self, {'class': 'download-svn-box'})
self += CTK.RawHTML ('<h2>%s</h2>' %("Development Snapshots"))
self += CTK.RawHTML ("You can also retrieve the current development sources ")
self += CTK.LinkWindow ("https://github.com/cherokee/webserver", CTK.RawHTML ("using Git"))
self += CTK.RawHTML (" or downloading the ")
self += CTK.Link ("/download/trunk/cherokee-latest-snapshot.tar.gz", CTK.RawHTML ("latest snapshot"))
self += CTK.RawHTML (".")
class QuickStart:
def __call__ (self):
title = _("Quickstart Guide")
# Install Cherokee
os_combo = OS_Panel()
druid = CTK.Druid (CTK.RefreshableURL ('%s/%s'%(URL_BASE, os_combo.os_selected)))
box = CTK.Box ({'id': 'platform-box'})
box += os_combo
step1 = CTK.Box({'id': 'qs-step-1', 'class': 'qs-step'})
step1 += box
step1 += CTK.RawHTML ("<h1>%s</h1>" %(title))
step1 += CTK.RawHTML ('<h2>%s</h2>' %(_("Install Cherokee")))
step1 += druid
os_combo.bind ('change', druid.JS_to_goto('"%s/"+$("#%s").val()' %(URL_BASE, os_combo.combo.id)))
# Page
page = Page.Page_Menu_Side (title=title)
page += step1
# Development version
page.sidebar += Development_Version()
# Mirros
mirrors = Mirror_Sites.Mirrors()
page.sidebar += mirrors
# This page cannot be cached. It'd break the OS detection.
return page.Render()
CTK.publish (r'^%s(\.html)?$'%(URL_BASE), QuickStart)
CTK.publish (r'^%s' %(URL_MACOSX), Download_MacOSX)
CTK.publish (r'^%s/2'%(URL_MACOSX), Download_MacOSX_2)
CTK.publish (r'^%s' %(URL_LINUX), Download_Linux)
CTK.publish (r'^%s' %(URL_FREEBSD), Download_FreeBSD)
CTK.publish (r'^%s' %(URL_SOURCE), Download_Source)
CTK.publish (r'^%s' %(URL_WINDOWS), Download_Windows)