this is one part of #2

This commit is contained in:
Alper Kanat 2008-10-25 20:21:25 +00:00
parent bfd27664b9
commit 0576df2104
6 changed files with 86 additions and 3 deletions

0
gezegen/__init__.py Normal file
View File

View File

@ -14,6 +14,7 @@ days_per_page = 0
feed_timeout = 15 feed_timeout = 15
encoding = utf-8 encoding = utf-8
locale = tr_TR.UTF-8 locale = tr_TR.UTF-8
limit_per_entry = 1500
date_format = %d %b %Y @ %I:%M %p date_format = %d %b %Y @ %I:%M %p
#date_format = %B %d, %Y %I:%M %p #date_format = %B %d, %Y %I:%M %p
@ -22,7 +23,6 @@ new_date_format = %d %B %Y
[DEFAULT] [DEFAULT]
facewidth = 64 facewidth = 64
faceheight = 64 faceheight = 64
#[http://feeds.feedburner.com/gl] #[http://feeds.feedburner.com/gl]
#name = Gezegen Ekibi #name = Gezegen Ekibi
#face = gezegenekibi.png #face = gezegenekibi.png
@ -488,4 +488,3 @@ name = LKD.org.tr
[http://gunluk.lkd.org.tr/ftp/feed/] [http://gunluk.lkd.org.tr/ftp/feed/]
name = FTP ekibi name = FTP ekibi
#email = ftp@linux.org.tr #email = ftp@linux.org.tr

25
gezegen/gezegen.py Normal file
View File

@ -0,0 +1,25 @@
#-*- encoding: utf8 -*-
"""
The purpose of this file is to store some common Python functions
that we can use everywhere inside the code..
Author: Alper KANAT <alperkanat@raptiye.org>
"""
def summarize(text, limit=0):
"""
Removes all HTML tags and cuts the text by limit
text (string): blog entry that needs to be summarized
limit (int): number of characters that the summary can include
"""
import re
regex = re.compile("<[^<>]*?>")
if limit > 0 and text.__len__() >= limit:
return regex.sub("", text)[:limit] + " [...]"
return regex.sub("", text)

View File

@ -279,6 +279,18 @@ class Planet:
# Gather item information # Gather item information
# Use summary to summarize the entry to N characters and
# put a JS link inside to expand and show the content..
from gezegen import gezegen
# getting the limit from the config.ini file
limit_per_entry = int(self.tmpl_config_get("Planet", "limit_per_entry", 1500))
for item in items_list:
if item["content"].__len__() >= limit_per_entry:
item["summary"] = gezegen.summarize(item["content"], limit_per_entry)
item["read_the_rest"] = True
# Process the template # Process the template
tp = htmltmpl.TemplateProcessor(html_escape=0) tp = htmltmpl.TemplateProcessor(html_escape=0)
tp.set("Items", items_list) tp.set("Items", items_list)

15
www/common.js Normal file
View File

@ -0,0 +1,15 @@
var entries = []
function toggleEntry(id) {
// hide summary
$("#summary_" + id).slideToggle()
if ($("#summary_" + id).css("display") == "none") {
// change the link text
$("#toggle_content_" + id).text("Bu yazıyla ilgili detayları okumak için tıklayın.")
} else {
// change the link text
$("#toggle_content_" + id).text("Bu yazının detaylarını kapatmak için tıklayın.")
}
// show the content
$("#content_" + id).slideToggle();
}

32
www/jquery-1.2.6.min.js vendored Normal file

File diff suppressed because one or more lines are too long