[BETA] Smartfeed

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
User avatar
tekguru
Registered User
Posts: 139
Joined: Thu Jul 03, 2003 1:33 pm

Post by tekguru » Sat Apr 22, 2006 8:00 am

Mark, understand what you are saying. Especially as the IM portal includes hundreds of Mods (although not that many on the BBCodes) and I've added a few BBCode Mods myself :)

If I sent you my bbcode.php file and a donation of say $30 would that help at all?

User avatar
MarkDHamill
Registered User
Posts: 3952
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Post by MarkDHamill » Sat Apr 22, 2006 1:17 pm

bbcode.php is a standard module in phpBB.

Let me look at the size of the mod and see how it modified bbcode.php in particular, then I can get a feel for the amount of work involved. Sometimes these custom mods take a lot more time than it appears at first glance.

User avatar
MarkDHamill
Registered User
Posts: 3952
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Post by MarkDHamill » Sat Apr 22, 2006 4:29 pm

Hmm, I didn't realize IntegraMod overwrote phpBB entirely. Too much work for me to install it and figure out how it works.

nickramsay
Registered User
Posts: 2
Joined: Mon Apr 24, 2006 1:39 pm
Location: Japan
Contact:

Post by nickramsay » Mon Apr 24, 2006 2:11 pm

Mark, thank you very much for smartfeed. It's great and does nearly everything I want it to do!

I'm a bit of a newbie so maybe I'm just doing something wrong, but it seems that the xml file is written with the newest posts at the end. This doesn't matter with some newsreaders because they sort the posts, so it's not a huge problem. However, I'm using Carp to display the latest three posts from the feed on my homepage, and when I use Smartfeed's 'Sort by Post Date/Time' option, I get the oldest three! :cry: Using the Category Order... option gives me a mixed bag - some new posts don't get into the latest three because they are lower down in forum order.

So, is there a simple way to reverse the list?

User avatar
MarkDHamill
Registered User
Posts: 3952
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Post by MarkDHamill » Mon Apr 24, 2006 2:59 pm

Bear in mind that I designed Smartfeed so that posts would appear in natural orders. The natural order in phpBB can be seen on the main index, which is category order, forum order, then last topic post time for the forum (descending), then by post time. I apply filters to filter out unwanted forums, and limit posts going back no more than a particular time range. In addition using smartfeed_url.php you can say to not see messages since your last visit.

Now you could change line 400 in smartfeed.php from:

Code: Select all

			$order_by_str = 'c.cat_order, f.forum_order, lp.post_time desc, p.post_time';
to

Code: Select all

			$order_by_str = 'c.cat_order, f.forum_order, lp.post_time desc, p.post_time desc';
If you do this then you should also update lang_smartfeed.php so that line 107 reads:

Code: Select all

$lang['smartfeed_sort_forum_topic']='Category Order, Forum Order, Forum Topic Last Post Time (Desc), Topic Post Date/Time (Desc)';
However, I suggest what you really want to do is see all the new posts on your forum since you last checked. Since you do this often, you can get as granular as see posts in the last 15 minutes. Make sure you say yes to "Reset your last visit date when you access the newsfeed?".

You can do this via smartfeed_url.php and generating a new URL.

nickramsay
Registered User
Posts: 2
Joined: Mon Apr 24, 2006 1:39 pm
Location: Japan
Contact:

Post by nickramsay » Mon Apr 24, 2006 3:27 pm

Thanks Mark,

I played around with 'desc', adding it to $order_by == 'postdate', and it worked a treat. I use the 'natural order' for my main feed which people can subscribe to, but this little fix is all I needed for the feed embedded in my homepage. Super! :D

User avatar
tekguru
Registered User
Posts: 139
Joined: Thu Jul 03, 2003 1:33 pm

Post by tekguru » Mon Apr 24, 2006 10:25 pm

Mark, yeah IM is very invasive and a complete alternate to PhpBB with a lot of Mods.

The BBCode can be found oneline here:

http://www.4winmobile.com/bbcode.zip

Interestingly the latest version of the Digest Mod handles all the codes completely painlessly so it may not be that hard a job?

Let me know where you want to go with it once you've taken a look.

Cheers.

