summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f>2009-02-26 20:28:43 +0000
committerluxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f>2009-02-26 20:28:43 +0000
commit3fa6409e2bbe4adf67712abc1c14f27831127c0e (patch)
tree6e98c10e1b4e7bb7ed6bb98b17c43cc7c1ea67ee
parentf01e43401b69a1540560dab2c359ad7574a8b8e4 (diff)
updated for delicious
-rw-r--r--apps/links/models.py2
-rw-r--r--apps/links/utils.py47
-rw-r--r--templates/base.html9
3 files changed, 56 insertions, 2 deletions
diff --git a/apps/links/models.py b/apps/links/models.py
index 00a6f54..4288351 100644
--- a/apps/links/models.py
+++ b/apps/links/models.py
@@ -20,7 +20,7 @@ DEBUG = 1
class Link(models.Model):
title = models.CharField(max_length=400)
- magnolia_id = models.CharField(max_length=20, blank=True, null=True)
+ magnolia_id = models.CharField(max_length=60, blank=True, null=True)
url = models.CharField(max_length=400)
description = models.TextField(blank=True, null=True)
screen_url = models.CharField(max_length=400, blank=True)
diff --git a/apps/links/utils.py b/apps/links/utils.py
index 2649dde..d8463e0 100644
--- a/apps/links/utils.py
+++ b/apps/links/utils.py
@@ -68,6 +68,51 @@ def sync_magnolia_links(*args, **kwargs):
send_to_deliciousfb(l)
if(dupe):
break
+
+def sync_delicious_links(*args, **kwargs):
+ b = delicious.get(settings.DELICIOUS_USER, settings.DELICIOUS_PASS)
+ dupe = False
+ for post in b['posts']:
+ taglist = []
+ try:
+ row = Link.objects.get(magnolia_id=safestr(post['hash']))
+ # If the row exists already, set the dupe flag
+ dupe = True
+ except ObjectDoesNotExist:
+ #f = copy_file(safestr(post.findtext('screenshot')), safestr(info['id']))
+ #fake the image since delicious doesn't offer them
+ local_image_url = "%s/%s.jpg" %(safestr(datetime.datetime.today().strftime("%b").lower()), safestr(post['hash']))
+ tags = str(post['tag']).split(" ")
+ for tag in tags:
+ taglist.append(tag)
+ for tag in taglist:
+ if tag == '2lux':
+ status = 1
+ break
+ else:
+ status = 0
+ descr = markdown.markdown(unquotehtml(safestr(post['extended'])), safe_mode = False)
+ l, created = Link.objects.get_or_create(
+ title = post['description'],
+ magnolia_id = safestr(post['hash']),
+ url = safestr(post['href']),
+ description = descr,
+ screen_url = local_image_url,
+ #fake the rating since delicious doesn't offer such things
+ rating = "3",
+ pub_date = datetime.datetime.strptime(post['time'], "%Y-%m-%dT%H:%M:%SZ"),
+ status = status,
+ enable_comments = True,
+ tags = ", ".join(t for t in taglist if t != "2lux")
+ )
+
+ email_link(l)
+ if l.status == 1:
+ post_to_tumblr(l)
+ send_to_deliciousfb(l)
+ if(dupe):
+ break
+
"""
b, created = Link.objects.get_or_create(
url = info['href'],
@@ -102,7 +147,7 @@ def sync_magnolia_links(*args, **kwargs):
pub_date = datetime.datetime(*(time.strptime(str(b.created[:-6]), '%Y-%m-%dT%H:%M:%S')[0:6])),
status = public,
enable_comments = True,
- tags=", ".join(t.name for t in b.tags.tag if t.name != "2lux")
+
)
email_link(l)
send_to_delicious(l)
diff --git a/templates/base.html b/templates/base.html
index 190175a..a1da32f 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -106,5 +106,14 @@
</div>
</div>
{% block js %}{% endblock%}
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-1186171-1");
+pageTracker._trackPageview();
+} catch(err) {}</script>
</body>
</html> \ No newline at end of file