Help:Setup
From ★grads.net/wiki
This is a record of everything I did to set up the software for stargrads.net, in case I need to install everything again, or to fix something that broke after an upgrade.
For help on how to use the software, see Help:Contents.
Contents |
Blogs (WordPressμ)
I am using the K2 theme for Wordpress. This theme is designed so that the template files do not usually need to be edited. Most of my customisation is done through a stylesheet and using K2's provided hooks. However, I did make three modifications to the template code in "theloop.php":
- I moved the permalink from the post title to just after it, and had it displayed as "[permalink]".
- I added a link to a post's comments after each post.
- I changed the code for the "Continue reading" link so that it expands/collapses the post using AJAX.
The stargrads.net banner and the loader for jsMath are included through "functions.php" by adding hooks for "template_body_top".
One slight change to "header.php": on line 52, I changed the string " at " to " @ " (this makes post titles show up as "post title @ davinci's notebook" on the individual post pages).
Another change to "header.php": I added links in the header to the RSS and Atom feeds of the comments.
The Continue Reading Link
The "Continue reading" link (which is normally displayed when WordPress encounters the <!--more--> tag) was changed so that it would display ellipses, followed by a new paragraph, before the link to the full post. This behaviour is overridden by the Ajaxified Expand Post NOW Plugin, for which see below.
The original code in "theloop.php" was:
<?php the_content(sprintf(__('Continue reading \'%s\'', 'k2_domain'), the_title('', '', false))); ?>
This was changed to:
<?php the_content(sprintf(__('…</p><p>» [Continue reading <span class="small-entry-title">%s</span>]', 'k2_domain'), the_title('', '', false))); ?>
The Ajaxified Expand Post NOW Plugin
In addition to the above, I activated the Ajaxified Expand Post NOW plugin. Note that this essentially overwrites the above changes. I made a number of customisations and modifications to the plugin:
-
\$aepnLoadingMsg = '… » [Fetching data <img src="http://stargrads.net/blogs/wp-content/themes/k2/images/spinner.gif" align=absmiddle />]';, -
\$postLess = 'Collapse post';, and -
\$postMore = 'Expand post';.
I also replaced the line \$content=preg_replace(...) and the following line with:
\$content=preg_replace('/<a href="(\S+)#more-(\d+)"(.*)>(.*)<\/a>/', (\$postLinkPrefix.'<span id="open-p'.\$id.'">… » [<a href="'.get_permalink().'#more-\$2" onclick="getData(\''.\$id.'\',\'post\');return false;">'.\$postMore.'</a>]</span><span id="viewBox-p'.\$id.'" class="viewBox" style="display: none;"></span><span id="close-p'.\$id.'" style="display: none";>« [<a href="'.get_permalink().'#more-\$2" onclick="closeView(\'p'.\$id.'\');return false;">'.\$postLess.'</a>]</span>'.\$postLinkPostfix.' [<a href="'.get_permalink().'">Permalink</a>]'), \$content);
In the "getPost" function, I added the lines:
-
global $post; -
\$post->ID = $id;
These were required to allow the footnotes plugin to create its anchors properly.
In the same function, I replaced the lines beginning \$content=explode(...) with:
\$content=explode(\$token,apply_filters('the_content',\$post_content),2); if (count(\$content)==2) { echo \$content[1]; }
This was needed so that plugins can apply filters to both parts of a text separated by the <!--more--> tag.
Finally, in the line gE('viewBox-'+postID).style.display = 'block';, I changed block to inline.
The above changes allow the post to be collapsed in the middle of a paragraph (or of a sentence, even).
There's a slight bug in the integration of the The Ajaxified Expand Post NOW Plugin with jsMath. Currently, mathematical formulas after the <!--more--> tag do not get processed. To get around this, in posts where formulas appear after the <!--more--> tag but not before, an empty equation needs to be inserted before the tag to force jsMath to load. Furthermore, the plugin code needs to be edited to add these lines to the end of the "fetchDone" function:
jsMath.ConvertTeX('viewBox-'+postID);
jsMath.Process('viewBox-'+postID);
Come to think of it, there's probably nothing I can do about this. The reason is that if there are any error messages (jsMath is missing fonts, and so on), they have to be displayed at the top of the site. There's no way this can happen if jsMath is loaded dynamically through Ajax when a post is expanded.
OpenID
The OpenID plugin has a bug which prevents trackbacks and pingbacks from working. See here for the fix. This is fixed in the latest version.
WP-Syntax (GeSHi)
The WP-Syntax plugin needs to escape special characters. See here for the fix.
Move geshi to the common subdirectory, since it's also used by MediaWiki. Change the line include_once("geshi/geshi.php") to include_once(getenv("DOCUMENT_ROOT") . "/common/geshi/geshi.php").
WP-reCAPTCHA
After setting the tab index in the options, the "comments.php" file has to be edited to change the tab index of the "Submit" button, so that the reCAPTCHA appears between the comment and the submit button.
Subscribe to Comments
The Subscribe to Comments plug-in likewise needs to be edited so that its checkbox appears just before the reCAPTCHA. The "comments.php" file needs to be edited to allow users to subscribe to comments even if they haven't commented, by adding a call to show_subscription_checkbox(). I've also edited the plugin to insert some tab index information.
The plugin needs to be edited in a number of places to make it compatible with WordPressμ, especially its concept of roles and capabilities. In particular, references to current_user_can('manage_options') should be changed to current_user_can('publish_posts') (to enable editors and blog posters who are not administrators to manage subscriptions). Also, SQL queries to SELECT comments need to have AND comment_type = '' added, so that pingbacks and trackbacks are ignored.
A minor cosmetic change: the "Return to the page you were viewing" link was changed so that it goes to the "#respond" anchor on that page.
Yet Another Related Posts Plugin
There's a bug in version 3.0.13 of YARPP which adds slashes in front of quotation marks for several options on the options page. See here.
Sociable
The Sociable, YARPP, and AEPN plugins interact with each other in a bad way. Sociable and YARPP work together in single posts. However, when they are used together with AEPN, inside an expanded post (say, on the front page) the Sociable plugin interferes with the YARPP plugin so that the latter displays the wrong list of related posts.
I don't know how to fix this, except to turn off the option to "Automatically display related posts", and then adding a call to related_posts() to the K2 hook template_entry_foot.
K2 Rolling Archives
In the "themes/k2/js/k2.functions.js" file, change the "smartPosition" function to the following:
/* Fix the position of an element when it is about to be scrolled off-screen */ function smartPosition(obj) { if ( jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 ) { return; } jQuery(window).scroll(function() { // Detect if content is being scroll offscreen. var rollingarchives = document.getElementById('rollingarchives'); if ( (document.documentElement.scrollTop || document.body.scrollTop) >= jQuery(obj).offset().top) { jQuery('body').addClass('smartposition'); rollingarchives.style.left = '' + (345 - document.documentElement.scrollLeft) + 'px'; } else { jQuery('body').removeClass('smartposition'); rollingarchives.style.left = '0px'; } }); };
The value of 345 was determined experimentally. There's probably a better (cleaner) way to do this!
Kses hack
The tags "ref", "references", and "wikindx" had to be allowed through a so-called "kses hack", so that footnotes and citations would work.
I had to edit the "wp-includes/kses.php" file to include "market" as an allowed protocol, to allow links to Android Market.
Incompatible plugins
Some plugins written for WordPress may be incompatible with WordPressμ. In some cases, it may be impossible to update the plugin's options. A hack to get around this is to comment out any "check_admin_referer" lines in the plugin, change the options, and then uncomment those lines.
Wiki (MediaWiki)
Major changes to the skin, obviously. The original settings for the sidebar were:
- SEARCH
- navigation
- mainpage|mainpage-description
- portal-url|portal
- currentevents-url|currentevents
- recentchanges-url|recentchanges
- randompage-url|randompage
- helppage|help
- TOOLBOX
- LANGUAGES
Note that to edit the sidebar, just edit the special wiki page MediaWiki:Sidebar.
The CSS for the site is found at MediaWiki:Common.css.
Forums (bbPress)
In the "header.php" file, add the line "<script type='text/javascript' src='http://www.stargrads.net/jsMath/easy/load.js'></script>" to load jsMath.
Bibliography (WIKINDX)
To write the name of the software, use "<span style="font-variant: small-caps;">Wikindx</span>", which shows up as
Wikindx.
Calendar (WebCalendar)
These pertain to WebCalendar 1.20.
There's a bug that prevents WebCalendar from display pages with untimed events if using PHP 5.2.8 and up. Typically the web server returns a zero-sized reply. See this post for the fix.
There's another bug that prevents user/group selection pages from displaying with the error "Program Error: No Form Specified". See here for the fix.
Equations (jsMath)
The following code was inserted into the header files of the templates for this web site:
<script type="text/javascript" src="http://path.to/jsMath/easy/load.js"></script>
To get equations to display correctly in WIKINDX, curly brackets have to be escaped correctly. Replace each "{" with "{{}" and each "}" with "{}}".
When updating, don't forget to save the customised macros and the installed fonts.
See above for a slight bug with the Ajaxified Expand Post NOW Plugin in regards to jsMath.
Web Analytics (piwik)
When upgrading piwik, pay special attention to the config and tmp subdirectories, especially their permission settings.
There are plugins available for WordPress and MediaWiki, but for now, the piwik code is just going into the template.





