2008-08-11 22 views
0

Gallery2RSS moduleと戦って「まだフィードが定義されていません」というメッセージが表示されてから、私は諦めました。 a Google search for "no feeds have yet been defined"に基づいて、これはかなり一般的な問題です。 Gallery2 RSSモジュールを動作させるためのヒントやヒントはありますか?また、このPHPアプリケーションの問題をデバッグしようとする、比較的PHPを知らない開発者のためのヒントはありますか?Gallery2からのRSSフィード

答えて

1

この問題の最終的な解決策は、Python CGIスクリプトでした。私のスクリプトは、(これが完全なハックであるという事実にもかかわらず)便利だと思う人のために続きます。

#!/usr/bin/python 
"""A CGI script to produce an RSS feed of top-level Gallery2 albums.""" 

#import cgi 
#import cgitb; cgitb.enable() 
from time import gmtime, strftime 
import MySQLdb 

ALBUM_QUERY = ''' 
    select g_id, g_title, g_originationTimestamp 
    from g_Item 
    where g_canContainChildren = 1 
    order by g_originationTimestamp desc 
    limit 0, 20 
    ''' 

RSS_TEMPLATE = '''Content-Type: text/xml 

<?xml version="1.0"?> 
<rss version="2.0"> 
    <channel> 
    <title>TITLE</title> 
    <link>http://example.com/gallery2/main.php</link> 
    <description>DESCRIPTION</description> 
    <ttl>1440</ttl> 
%s 
    </channel> 
</rss> 
''' 

ITEM_TEMPLATE = ''' 
    <item> 
     <title>%s</title> 
     <link>http://example.com/gallery2/main.php?g2_itemId=%s</link> 
     <description>%s</description> 
     <pubDate>%s</pubDate> 
    </item> 
''' 

def to_item(row): 
    item_id = row[0] 
    title = row[1] 
    date = strftime("%a, %d %b %Y %H:%M:%S GMT", gmtime(row[2])) 
    return ITEM_TEMPLATE % (title, item_id, title, date) 

conn = MySQLdb.connect(host = "HOST", 
         user = "USER", 
         passwd = "PASSWORD", 
         db = "DATABASE") 
curs = conn.cursor() 
curs.execute(ALBUM_QUERY) 
print RSS_TEMPLATE % ''.join([ to_item(row) for row in curs.fetchall() ]) 
curs.close() 
-2

まあ、私はこれはあなたを助けることができるか不明だが、ここでは別のトピックで解決策として提示された非常にシンプルなRSSです:

PHP RSS Builder

は、