コード例 #1
0
ファイル: routes.py プロジェクト: cnspica/wkk
def save(note, data):
    html = data['html']

    if parsers.remove_html(html):
        path_new = os.path.join(data['new[notebook]'],
                                data['new[title]'] + note.ext)

        # If the title or notebook has changed,
        # move the note by updating its path.
        if note.path.abs != path_new:
            try:
                note.move(path_new)
            except NoteConflictError:
                # 409 = Conflict
                return 'Note already exists', 409

        html = parsers.rewrite_external_images(html, note)

        if note.ext == '.md':
            content = html2md.html_to_markdown(html)

        note.write(content)
        note.clean_resources()

        # Update all connected clients.
        #self.refresh_clients()

        return jsonify({'path': note.path.abs})
    return 'Success', 200
コード例 #2
0
ファイル: routes.py プロジェクト: 447327642/wkk
def save(note, data):
    html = data['html']

    if parsers.remove_html(html):
        path_new = os.path.join(data['new[notebook]'], data['new[title]'] + note.ext)

        # If the title or notebook has changed,
        # move the note by updating its path.
        if note.path.abs != path_new:
            try:
                note.move(path_new)
            except NoteConflictError:
                # 409 = Conflict
                return 'Note already exists', 409

        html = parsers.rewrite_external_images(html, note)

        if note.ext == '.md':
            content = html2md.html_to_markdown(html)

        note.write(content)
        note.clean_resources()

        # Update all connected clients.
        #self.refresh_clients()

        return jsonify({
            'path': note.path.abs
        })
    return 'Success', 200
コード例 #3
0
ファイル: models.py プロジェクト: 447327642/wkk
    def plaintext(self):
        text = u''
        if self.ext == '.pdf':
            text = self.content

        else:
            if self.ext == '.html':
                text = parsers.remove_html(self.content)
            elif self.ext == '.md':
                text = parsers.remove_md(self.content)

        if isinstance(text, str):
            text = text.decode('utf-8')

        return text
コード例 #4
0
    def plaintext(self):
        text = u''
        if self.ext == '.pdf':
            text = self.content

        else:
            if self.ext == '.html':
                text = parsers.remove_html(self.content)
            elif self.ext == '.md':
                text = parsers.remove_md(self.content)

        if isinstance(text, str):
            text = text.decode('utf-8')

        return text