예제 #1
0
def add_bookmark():
    form = BookmarkForm(request.json, create=True)
    ret = None
    if form.validate_on_submit():
        # register form
        service.add_bookmark(form.bookmark)
        ret = ["OK"]
    else:
        ret = form.errors
    return jsonify(ret)
예제 #2
0
def add_bookmark():
    form = BookmarkForm(request.json, create=True)
    ret = None
    if form.validate_on_submit():
        # register form
        service.add_bookmark(form.bookmark)
        ret = ["OK"]
    else:
        ret = form.errors
    return jsonify(ret)
예제 #3
0
def reset_all(json_file):
    db.drop_all()
    db.create_all()

    items = json.loads(open(json_file).read())
    for item in items:
        i = ItemBookmark(ptags=item['tags'],
            plink=item['link'], ptitle=item['title'],
            pdescription=item['description'], json=True)
        add_bookmark(i)
예제 #4
0
def reset_all(json_file):
    db.drop_all()
    db.create_all()

    items = json.loads(open(json_file).read())
    for item in items['bookmarks']:
        i = ItemBookmark(**item)
        add_bookmark(i)
    for item in items['users']:
        i = User(**item)
        add_user(i)
예제 #5
0
def reset_all(json_file):
    db.drop_all()
    db.create_all()

    items = json.loads(open(json_file).read())
    for item in items:
        i = ItemBookmark(ptags=item['tags'],
                         plink=item['link'],
                         ptitle=item['title'],
                         pdescription=item['description'],
                         json=True)
        add_bookmark(i)
예제 #6
0
def add_bookmark():
    form = BookmarkForm(request.json)
    ret = None
    if form.validate_on_submit():
        try:
            service.add_bookmark(form.bookmark)
            ret = {}
        except IntegrityError, e:
            errors = []
            if e.message == '(IntegrityError) column link is not unique':
                errors.append("Link alredy exists")
            ret = {
                "errors": {
                    "link": errors,
                }
            }
예제 #7
0
import argparse
from lxml.html.soupparser import fromstring
from bookmark.blueprint.api.item.Bookmark import ItemBookmark
from bookmark.service import add_bookmark

parser = argparse.ArgumentParser(description='Delicious bookmark import')
parser.add_argument('path', type=str, help='path to delicious.html file')

args = parser.parse_args()
path = args.path

content = open(path).read()
xml = fromstring(content)

for link in xml.xpath("/html/dl/dt/a"):
    item = {
        "title": link.text,
        "link": link.get("href"),
        "description": "",
        "tags": [{"name": x.strip(),} for x in link.get("tags").split(',')]
    }
    i = ItemBookmark(**item)
    add_bookmark(i)


예제 #8
0
import argparse
from lxml.html.soupparser import fromstring
from bookmark.blueprint.api.item.Bookmark import ItemBookmark
from bookmark.service import add_bookmark

parser = argparse.ArgumentParser(description='Delicious bookmark import')
parser.add_argument('path', type=str, help='path to delicious.html file')

args = parser.parse_args()
path = args.path

content = open(path).read()
xml = fromstring(content)

for link in xml.xpath("/html/dl/dt/a"):
    item = {
        "title": link.text,
        "link": link.get("href"),
        "description": "",
        "tags": [{
            "name": x.strip(),
        } for x in link.get("tags").split(',')]
    }
    i = ItemBookmark(**item)
    add_bookmark(i)