Esempio n. 1
0
    def get(self):
        locale = getUserLocale(self.request.GET.get("locale"), self.request.headers.get("accept_language"))
        i18n.get_i18n().set_locale(locale)

        titleword = u""
        mainviewDivInnerHTML = None
        if self.request.path.startswith("/canon"):
            if isValidCanonUrl(self.request.path):
                titleword = getTitleInfo(self.request.path)
                mainviewDivInnerHTML = getMainViewInnerHTML(self.request.path)
            else:
                self.error(404)
                self.response.out.write("Page Not Found!")
                return

        devjs = self.request.GET.get("devjs")
        if devjs not in ["yes", "no"]:
            devjs = None
        if devjs == None:
            if os.environ["SERVER_SOFTWARE"].startswith("Development"):
                devjs = "yes"
            else:
                devjs = "no"

        template_values = {
            "titleword": titleword,
            "locale": "%s~%s" % (locale, self.request.headers.get("accept_language")),
            "mainviewDivInnerHTML": mainviewDivInnerHTML,
            "devjs": devjs,
        }

        template = jinja_environment.get_template("index.html")
        self.response.out.write(template.render(template_values))
Esempio n. 2
0
File: main.py Progetto: sup6/pali
    def get(self, prefix=None, word=None):
        locale = getUserLocale(self.request.GET.get('locale'),
                               self.request.headers.get('accept_language'))
        i18n.get_i18n().set_locale(locale)
        #browser = self.request.headers.get('user_agent')

        titleword = u''
        resultDivInnerHTML = None
        if self.request.path.startswith('/browse'):
            if isValidPrefixAndWord(prefix, word, dicPrefixWordLists):
                if (word == None):
                    if (prefix != None):
                        # build prefix HTML here
                        titleword = u'browse words with prefix ' + prefix.decode(
                            'utf-8') + u' - '
                        resultDivInnerHTML = getPrefixHTML(
                            prefix, dicPrefixWordLists)
                else:
                    # build word HTML here
                    titleword = word.decode(
                        'utf-8') + u' - definition and meaning - '
                    resultDivInnerHTML = getWordHTML(word, jsonpLookup(word),
                                                     i18n)
            else:
                self.error(404)
                self.response.out.write("Page Not Found!")
                return

        compiledBootstrapJS = self.request.GET.get('compiledBootstrapJS')
        if compiledBootstrapJS not in ['yes', 'no']:
            compiledBootstrapJS = None
        if (compiledBootstrapJS == None):
            if os.environ['SERVER_SOFTWARE'].startswith("Development"):
                compiledBootstrapJS = 'no'
            else:
                compiledBootstrapJS = 'yes'

        template_values = {
            'titleword':
            titleword,
            'locale':
            '%s~%s' % (locale, self.request.headers.get('accept_language')),
            'compiledBootstrapJS':
            compiledBootstrapJS,
            'resultDivInnerHTML':
            resultDivInnerHTML
        }

        template = jinja_environment.get_template('index.html')
        self.response.out.write(template.render(template_values))
Esempio n. 3
0
  def get(self, prefix=None, word=None):
    locale = getUserLocale(self.request.GET.get('locale'),
                           self.request.headers.get('accept_language'))
    i18n.get_i18n().set_locale(locale)
    #browser = self.request.headers.get('user_agent')

    titleword = u''
    resultDivInnerHTML = None
    if self.request.path.startswith('/browse'):
      if isValidPrefixAndWord(prefix, word, dicPrefixWordLists):
        if (word == None):
          if (prefix != None):
            # build prefix HTML here
            titleword = u'browse words with prefix ' + prefix.decode('utf-8') + u' - '
            resultDivInnerHTML = getPrefixHTML(prefix, dicPrefixWordLists)
        else:
          # build word HTML here
          titleword = word.decode('utf-8') + u' - definition and meaning - '
          resultDivInnerHTML = getWordHTML(word, jsonpLookup(word), i18n)
      else:
        self.error(404)
        self.response.out.write("Page Not Found!")
        return

    compiledBootstrapJS = self.request.GET.get('compiledBootstrapJS')
    if compiledBootstrapJS not in ['yes', 'no']:
      compiledBootstrapJS = None
    if (compiledBootstrapJS == None):
      if os.environ['SERVER_SOFTWARE'].startswith("Development"):
        compiledBootstrapJS = 'no'
      else:
        compiledBootstrapJS = 'yes'

    template_values = {
      'titleword' : titleword,
      'locale' : '%s~%s' % (locale, self.request.headers.get('accept_language')),
      'compiledBootstrapJS' : compiledBootstrapJS,
      'resultDivInnerHTML' : resultDivInnerHTML
    }

    template = jinja_environment.get_template('index.html')
    self.response.out.write(template.render(template_values))
Esempio n. 4
0
    def get(self):
        locale = getUserLocale(self.request.GET.get('locale'),
                               self.request.headers.get('accept_language'))
        i18n.get_i18n().set_locale(locale)

        titleword = u''
        mainviewDivInnerHTML = None
        if self.request.path.startswith('/canon'):
            if isValidCanonUrl(self.request.path):
                titleword = getTitleInfo(self.request.path)
                mainviewDivInnerHTML = getMainViewInnerHTML(self.request.path)
            else:
                self.error(404)
                self.response.out.write("Page Not Found!")
                return

        devjs = self.request.GET.get('devjs')
        if devjs not in ['yes', 'no']:
            devjs = None
        if devjs == None:
            if os.environ['SERVER_SOFTWARE'].startswith("Development"):
                devjs = 'yes'
            else:
                devjs = 'no'

        template_values = {
            'titleword':
            titleword,
            'locale':
            '%s~%s' % (locale, self.request.headers.get('accept_language')),
            'mainviewDivInnerHTML':
            mainviewDivInnerHTML,
            'devjs':
            devjs
        }

        template = jinja_environment.get_template('index.html')
        self.response.out.write(template.render(template_values))