-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from mkouhei/devel
release 0.3.0
- Loading branch information
Showing
41 changed files
with
1,277 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ shiori/static/twbs | |
shiori/static/underscore | ||
.tox | ||
.coverage | ||
dummy_*.json | ||
celerybeat-schedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
language: python | ||
python: 2.7 | ||
before_script: | ||
- pip install python-coveralls | ||
env: | ||
- TOX_ENV=py27 | ||
install: | ||
- pip install coveralls tox | ||
script: | ||
- python setup.py test | ||
- tox -e $TOX_ENV | ||
after_success: | ||
- coveralls | ||
- coveralls --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.contrib import admin | ||
from shiori.bookmark.models import Bookmark, Category, Tag, BookmarkTag | ||
from shiori.bookmark.models import (Bookmark, | ||
Category, | ||
Tag, | ||
BookmarkTag, | ||
FeedSubscription, | ||
CrawlingHistory) | ||
|
||
|
||
admin.site.register(Bookmark) | ||
class BookmarkAdmin(admin.ModelAdmin): | ||
list_display = ('title', 'category', 'registered_datetime', | ||
'owner', 'is_hide') | ||
|
||
|
||
class BookmarkTagAdmin(admin.ModelAdmin): | ||
list_display = ('bookmark', 'tag') | ||
|
||
|
||
class FeedSubscriptionAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'owner', 'default_category') | ||
|
||
|
||
class CrawlingHistoryAdmin(admin.ModelAdmin): | ||
list_display = ('get_name', 'update_datetime', 'result') | ||
|
||
def get_name(self, obj): | ||
return obj.feed.name | ||
|
||
|
||
admin.site.register(Bookmark, BookmarkAdmin) | ||
admin.site.register(Category) | ||
admin.site.register(Tag) | ||
admin.site.register(BookmarkTag) | ||
admin.site.register(BookmarkTag, BookmarkTagAdmin) | ||
admin.site.register(FeedSubscription, FeedSubscriptionAdmin) | ||
admin.site.register(CrawlingHistory, CrawlingHistoryAdmin) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.contrib.auth.models import User | ||
from django.db import IntegrityError | ||
import json | ||
from shiori.bookmark.models import (Bookmark, | ||
Category, | ||
FeedSubscription, | ||
CrawlingHistory) | ||
from shiori.bookmark.agents.feed_parser import FeedParser | ||
|
||
|
||
def register_bookmarks(): | ||
|
||
for feed in FeedSubscription.objects.all(): | ||
result = fetch_feeds(url=feed.url, | ||
category=feed.default_category, | ||
owner=feed.owner) | ||
CrawlingHistory(feed=feed, result=json.dumps(result)).save() | ||
|
||
|
||
def fetch_feeds(**kwargs): | ||
result = [] | ||
for entry in FeedParser(kwargs.get('url')).retrieve_items(): | ||
rc, msg = add_item(url=entry.get('link'), | ||
title=entry.get('title'), | ||
category=kwargs.get('category'), | ||
owner=kwargs.get('owner')) | ||
if rc is False and "already registered:" in msg: | ||
break | ||
result.append(dict(link=entry.get('link'), | ||
rc=rc, | ||
msg=msg)) | ||
return result | ||
|
||
|
||
def add_categories(url): | ||
[add_category(entry.get('category')) | ||
for entry | ||
in FeedParser(url).retrieve_items() | ||
if entry.get('category')] | ||
|
||
|
||
def add_item(**kwargs): | ||
category = Category.objects.get(category=kwargs.get('category')) | ||
owner = User.objects.get(username=kwargs.get('owner')) | ||
|
||
bookmark = Bookmark(url=kwargs.get('url'), | ||
title=kwargs.get('title'), | ||
category=category, | ||
owner=kwargs.get('owner')) | ||
try: | ||
bookmark.save() | ||
return True, '' | ||
except IntegrityError as error: | ||
return False, "already registered: %s" % error |
Oops, something went wrong.