예제 #1
0
파일: elements.py 프로젝트: oubiwann/tharsk
    def dictionaryTabs(self, request, tag):
        """
        The code in this method generates HTML similar to the following,
        producing the left-hand side tabs for browsing a dictionary:

          <div class="tabbable tabs-left">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#lA" data-toggle="tab">a</a></li>
              <li><a href="#lB" data-toggle="tab">b</a></li>
              <li><a href="#lC" data-toggle="tab">c</a></li>
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="lA">
                <p>I'm in Section A.</p>
              </div>
              <div class="tab-pane" id="lB">
                <p>Howdy, I'm in Section B.</p>
              </div>
              <div class="tab-pane" id="lC">
                <p>What up girl, this is Section C.</p>
              </div>
            </div>
          </div> <!-- /tabbable -->
        """
        def generateTabsAndContent(results):
            """
            results is a dictionary whose keys are normalized ASCII chars and
            whose values are the original (possible unicode) chars that map to
            the ASCII ones.
            """
            tabs = []
            contents = []
            for asciiLetter in sorted(results.keys()):
                if not asciiLetter:
                    continue
                for letter in sorted(results[asciiLetter]):
                    tab = tags.li(
                        tags.a(
                            letter.upper(),
                            href="#l%s" % letter,
                            **{"data-toggle": "tab"})
                        )
                    tabs.append(tab)
                    content = tags.div(
                        tags.p("holding content"),
                        class_="tab-pane",
                        id="l%s" % letter)
                    contents.append(content)

            return tags.div(
                tags.ul(tabs, class_="nav nav-tabs"),
                tags.div(contents, class_="tab-content"),
                class_="tabbable tabs-left")

        dictId = os.path.basename(request.path)
        model = collection.dictionaryFactoryV1(dictId)
        d = retrieve.getAlphabet(model)
        d.addCallback(generateTabsAndContent)
        return d
예제 #2
0
    def getAlphabet(self):
        def logResults(letters, model):
            letters = " ".join([x.encode("utf-8") for x in letters])
            log.msg("%s alphabet: %s" % (model.title, letters))

        # XXX add support for getting the English alphabet for this dictionry
        model = self.modelClass()
        d = retrieve.getAlphabet(model)
        d.addCallback(logResults, model)
        return d
예제 #3
0
파일: elements.py 프로젝트: oubiwann/tharsk
    def dictionaryTabs(self, request, tag):
        """
        The code in this method generates HTML similar to the following,
        producing the left-hand side tabs for browsing a dictionary:

          <div class="tabbable tabs-left">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#lA" data-toggle="tab">a</a></li>
              <li><a href="#lB" data-toggle="tab">b</a></li>
              <li><a href="#lC" data-toggle="tab">c</a></li>
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="lA">
                <p>I'm in Section A.</p>
              </div>
              <div class="tab-pane" id="lB">
                <p>Howdy, I'm in Section B.</p>
              </div>
              <div class="tab-pane" id="lC">
                <p>What up girl, this is Section C.</p>
              </div>
            </div>
          </div> <!-- /tabbable -->
        """
        def generateTabsAndContent(results):
            """
            results is a dictionary whose keys are normalized ASCII chars and
            whose values are the original (possible unicode) chars that map to
            the ASCII ones.
            """
            tabs = []
            contents = []
            for asciiLetter in sorted(results.keys()):
                if not asciiLetter:
                    continue
                for letter in sorted(results[asciiLetter]):
                    tab = tags.li(
                        tags.a(letter.upper(),
                               href="#l%s" % letter,
                               **{"data-toggle": "tab"}))
                    tabs.append(tab)
                    content = tags.div(tags.p("holding content"),
                                       class_="tab-pane",
                                       id="l%s" % letter)
                    contents.append(content)

            return tags.div(tags.ul(tabs, class_="nav nav-tabs"),
                            tags.div(contents, class_="tab-content"),
                            class_="tabbable tabs-left")

        dictId = os.path.basename(request.path)
        model = collection.dictionaryFactoryV1(dictId)
        d = retrieve.getAlphabet(model)
        d.addCallback(generateTabsAndContent)
        return d
예제 #4
0
파일: async.py 프로젝트: oubiwann/tharsk
    def getAlphabet(self):

        def logResults(letters, model):
            letters = " ".join([x.encode("utf-8") for x in letters])
            log.msg("%s alphabet: %s" % (model.title, letters))

        # XXX add support for getting the English alphabet for this dictionry
        model = self.modelClass()
        d = retrieve.getAlphabet(model)
        d.addCallback(logResults, model)
        return d