Search Results for 'code'
-
Search Results
-
Being both a web nerd and Physics student, I decided it was time for BBpress to meet up with MathML.
Here’s the steps I took to get it crankin’:
- Made a copy of the default ‘kakumei’ template, then renamed the folder ‘physics’, my new template name. I then put a copy of ASCIImath.js in there. This does all the hard work.
- Changed the physics/header.php from:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php bb_language_attributes( '1.1' ); ?>>to:
<?xml version='1.0' encoding='iso-8859-1'?>
<?xml-stylesheet type="text/xsl" href="http://www.w3.org/Math/XSL/mathml.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"
xmlns:pref="http://www.w3.org/2002/Math/preference"
pref:renderer="css">It’d probably still work if you didn’t bother with this step, but seeing as BBpress is making XML we may as well.
- Added
<script type="text/javascript" src="<?php echo bb_path_to_url( dirname(__FILE__) . '/ASCIIMathML.js'); ?>">
to physics/header.php – this loads the ASCIIMathML.js javascript and does a majority of the MathML magic. - Opened bb-includes/formattingfunctions.php and edited this:
function code_trick( $text ) {
$text = str_replace(array("rn", "r"), "n", $text);
// $text = preg_replace("|<code>(.*?)</code>|e", "'<code>' . encodeit('$1') . '</code>'", $text);
// $text = preg_replace("|n<code>(.*?)</code>|se", "'<pre><code>' . encodeit('$1') . '</code></pre>'", $text);
return $text;
}To turn off the backtick code replacement – this is what ASCIIMath.js does!
That was it. I’ll zip it all up then post it up here. Ideally, it’d be better to not comment out any of the bb-include/ files – if anyone has any suggestions, let me know.
Topic: Include code in posts
I am working on adding a “Most Viewed Topics” list to my bb-Topic-Views plugin, and I’m getting hung up on one little thing. This is the code I am using to pull the topic ID and # of views from the topicmeta table:
$most_viewed = (array) $bbdb->get_results("SELECT topic_id, meta_value FROM $bbdb->topicmeta WHERE meta_key='views' ORDER BY meta_value DESC");
I then use
array_slice
to shorten the list to the number of posts the user wants to have listed. The only problem is that the results are sorted out of order.For instance, a post with 5 views would come before a post with 40, because 5 is higher than 4. In other words, any post with a single-digit number of views is sorted above posts with a double-digit number of views.
Has anyone ever had this problem? Any ideas how to fix it?
PurposeGames is one of my sites. It’s basically a site for anyone that wants to learn something new in the most efficient way possible; by creating a game around that very subject. It allows for anyone to easily create games and play/rate games by other members. I’ve actionscripted a game engine and a game creation module to allow for anyone to create games via their own pictures and drag and drop.
I use bbpress for the forum section, and actually liked the user handling so much that I kept the authentication engine for all of the site. I’ve extended it in the following manner:
– Elaborating on the bozo concept to exclude games created by a bozo, ratings doesn’t count for bozo’s and comments to games by bozos gets treated like forum entries by bozos.
– Added a vast number of statistics to the dashboard to see what member’s are doing, creating, rating, commenting, forum entries, top lists etc.
– Extending profile pages to show member’s games, comments to the games created by member etc.
– Keeping the base of the style of the forum, extending it to fit the way I like my site to look.
Concepts I like most about bbpress include the sanitize methods (very fast, perfectly implemented in my opinion), the user object; extending it is endless and very easy with the meta-concept, the tags concept, and the bozo concept and of course the table-free layout. The Akismet utilization is very nice also.
Concepts that I’ve excluded or re-written: Db-connection open/close (not optimized for my type of site), the plugin concept (my extensions are therefore “include”-based i.e. I’m not utilizing the various hooks available). I have not cluttered the code of any standard files with my code, other than adding an include statement where needed. I also had to re-route the “include header”-call of the admin panel to be able to add new parent sections to keep child sections. No biggie really but quite strange.
I rate bbpress as 4 out of 5 as code architecture goes being able to extend it and to use it as authentication foundation. Near superb. As forums goes, it falls into the category of “less is more, but not enough”
Check my way of using bbpress at http://www.purposegames.com
Feel free to comment on what you like and don’t like. Thanks.
David Andersson
Creator of purposegames.com
Topic: Plugin: bb-Topic-Views
bb-Topic-Views keeps track of how many times each topic has been viewed, and then displays the count alongside the title of the topic on the front page, on forums pages, and on tags pages.
The plugin is written in such a way that it does not double-count views when a visitor browses to a different page in the same topic. If no view count record exists for a specific topic, the plugin will create a record for it. Rather than setting the initial view count to zero, the plugin sets it to the number of posts in the topic, because it has obviously been viewed at least as many times as people have posted in it! This is especially nice for adding the plugin to existing bbpress forums so the view count isn’t zero for every single topic.
You can download it here: http://blog.wittmania.com/bb-topic-views
You can see it in action here: http://blog.wittmania.com/bbpress
—
By the way, I’ve only tested this plugin in browser environments where cookies were enabled. This plugin doesn’t set any cookies (directly, anyway), but it does use session variables which are usually passed as cookies. So, if anyone runs into any bugs, please let me know!
I’m also very open to suggestions as to how I could streamline or improve the code. Thanks!
Topic: Views plugin help needed
I am working on a “Topic Views Count” plugin, and I’m just about finished with it. You can see a working version of it here: http://blog.wittmania.com/bbpress/, and see the source code as it is right now here: http://blog.wittmania.com/files/bb-topic-views.txt
The only thing holding me up is this; I can’t figure out a way to keep the views count from including page views. For example, when page one of a topic loads, the view count will go up by one. But, when page two loads it will also go up by one. So, a visitor has only viewed the topic once (albeit they’ve viewed more than one page), but the counter has registered two views).
I know this isn’t a huge deal, and a counter that over-counts is better than no counter at all. Still, I was wondering if anyone would have any ideas. I’d like to avoid using cookies, if possible, because I have no experience with them at all to even know where to start.
Any ideas? I’m also open to any other ideas or suggestions for the rest of the code.
Thanks!