User avatar
MarkDHamill
Registered User
Posts: 3952
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Post by MarkDHamill » Wed Apr 26, 2006 12:45 am

Sorry, I looked at your code and compared it with the phpBB version. There are lots of changes but nothing that is readily apparent to me.

Someone better with regular expressions could probably do it. I would try to find someone who is more skilled in phpBB internals. You might be able to hire someone on the forums at http://www.phpbbhacks.com.

jokieman31
Registered User
Posts: 38
Joined: Sun Mar 19, 2006 10:29 pm
Contact:

Post by jokieman31 » Wed Apr 26, 2006 3:33 am

MarkDHamill wrote: Sorry, I looked at your code and compared it with the phpBB version. There are lots of changes but nothing that is readily apparent to me.

Someone better with regular expressions could probably do it. I would try to find someone who is more skilled in phpBB internals. You might be able to hire someone on the forums at http://www.phpbbhacks.com.


How will this mod fair on large or oft used forums? Is there a way to limit the max number of days or weeks that the feed pulls information for? I'm mainly thinking of serverload and bandwidth issues.

Also is there a way we can trim the output of the feed. Like say I only want 256 or 512 characters of the post to be displayed with a link back so users can view the entire post/topic.

Also, drop me a pm about the button graphic you wanted? I can probably whip something up.
Last edited by jokieman31 on Wed Apr 26, 2006 8:11 am, edited 1 time in total.

User avatar
tekguru
Registered User
Posts: 139
Joined: Thu Jul 03, 2003 1:33 pm

Post by tekguru » Wed Apr 26, 2006 6:14 am

Cheers for the reply Mark, in that cae wlould it not be easier to just add code to strip out the BBCodes entirely as an option, would that be more feasible?

User avatar
MarkDHamill
Registered User
Posts: 3952
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Post by MarkDHamill » Wed Apr 26, 2006 12:03 pm

jokieman31 wrote: How will this mod fair on large or oft used forums? Is there a way to limit the max number of days or weeks that the feed pulls information for? I'm mainly thinking of serverload and bandwidth issues.

Also is there a way we can trim the output of the feed. Like say I only want 256 or 512 characters of the post to be displayed with a link back so users can view the entire post/topic.

Also, drop me a pm about the button graphic you wanted? I can probably whip something up.


This mod should be able to be throttled well for high traffic boards. There is a setting in smartfeed_constants.php which will set what amounts to a throttle so that for unauthenticated users no query will go back more than a given amount of time. I think the default is one week.

The user determines the amount of time they want to go back when they create the URL with smartfeed_url.php. I think the maximum is 7 days. As a practical matter it is often less, if they don't pick all forums, or they also indicate to reset their last visit date, etc.

There is no way to trim the length of the feed at present, although that is a good idea for an enhancement. It would not be hard to add. If a user selects RSS 0.91 they are limited to 15 feed items and the item text is trimmed to a certain length if needed, because it is part of the RSS 0.91 specification.

I think both RSS and Atom support the link back, but it depends on the newsreader to implement this feature. Each item in the feed should have a link back to the post.

I already include a XML button in the Smartfeed archive if someone wants to use it, but currently I don't have any suggestions on where to put it. It could be integrated into a lot of places, including the Main Index, but that of course would require a revision to the mod. The virtue of Smartfeed, from my perspective, is that it doesn't change one line of phpBB code -- it operates independently.

User avatar
MarkDHamill
Registered User
Posts: 3952
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Post by MarkDHamill » Wed Apr 26, 2006 12:05 pm

tekguru wrote: Cheers for the reply Mark, in that cae wlould it not be easier to just add code to strip out the BBCodes entirely as an option, would that be more feasible?


It's possible but you would lose something, including the ability to use the quote feature. Should be fairly simple to programatically remove anything between a [ and a ] in a message, although it is possible one could also remove content other than bbcode.

All these are good ideas for a future version.

User avatar
tekguru
Registered User
Posts: 139
Joined: Thu Jul 03, 2003 1:33 pm

Post by tekguru » Wed Apr 26, 2006 7:27 pm

Okay, so there are a few options as I see it:

