Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rss-reader
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-rss-reader
Commits
6d9f91e1
Commit
6d9f91e1
authored
Jan 23, 2013
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Fixed RSS read library
parent
c9a35b8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
144 deletions
+0
-144
intranet-rss-reader-procs.tcl
tcl/intranet-rss-reader-procs.tcl
+0
-144
No files found.
tcl/intranet-rss-reader-procs.tcl
View file @
6d9f91e1
...
...
@@ -15,147 +15,3 @@ ad_library {
#
# ----------------------------------------------------------------------
#
set
feed_ctr 0
set
debug
""
set
html
""
# Fraber 130116: What is this??? Why is there such a syntax error in the code?
set
rss_feeds
{}
foreach
rss_feed
$rss
_feeds
{
if
{
[
catch
{
set update_xml
[
ns_httpget
$rss
_feed
]
}
errmsg
]
}
{
ad_return_complaint 1
"Error while accessing the URL '
$rss
_feed'.<br>
Please check your URL. The following error was returned: <br>
<blockquote><pre>
[
ad_quotehtml
$errmsg
]
</pre></blockquote>"
return
}
if
{
""
==
$update
_xml
}
{
ad_return_complaint 1
"Found an empty XML file accessing the URL '
$rss
_feed'.<br>
This means that your server(!) was not able to access the URL.<br>
Please check the the Internet and firewall configuration of your
server and verify that the 'nsd' (Linux) or 'nsd4' (Windows)
process has access to the URL.<br>"
return
}
# ------------------------------------------------------------
# Check whether it's a HTML or an XML
#
if
{
!
[
regexp
{
<
([
^>
]
*
)
>
\s
*<
([
^>
]
*
)
>
\s
*<
([
^>
]
*
)
>
}
$update
_xml match tag1 tag2 tag3
]}
{
ad_return_complaint 1
"Error while retreiving update information from
URL '
$rss
_feed'.<br>The retreived files doesn't seem to be a XML or HTML file:<br>
<pre>
$update
_xml</pre>"
return
}
if
{[
string
tolower
$tag1
]
==
"html"
||
[
string
tolower
$tag2
]
==
"html"
||
[
string
tolower
$tag3
]
==
"html"
}
{
ad_return_complaint 1
"Error while retreiving update information from URL<br>
'
$rss
_feed'.<br>
The retreived result seems to be a HTML document and not an XML document.<br>
Please check the URL above and/or send an error report to
<a href=
\"
mailto:support@project-open.com
\"
>support@project-open.com</a>.
<br> </br>
Here is what the server returned:
<br> </br>
<pre>
$update
_xml</pre>"
}
ns_log notice
"rss-reader: match=
$match
, tag1=
$tag1
, tag2=
$tag2
, tag3=
$tag3
"
# ------------------------------------------------------------
# Parse the XML file and generate the HTML table
#
# Sample File:
#
# <?xml version="1.0" encoding="UTF-8"?>
# <rss version="2.0">
# <channel>
# <title>
]project-open
[
</title>
# <link>http://www.project-open.com</link>
# <description>News from the maintainers of
]
project-open
[
</description>
# <language>en-us</language>
# <copyright>Copyright 2008
]
project-open
[
</copyright>
# <pubDate>Mon, 03 Mar 2008 11:39:00 GMT</pubDate>
# <lastBuildDate>Tue, 22 Jul 2008 16:30:27 GMT</lastBuildDate>
#
# <item>
# <title>Updated Italien Localization available for download</title>
# <link>http://www.project-open.net/sources/italian_catalogs_update.rar</link>
# <description>Thanks goes to our partner ...</description>
# <guid isPermaLink="false">{ca01b700-eaba-981c-d97b-7280a9cbd186
}
</guid>
# <pubDate>Tue, 22 Jul 2008 16:30:27 GMT</pubDate>
# </item>
# <item>
# <title>Get a sneak preview of
]
po
[
V3.4</title>
# <link>http://po34demo.dnsalias.com</link>
# <description>New navigation elements ...</description>
# <guid isPermaLink="false">{2b5d3671-6aa5-6089-4b70-ca11648f2dcf
}
</guid>
# <pubDate>Thu, 26 Jun 2008 09:55:42 GMT</pubDate>
# </item>
# </channel>
# </rss>
set
tree
[
xml_parse -persist
$update
_xml
]
set
rss_node
[
xml_doc_get_first_node
$tree
]
set
root_name
[
xml_node_get_name
$rss
_node
]
if
{
!
[
string
equal
$root
_name
"rss"
]
}
{
ad_return_complaint 1
"Expected 'rss' as root node of update.xml file, found: '
$root
_name'"
}
set
channel_nodes
[
xml_node_get_children
$rss
_node
]
set
channel_ctr 0
foreach
channel_node
$channel
_nodes
{
if
{[
catch
{
set
channel_title
[[
$channel
_node selectNodes
{
title
}]
text
]}
err_msg
]}
{
set channel_title
"unknown title"
}
if
{[
catch
{
set
channel_link
[[
$channel
_node selectNodes
{
link
}]
text
]}
err_msg
]}
{
set channel_link
""
}
if
{[
catch
{
set
channel_description
[[
$channel
_node selectNodes
{
description
}]
text
]}
err_msg
]}
{
set channel_description
""
}
if
{[
catch
{
set
channel_language
[[
$channel
_node selectNodes
{
language
}]
text
]}
err_msg
]}
{
set channel_language
"en_US"
}
if
{[
catch
{
set
channel_copyright
[[
$channel
_node selectNodes
{
copyright
}]
text
]}
err_msg
]}
{
set channel_copyright
""
}
if
{[
catch
{
set
channel_pubDate
[[
$channel
_node selectNodes
{
pubDate
}]
text
]}
err_msg
]}
{
set channel_pubDate
""
}
if
{[
catch
{
set
channel_lastBuildDate
[[
$channel
_node selectNodes
{
lastBuildDate
}]
text
]}
err_msg
]}
{
set channel_lastBuildDate
""
}
append html
"<h1><a href='
$channel
_link'>
$channel
_title</a></h1>
\n
"
append html
"<p>
\n
$channel
_description
\n
</p>
\n
"
# Go through each item
# <item>
# <title>Get a sneak preview of ]po
[
V3.4</title>
# <link>http://po34demo.dnsalias.com</link>
# <description>New navigation elements ...</description>
# <guid isPermaLink=
"false"
>
{
2b5d3671-6aa5-6089-4b70-ca11648f2dcf
}
</guid>
# <pubDate>Thu, 26 Jun 2008 09:55:42 GMT</pubDate>
# </item>
set item_nodes
[
xml_node_get_children
$channel
_node
]
foreach item_node
$item
_nodes
{
if
{[
catch
{
set
item_title
[[
$item
_node selectNodes
{
title
}]
text
]}
err_msg
]}
{
set item_title
""
}
if
{[
catch
{
set
item_link
[[
$item
_node selectNodes
{
link
}]
text
]}
err_msg
]}
{
set item_link
""
}
if
{[
catch
{
set
item_description
[[
$item
_node selectNodes
{
description
}]
text
]}
err_msg
]}
{
set item_description
""
}
if
{[
catch
{
set
item_guid
[[
$item
_node selectNodes
{
guid
}]
text
]}
err_msg
]}
{
set item_guid
""
}
if
{[
catch
{
set
item_pubDate
[[
$item
_node selectNodes
{
pubDate
}]
text
]}
err_msg
]}
{
set item_pubDate
""
}
append html
"<h3><a href='
$item
_link'>
$item
_title</a></h3>
\n
"
append html
"<p>
\n
$item
_description
\n
</p>
\n
"
}
incr item_ctr
}
incr feed_ctr
}
ns_return 200
"text/html"
$html
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment