Skip to content

Commit a3e9f0f

Browse files
committed
change default appspot domain and fix setup bug
1 parent a92a8f7 commit a3e9f0f

File tree

9 files changed

+35
-45
lines changed

9 files changed

+35
-45
lines changed

dictionary/app/partials/buttons.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<div class="floating-buttons">
22
<div>
3-
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://dictionary.online-dhamma.net/" data-count="vertical">Tweet</a>
3+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="{$ dicWebAppUrl $}" data-count="vertical">Tweet</a>
44
</div>
55
<!-- Place this tag where you want the +1 button to render -->
6-
<div class="g-plusone" data-size="tall" data-href="http://dictionary.online-dhamma.net/"></div>
6+
<div class="g-plusone" data-size="tall" data-href="{$ dicWebAppUrl $}"></div>
77
<!-- Place the code for your plugin wherever you want the plugin to appear on your page. -->
8-
<div class="fb-like" data-href="http://dictionary.online-dhamma.net/" data-send="true" data-layout="box_count" data-show-faces="true"></div>
8+
<div class="fb-like" data-href="{$ dicWebAppUrl $}" data-send="true" data-layout="box_count" data-show-faces="true"></div>
99
</div>
1010

1111
<!-- Place this render call where appropriate -->

dictionary/mainweb.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,23 @@
4343
r"/browse/([^/]+)", "PrefixPage",
4444
)
4545

46+
47+
def RedirectToNewDomain(oldDomain, newDomain):
48+
if web.ctx.host.split(':')[0] == oldDomain:
49+
url = newDomain + urllib.quote(web.ctx.path.encode('utf-8')) + web.ctx.query
50+
raise web.redirect(url)
51+
4652
def commonTemplateValues(urlLocale, reqHandlerName, prefix=None, word=None):
4753
userLocale = getLocale(urlLocale, web.ctx.env.get('HTTP_ACCEPT_LANGUAGE'))
4854
i18n.setLocale(userLocale)
4955
template_values = {
5056
# 'serverEnv': 'ec2',
5157
# 'tpkWebAppUrl': 'http://tipitaka.sutta.org/',
5258
'serverEnv': 'appspot',
53-
# 'tpkWebAppUrl': 'http://epalitipitaka.appspot.com/',
54-
'tpkWebAppUrl': 'http://tipitaka.online-dhamma.net/',
59+
'tpkWebAppUrl': 'http://epalitipitaka.appspot.com/',
60+
'dicWebAppUrl': 'http://palidictionary.appspot.com/',
61+
# 'tpkWebAppUrl': 'http://tipitaka.online-dhamma.net/',
62+
# 'dicWebAppUrl': 'http://dictionary.online-dhamma.net/',
5563
'htmlTitle': getHtmlTitle(userLocale, reqHandlerName, i18n, prefix, word),
5664
'userLocale': userLocale,
5765
'locales': json.dumps(i18n.locales),
@@ -65,25 +73,11 @@ def commonTemplateValues(urlLocale, reqHandlerName, prefix=None, word=None):
6573

6674
class MainPage:
6775
def GET(self, urlLocale=None):
68-
if web.ctx.host.split(':')[0] == "palidictionary.appspot.com":
69-
# redirect to new domain
70-
url = "http://dictionary.online-dhamma.net" + \
71-
urllib.quote(web.ctx.path.encode('utf-8')) + \
72-
web.ctx.query
73-
raise web.redirect(url)
74-
7576
template_values = commonTemplateValues(urlLocale, self.__class__.__name__)
7677
template = jinja_environment.get_template('index.html')
7778
return template.render(template_values)
7879

7980
def commonPage(prefix, word, reqHandlerName, urlLocale=None):
80-
if web.ctx.host.split(':')[0] == "palidictionary.appspot.com":
81-
# redirect to new domain
82-
url = "http://dictionary.online-dhamma.net" + \
83-
urllib.quote(web.ctx.path.encode('utf-8')) + \
84-
web.ctx.query
85-
raise web.redirect(url)
86-
8781
if type(prefix) is not unicode:
8882
prefix = prefix.decode('utf-8')
8983

dictionary/serviceweb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def GET(self, word):
2828

2929
class robots:
3030
def GET(self):
31-
if web.ctx.host == 'dictionary.online-dhamma.net':
31+
if web.ctx.host == 'palidictionary.appspot.com':
3232
return 'User-agent: *\nDisallow: /wordJson/\n'
3333
return 'User-agent: *\nDisallow: /'
3434

tipitaka/app.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ skip_files:
6161
- ^(.*/)?app/scripts/.*
6262
- ^(.*/)?app/css/app\.css
6363
- ^(.*/)?app/css/tipitaka-latn\.css
64-
- ^(.*/)?pylib/romn/.*
64+
#- ^(.*/)?pylib/romn/.*
65+
- ^(.*/)?pylib/romn/.*\.xml
6566
- ^(.*/)?setup/.*
6667
- ^(.*/)?node_modules/.*
6768
- ^(.*/)?build/.*

tipitaka/app/partials/buttons.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div class="floating-buttons">
2-
<div class="g-plusone" data-size="tall" data-href="http://tipitaka.online-dhamma.net/"></div>
3-
<div class="fb-like" data-href="http://tipitaka.online-dhamma.net/" data-send="true" data-layout="box_count" data-show-faces="true"></div>
2+
<div class="g-plusone" data-size="tall" data-href="{$ tpkWebAppUrl $}"></div>
3+
<div class="fb-like" data-href="{$ tpkWebAppUrl $}" data-send="true" data-layout="box_count" data-show-faces="true"></div>
44
<div>
5-
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://tipitaka.online-dhamma.net/" data-count="vertical">Tweet</a>
5+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="{$ tpkWebAppUrl $}" data-count="vertical">Tweet</a>
66
</div>
77
</div>
88
<!-- Place this tag after the last +1 button tag. -->

tipitaka/mainweb.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,21 @@
4141
)
4242