- Remove all BBCode - and quotes would show up as part of the text. How would this work, something like: $msg = ereg_replace("[\[*\]]", "", $msg); ?

- Try and add additional filters into your code as you originally envisaged

- Or maybe call the existing BBCode system to do the conversion?

The later would seem obvious but I guess there are reasons why it is not possible? I *think* the digest Mod must do this though as that has no problems with any of the BBCodes used - or am I missing something obvious?

User avatar
MarkDHamill
Registered User
Posts: 3952
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Post by MarkDHamill » Wed Apr 26, 2006 9:44 pm

tekguru wrote: I *think* the digest Mod must do this though as that has no problems with any of the BBCodes used - or am I missing something obvious?


The mail_digests.php program (at least my version 1.0.9c, the last one I authored) does not call bbcode.php at all. Rather it uses this code:

Code: Select all

		// Remove BBCode and replace \n with <br />, makes for nicer presentation
            $this_msg = '<td>' . preg_replace('/\[\S+\]/', '', $row2['Post Text']) . '</td>';
            $this_msg = preg_replace('/\\n/', '<br />', $this_msg);
and this:

Code: Select all

   				// Remove BBCode, makes for nicer presentation
					$msg .= $lang['digest_message_excerpt'] . ': ' . preg_replace('/\[\S+\]/', '', $row2['Post Text']) . "\r\n";

I think some beta tester (maybe you) provided this code a couple years back when I was doing this mod.

When doing Smartfeed though I looked at the other RSS mods out there, and that's why I decided to use bbcode.php, because it already worked in one instance. Didn't see a point of reinventing the wheel.

So I'm betting if you replace this code in smartfeed.php:

Code: Select all

				// Code from rss.php by Sascha Carlin, slightly modified 
				$post_text = '<em>' . $row['username'] . '</em> ' . $lang['smartfeed_wrote'] . ' ' . $lang['smartfeed_at'] . ' <em>' . date('d M Y h:i A ',$row['post_time']) . ' ' . $timezone . '</em>: ' . $row['post_text'];
				$post_text = str_replace("\n", "\n<br />\n", $post_text);
				$post_text = bbencode_second_pass($post_text, $row['bbcode_uid']);
				$post_text = smilies_pass($post_text);
				$post_text = preg_replace("/$smilies_path/", SMILIES_URL, $post_text);
				$post_text = make_clickable($post_text);
				// Variable reassignment and reformatting for user sig
				$user_sig = $row['user_sig'];
				$user_sig = bbencode_second_pass($user_sig, $post['user_sig_bbcode_uid']);
				$user_sig = smilies_pass($user_sig);
				$user_sig = preg_replace("/$smilies_path/", SMILIES_URL, $user_sig);
				$user_sig = make_clickable($user_sig);
				// End Code from rss.php by Sascha Carlin, slightly modified 
with something like the above you would be happy.

I'll consider it for a future version, but this sounds like the sort of mod you could make on your own.

I am not sure though that links and such would translate correctly. The email digest mod sort of expects an intelligent mail client to make embedded URLs clickable.

User avatar
tekguru
Registered User
Posts: 139
Joined: Thu Jul 03, 2003 1:33 pm

Post by tekguru » Wed Apr 26, 2006 10:03 pm

Right, not knowing a lot of PHP, looking at the working viewtopic.php in IntegraMod would it be as simple as taking the code here:

Code: Select all

		$bbcode_uid = $row['bbcode_uid'];
		$message = $row['post_text'];

		$message = strip_tags($message);
		$message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", '', $message);
		$message = preg_replace('/\[url\]|\[\/url\]/si', '', $message);
		$message = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);

		$message = unprepare_message($message);
		$message = preg_replace('/(/', '(', $message);
		$message = preg_replace('/)/', ')', $message);
		$message = preg_replace('/:/', ':', $message);

		if (count($orig_word))
		{
			$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);

			$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
		}
and changing it to use the variables in smartfeed.php and it should work?

As this seems to be doing the bbcode reformatting for message en forum?

If you can advise I'll throw it at a colleague who knows PHP to see what he can achieve.

If this idea does work though it should work on the vanilla PhpBB systems too I think?

Thoughts please?

Post Reply

Return to “[2.0.x] MODs in Development”