Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Tiny Tiny RSS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Server
Tiny Tiny RSS
Commits
5800d3d5
Commit
5800d3d5
authored
Jan 22, 2017
by
JustAMacUser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update af_comics to handle new GoComics site.
parent
fabfb9fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
55 deletions
+68
-55
plugins/af_comics/filters/af_comics_gocomics.php
plugins/af_comics/filters/af_comics_gocomics.php
+0
-53
plugins/af_comics/init.php
plugins/af_comics/init.php
+68
-2
No files found.
plugins/af_comics/filters/af_comics_gocomics.php
deleted
100644 → 0
View file @
fabfb9fc
<?php
class
Af_Comics_GoComics
extends
Af_ComicFilter
{
function
supported
()
{
return
array
(
"GoComics"
);
}
function
process
(
&
$article
)
{
$owner_uid
=
$article
[
"owner_uid"
];
if
(
strpos
(
$article
[
"guid"
],
"gocomics.com"
)
!==
FALSE
)
{
$doc
=
new
DOMDocument
();
@
$doc
->
loadHTML
(
fetch_file_contents
(
$article
[
"link"
]));
$basenode
=
false
;
if
(
$doc
)
{
$xpath
=
new
DOMXPath
(
$doc
);
$entries
=
$xpath
->
query
(
"(//img[@class='strip'])"
);
$matches
=
array
();
if
(
$entries
->
length
>
1
)
{
// if we have more than one match, then get the zoomed one, which is the second for gocomics
$entry
=
$entries
->
item
(
1
);
// get the second element (items start at 0)
if
(
preg_match
(
"/(http:\/\/assets.amuniversal.com\/.*)/i"
,
$entry
->
getAttribute
(
"src"
),
$matches
))
{
$entry
->
setAttribute
(
"src"
,
$matches
[
0
]);
$basenode
=
$entry
;
}
}
if
(
!
$basenode
)
{
// fallback on the smaller version
foreach
(
$entries
as
$entry
)
{
if
(
preg_match
(
"/(http:\/\/assets.amuniversal.com\/.*)/i"
,
$entry
->
getAttribute
(
"src"
),
$matches
))
{
$entry
->
setAttribute
(
"src"
,
$matches
[
0
]);
$basenode
=
$entry
;
break
;
}
}
}
if
(
$basenode
)
{
$article
[
"content"
]
=
$doc
->
saveXML
(
$basenode
);
}
}
return
true
;
}
return
false
;
}
}
?>
plugins/af_comics/init.php
View file @
5800d3d5
...
...
@@ -5,7 +5,7 @@ class Af_Comics extends Plugin {
private
$filters
=
array
();
function
about
()
{
return
array
(
1
.0
,
return
array
(
2
.0
,
"Fixes RSS feeds of assorted comic strips"
,
"fox"
);
}
...
...
@@ -13,6 +13,7 @@ class Af_Comics extends Plugin {
function
init
(
$host
)
{
$this
->
host
=
$host
;
$host
->
add_hook
(
$host
::
HOOK_FETCH_FEED
,
$this
);
$host
->
add_hook
(
$host
::
HOOK_ARTICLE_FILTER
,
$this
);
$host
->
add_hook
(
$host
::
HOOK_PREFS_TAB
,
$this
);
...
...
@@ -40,7 +41,7 @@ class Af_Comics extends Plugin {
print
"<p>"
.
__
(
"The following comics are currently supported:"
)
.
"</p>"
;
$comics
=
array
();
$comics
=
array
(
"GoComics"
);
foreach
(
$this
->
filters
as
$f
)
{
foreach
(
$f
->
supported
()
as
$comic
)
{
...
...
@@ -71,6 +72,71 @@ class Af_Comics extends Plugin {
}
// GoComics dropped feed support so it needs to be handled when fetching the feed.
function
hook_fetch_feed
(
$feed_data
,
$fetch_url
,
$owner_uid
,
$feed
,
$last_article_timestamp
,
$auth_login
,
$auth_pass
)
{
if
(
$auth_login
||
$auth_pass
)
return
$feed_data
;
if
(
preg_match
(
'#^https?://feeds.feedburner.com/uclick/([a-z]+)#'
,
$fetch_url
,
$comic
))
{
$site_url
=
'http://www.gocomics.com/'
.
$comic
[
1
];
$article_link
=
$site_url
.
date
(
'/Y/m/d'
);
$body
=
fetch_file_contents
(
array
(
'url'
=>
$article_link
,
'type'
=>
'text/html'
,
'followlocation'
=>
false
));
require_once
'lib/MiniTemplator.class.php'
;
$feed_title
=
htmlspecialchars
(
$comic
[
1
]);
$site_url
=
htmlspecialchars
(
$site_url
);
$article_link
=
htmlspecialchars
(
$article_link
);
$tpl
=
new
MiniTemplator
();
$tpl
->
readTemplateFromFile
(
'templates/generated_feed.txt'
);
$tpl
->
setVariable
(
'FEED_TITLE'
,
$feed_title
,
true
);
$tpl
->
setVariable
(
'VERSION'
,
VERSION
,
true
);
$tpl
->
setVariable
(
'FEED_URL'
,
htmlspecialchars
(
$fetch_url
),
true
);
$tpl
->
setVariable
(
'SELF_URL'
,
$site_url
,
true
);
$tpl
->
setVariable
(
'ARTICLE_UPDATED_ATOM'
,
date
(
'c'
),
true
);
$tpl
->
setVariable
(
'ARTICLE_UPDATED_RFC822'
,
date
(
DATE_RFC822
),
true
);
if
(
$body
)
{
$doc
=
new
DOMDocument
();
if
(
@
$doc
->
loadHTML
(
$body
))
{
$xpath
=
new
DOMXPath
(
$doc
);
$node
=
$xpath
->
query
(
'//picture[contains(@class, "item-comic-image")]/img'
)
->
item
(
0
);
if
(
$node
)
{
$tpl
->
setVariable
(
'ARTICLE_ID'
,
$article_link
,
true
);
$tpl
->
setVariable
(
'ARTICLE_LINK'
,
$article_link
,
true
);
$tpl
->
setVariable
(
'ARTICLE_TITLE'
,
date
(
'l, F d, Y'
),
true
);
$tpl
->
setVariable
(
'ARTICLE_EXCERPT'
,
''
,
true
);
$tpl
->
setVariable
(
'ARTICLE_CONTENT'
,
$doc
->
saveXML
(
$node
),
true
);
$tpl
->
setVariable
(
'ARTICLE_AUTHOR'
,
''
,
true
);
$tpl
->
setVariable
(
'ARTICLE_SOURCE_LINK'
,
$site_url
,
true
);
$tpl
->
setVariable
(
'ARTICLE_SOURCE_TITLE'
,
$feed_title
,
true
);
$tpl
->
addBlock
(
'entry'
);
}
}
}
$tpl
->
addBlock
(
'feed'
);
$tmp_data
=
''
;
if
(
$tpl
->
generateOutputToString
(
$tmp_data
))
$feed_data
=
$tmp_data
;
}
return
$feed_data
;
}
function
api_version
()
{
return
2
;
}
...
...
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