Nov 192012
 

Just released a new version of Now Reading Redux, version 6.7 with a number of fixes and improvements.

Highlights include fixes to Amazon searching, templates, CSS styles and a new nrr_shelf shortcode to generate book lists in posts like the Library page does. I’ve addressed a number of user-submitted bugs, so hopefully some complaints are answered.

Please don’t be shy to give feedback, make suggestions or ask question on the project’s home, on GitHub or WordPress.

Here is the changelog:

6.7.0.0

  • WordPress 3.4 support.
  • Fixed: The wp-config.php file may be either in its default folder or a folder above it. See Hardening WordPress. (Thanks to Alex for this request.)
  • Fixed: Replaced file_get_contents() with url_get_contents() which is based on cURL/Snoopy and doesn’t suffer PHP settings. file_get_contents() required enabling allow_url_fopen in php.ini which some servers disallowed. (Thanks to Tom Saunders, TechnoMom, unsicherheitsserver, inktails and others for reporting).
  • Improved the robustness of Amazon searches, debugging and error-reporting. Also, untitled books are now show with the title “Untitled” (previously they were skipped).
  • Fixed: Removed hard-coding of styles from shelf and using CSS class nr_booktitle and nr_bookauthor for the title and author respectively. Also, new classes include nr_viewlibrary, nr_wishlist, nr_nobooks. Apply default CSS styles in NRR options page to get new default styles.
  • Fixed: Redesigned templates to use correct and up-to-date styles and better WordPress integration.
  • New options: Library Title and Wishlist Title options added.
  • New option: “Use Theme templatates” to control whether or not to load theme-specific templates or defaults. Themes can have ‘now-reading’ or ‘now-reading-redux’ folders added to the TEMPLATEPATH and by enabling this option the templates will be loaded from there. Suffusion makes use of this approach as it has heavily customized templates and the defaults don’t render so well (although latest templates are much better in this regard.) For Suffusion you’re advised to copy the templates from NRR’s suffusion subfolder into Suffusion’s now-reading subfolder and enable “Use Theme templates”. Don’t forget to repeat this every time you update Suffusion!
  • Added: NRR shortcode nrr_shelf added. Supports all rendering styles and filtering options supported in the Library page. See FAQ for doc and sample.
  • Improved book statistics and average reading rate calculation. Statistics may be calculated by books being read per-month as well as books finished per-month (no external option, just internal function implementation).
  • Improved nrr-generated page-titles shown in the browser caption-bar.
Share
Jan 012012
 

The latest version of WordPress plugin Now Reading Redux was released on New Year’s eve. It has many awaited features that should prove very useful.

The main focus of this release has been, by and large, to refurbish the plugin and make it more flexible and usable. To that end there were two main types of changes. First, a new set of options were introduced to make the main templates vastly more customizable and thereby reduce the need to make manual changes to the template files themselves. Second, a number of internal cleanups were performed to make the plugin code more up-to-date with WordPress. In that vein, the minimum WP required version was bumped from 2.8.0 to 2.9.0.

These changes, which are both user-visible and internal, are by all measures the biggest done in the Redux incarnation. As versions 6.2 and 6.3 were internal, 6.4 was skipped and 6.5 was chosen to mark the significance of this release.

There is a lot more work and a longish todo list waiting for realization. My main goals are to make NRR as flexible and as usable to as wide an audience as possible and to make the plugin more active and interactive. As it is, the plugin just passively shows off the owner’s library of books. This is less than satisfactory in an age of interactive networking. Without going into much details, what I’d love to see in this plugin is the ability to share, exchange and even interact with anyone’s library. Much like we did when we visited a friend and went through their albums, commenting, comparing, borrowing and trading.

I’d also like to see more people using the plugin and upgrading from the older versions that are out there in the thousands. So I ask the users of NRR to rate it on WordPress, add their feedback on the plugin’s homepage, report bugs and issues on git (or on the homepage,) and to make suggestions for improvements and feature requests. To help promote the plugin, I’ve added a link from the widget to the homepage that is hidden only to become visible on mouse hover.

I hope this plugin encourages people to read more and talk about books and the ideas contained therein more than ever. I hope it’s a good aid to those who have a reading list but procrastinate or can’t get organized to create the time necessary to finish a book before dust collects and it becomes a reminder of unfinished business.

Share
Apr 102011
 

The WordPress plugin I use to manage my reading list is an updated version of the popular Now Reading plugin, called Now Reading Reloaded.

Original NRR book management page.

The original Now Reading plug was developed by Rob Miller who stopped maintaining it at around WP2.5. Luckily, Ben Gunnink at heliologue.com picked up where Rob left off and gave us Now Reading Reloaded (NRR). Unfortunately, it seems that the maintainer has no time to donate to the project and ceased maintaining it.

As one can see, the plugin is a great way to organize and share reading lists. This is exactly what I was looking for when I searched the WP plugin database. Up until then I was tracking my reading lists using simple lists in WP posts and pages. The database back-end of NRR gives it much more potential than one can hope to achieve with simple lists. This is not to say anything of the Amazon search-n-add feature with link and thumbnail of the book cover. All very welcome features.

Limitations

Unfortunately, NRR is far from perfect. One can run into it’s quirks multiple times during a single book update. But, for the price, I can’t complain. None of the issues were too big to annoy me enough to get my hands dirty debugging and patching the code. None, that is, except for a little obvious feature conspicuously missing. By the time I added most of the books I had in my lists and started updating what I read and adding current-reading items, I wished I didn’t have to jump from page to page until I found the book I had just finished to update its status. That is, I wished I could simply sort my library by status, started-reading or finished-reading dates. Even better, I wished by default the library showed me the latest books I started reading, which I was most probably interested in updating.