4343

44+
def RedirectToNewDomain(oldDomain, newDomain):
45+
if web.ctx.host.split(':')[0] == oldDomain:
46+
url = newDomain + urllib.quote(web.ctx.path.encode('utf-8')) + web.ctx.query
47+
raise web.redirect(url)
48+
4449
def commonTemplateValues(urlLocale, userLocale):
4550
i18n.setLocale(userLocale)
4651
template_values = {
4752
# 'serverEnv': 'ec2',
4853
# 'dicWebAppUrl': 'http://dictionary.sutta.org/',
4954
'serverEnv': 'appspot',
50-
# 'dicWebAppUrl': 'http://palidictionary.appspot.com/',
51-
'dicWebAppUrl': 'http://dictionary.online-dhamma.net/',
55+
'tpkWebAppUrl': 'http://epalitipitaka.appspot.com/',
56+
'dicWebAppUrl': 'http://palidictionary.appspot.com/',
57+
# 'tpkWebAppUrl': 'http://tipitaka.online-dhamma.net/',
58+
# 'dicWebAppUrl': 'http://dictionary.online-dhamma.net/',
5259
'htmlTitle': u'',
5360
'userLocale': userLocale,
5461
'locales': json.dumps(i18n.locales),
@@ -62,13 +69,6 @@ def commonTemplateValues(urlLocale, userLocale):
6269

6370

6471
def commonPage(paliTextPath, translationLocale=None, translator=None, urlLocale=None):
65-
if web.ctx.host.split(':')[0] == "epalitipitaka.appspot.com":
66-
# redirect to new domain
67-
url = "http://tipitaka.online-dhamma.net" + \
68-
urllib.quote(web.ctx.path.encode('utf-8')) + \
69-
web.ctx.query
70-
raise web.redirect(url)
71-
7272
userLocale = getLocale(urlLocale, web.ctx.env.get('HTTP_ACCEPT_LANGUAGE'))
7373
result = checkPath(web.ctx.path, urlLocale, paliTextPath,
7474
userLocale, translationLocale, translator)
@@ -82,13 +82,6 @@ def commonPage(paliTextPath, translationLocale=None, translator=None, urlLocale=
8282

8383

8484
def commonMainPage(urlLocale=None):
85-
if web.ctx.host.split(':')[0] == "epalitipitaka.appspot.com":
86-
# redirect to new domain
87-
url = "http://tipitaka.online-dhamma.net" + \
88-
urllib.quote(web.ctx.path.encode('utf-8')) + \
89-
web.ctx.query
90-
raise web.redirect(url)
91-
9285
userLocale = getLocale(urlLocale, web.ctx.env.get('HTTP_ACCEPT_LANGUAGE'))
9386
template_values = commonTemplateValues(urlLocale, userLocale)
9487
template_values['isIncludeAbout'] = True

tipitaka/pylib/xml2html.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ def getTranslationXmlUrl(action, translationLocale, translator):
3838
class XmlBlobKey(ndb.Model):
3939
blob_key = ndb.BlobKeyProperty()
4040

41-
xslt_root = etree.parse(blobstore.BlobReader(
42-
XmlBlobKey.get_by_id('cscd/tipitaka-latn.xsl').blob_key))
41+
#xslt_root = etree.parse(blobstore.BlobReader(
42+
# XmlBlobKey.get_by_id('cscd/tipitaka-latn.xsl').blob_key))
43+
with open(getCanonXmlUrl('cscd/tipitaka-latn.xsl'), 'r') as f:
44+
xslt_root = etree.parse(f)
4345

4446
def paliXslt(action):
4547
return xslt(blobstore.BlobReader(XmlBlobKey.get_by_id(action).blob_key))

tipitaka/serviceweb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def GET(self, word):
6565

6666
class robots:
6767
def GET(self):
68-
if web.ctx.host == 'tipitaka.online-dhamma.net':
68+
if web.ctx.host == 'http://epalitipitaka.appspot.com/':
6969
return 'User-agent: *\nDisallow: /html/\n'
7070
return 'User-agent: *\nDisallow: /'
7171

tipitaka/setup/init4uploadToGAE.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def uploadXmlsToBlobstore():
6464
for dirpath, dirnames, filenames in os.walk(romn_dir):
6565
for filename in filenames:
6666
path = os.path.join(dirpath, filename)
67-
key = path[len(romn_dir)+1:]
67+
key = path[len(romn_dir):]
6868
print('uploading %s ...' % key)
6969
with open(path, 'rb') as f:
7070
# Create the file
@@ -101,7 +101,7 @@ def uploadXmlsViaCustomRemoteBlobstoreAPI():
101101
for dirpath, dirnames, filenames in os.walk(romn_dir):
102102
for filename in filenames:
103103
path = os.path.join(dirpath, filename)
104-
key = path[len(romn_dir)+1:]
104+
key = path[len(romn_dir):]
105105
print('uploading %s ...' % key)
106106

107107
"""Python HTTP POST json-format data (payload is encoded with base64).

0 commit comments

Comments
 (0)