While open-source programs are great for too many reasons to list here, they all suffer from the same problem. Namely, the freedom to update the code also, by definition, forks and diverges it from the source. This immediately adds the overhead of merging any updates or bug-fixes added to the source to your hand-modified version. However, since it seems that NRR is no longer maintained, I had no reason to fear such a hustle and I still had all the reasons to get sorting functionality in the admin library page, also known as the Manage Books page.

Figuring out the code

First test with new sorting code.

First I had to figure out the wheres and the hows of the code. I wasn’t familiar with NRR, so I had some detective work ahead of me. First, I browsed the page in question: wp-admin/admin.php?page=manage_books. I browsed the pages and noticed how the URL was formed. Apparently, selecting the page to display is chosen by specifying a ‘p’ argument and the index of the page. For example, the second page would be /wp-admin/admin.php?page=manage_books&p=3. Next I had to find the PHP file responsible for generating this page. Since each plugin is stored in its own separate folder, first place to look in was the NRR plugin folder within my WP installation. On my WP3.1 installation, this folder is at /wp-content/plugins/now-reading-reloaded/admin. Within this folder a few PHP files exist with the “admin” prefix. The file “admin-manage.php” seems a reasonable start. I looked for any table construction code that resembles the Manage Books page, and sure enough it’s right there.

Patching

Page sorting works.

(Note: Breaking the PHP files may leave your WP in limbo. Make sure you have backup of your site before you make manual changes, and that you can replace broken files via ssh or ftp.)

The key to adding sorting is to figure out how the database query is generated. This, as it turns out, wasn’t very difficult to find. Within the admin-manage.php file the get_books function contains the complete query

$books = get_books("num=-1&status=all&orderby=status&order=desc{$search}{$pageq}{$reader}");

From this, it’s quite obvious which filter is responsible for what. The ‘orderby’ filter selects the sorting column, ‘order’ decides the direction of sorting and the rest are for searching, pagination etc. Instead of using hard-coded values, we need to get these values from the browser. Let’s add a couple of optional parameters to the page:

            if ( empty($_GET['o']) )
                $order = 'desc';
            else
                $order = urlencode($_GET['o']);

            if ( empty($_GET['s']) )
                $orderby = 'started';
            else
                $orderby = urlencode($_GET['s']);

So ‘o’ will decide the ‘order’ and ‘s’ the ‘orderby’ value. Before I move on, I have to test that this is working in practice and not just in theory. Manually loading the page with the newly added parameters give the expected results. /wp-admin/admin.php?page=manage_books&s=author&o=asc loads as expected the table of books, sorted by the author name in ascending order. Now, all we have to do is add links to the column headers and we can get a working page.

			if ( $order == 'asc' )
				$new_order = 'desc';
			else
				$new_order = 'asc';

			$book_link = "{$nr_url->urls['manage']}&p=$page&s=book&o=$new_order";
			$author_link = "{$nr_url->urls['manage']}&p=$page&s=author&o=$new_order";
			$added_link = "{$nr_url->urls['manage']}&p=$page&s=added&o=$new_order";
			$started_link = "{$nr_url->urls['manage']}&p=$page&s=started&o=$new_order";
			$finished_link = "{$nr_url->urls['manage']}&p=$page&s=finished&o=$new_order";
			$status_link = "{$nr_url->urls['manage']}&p=$page&s=status&o=$new_order";

            echo '
				<table class="widefat post fixed" cellspacing="0">
					<thead>
						<tr>
							<th></th>
							<th class="manage-column column-title"><a class="manage_books" href="'. $book_link .'">Book</a></th>
							<th class="manage-column column-author"><a class="manage_books" href="'. $author_link .'">Author</a></th>
							<th><a class="manage_books" href="'. $added_link .'">Added</a></th>
							<th><a class="manage_books" href="'. $started_link .'">Started</a></th>
							<th><a class="manage_books" href="'. $finished_link .'">Finished</a></th>
							<th><a class="manage_books" href="'. $status_link .'">Status</a></th>
						</tr>
					</thead>
					<tbody>
			';

Notice that I didn’t forget to invert the current sorting order in the link. This is pretty straight forward. Reloaded the page, tested the header links and sure enough all was well. One thing missing is the page selection links – they don’t obey the current sorting. The page selection links had to be patched as well:

                $pages .= " <a class='page-numbers prev' href='{$nr_url->urls['manage']}&p=$previous&s=$orderby&o=$order'>«</a>";
                $pages .= " <a class='page-numbers' href='{$nr_url->urls['manage']}&p=$i&s=$orderby&o=$order'>$i</a>";
                $pages .= " <a class='page-numbers next' href='{$nr_url->urls['manage']}&p=$next&s=$orderby&o=$order'>»</a>";

New default book management page view.

Download

Perfecto! Works great.

One last thing I thought would be useful was to reorder the columns, such that it’s “Book, Author, Status, Started, Finished, Added” instead of the default “Book, Author, Added, Started, Finished, Status”. Because frankly, I don’t care much when I added a book, I care most about its current status and when I started reading it. Once I’m done, I want to set the Finished date and move on to the next. After reordering the columns, I set the default sorting on the Started date and in descending order, as you can see in the screenshot.

Download NRR v5.1.3.2 with the sorting patch.

Share
QR Code Business Card