Blogs

Liferea Trick #1: Middle Mouse Button Clicking

Give a +1 if you found this post useful!

For all the readers of this development blog I want to share same hidden usability things in Liferea. Today I want to start with using the 3rd mouse button.

Place Where To Use Middle Click

  1. Subscription List: Click on any subscription or folder to mark everything in the subscription or folder as read.
  2. Item List (on flag column): Click on the flag column to toggle the flag for an item without selecting it.
  3. Item Lists (except flag column): Click everwhere beside the flag column and you toggle the read status of the item even without selecting it.
  4. Browser View: In any browser view, be it a browser tab or the item view pane middle click any link to open it in a new browser tab within Liferea.

How To Debug PgBouncer

When you use Postgres with pgbouncer when you have database problems you want to have a look at pgbouncer too. To inspect pgbouncer operation ensure to add at least one user you defined in the user credentials file (e.g. on Debian per-default /etc/pgbouncer/userlist.txt) to the "stats_users" key in pgbouncer.ini:

stats_users = myuser

Now reload pgbouner and use this user "myuser" to connect to pgbouncer with psql by requesting the special "pgbouncer" database:

psql -p 6432 -U myuser -W pgbouncer

At the psql prompt list the supported pgbouncer commands with

SHOW HELP;

PgBouncer will present all statistics and configuration options:

pgbouncer=# SHOW HELP;
NOTICE:  Console usage
DETAIL:  
	SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|VERSION
	SHOW STATS|FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM
	SET key = arg
	RELOAD
	PAUSE []
	SUSPEND
	RESUME []
	SHUTDOWN

The "SHOW" commands are all self-explanatory. Very useful are the "SUSPEND" and "RESUME" commands when you use pools.

Liferea 1.10.2 Released

This is a bugfix release fixing tray icon minimizing. It also adds seeking to the media player. Please upgrade.

The Changes:

* Patch SF #222: Make media player seekable
  (Simon Kågedal Reimer)
* Fixes SF #1102: Spelling error in man page
  (David Smith)
* Fixes SF #1104: liferea.desktop missing keywords
  (David Smith)
* Fixes SF #1105: Start Minimized to Tray Does Not Work
  (reported by bitlord)
* Fixes SF #1114: Crashes opening browser on item without link via popup
  (reported by Rich Coe, David Smith)
* Improved handling of broken Atom author information.
  (Lars Windolf)
* Removed dead Google Reader code to avoid doing requests to Google.
  Replaced with dummy source that even allows normal feed updates.
  (Lars Windolf)
* Added hint to FAQ on how to workaround broken Flash support
  (Lars Windolf)
* Dumping feedlist.opml with indentation for readability.
  (suggested by Christoph Temmel and Simon Kågedal Reimer)

MySQL Dump Skip Event Table

If your MySQL backup tool or self-written script complains about an event table than you have run into an issue caused by newer MySQL versions (>5.5.30) that introduced a new table "events" in the internal schema.

If you run into this you need to decide wether you want to include or exclude the new events table when dumping your database.

To skip: Due to a MySQL bug #68376 you have two choices. You can check documentation and add the logical option

--skip-events

which will cause the event table not to be exported. But the warning won't go away. To also get rid of the warning you need to use this instead:

--events --ignore-table=mysql.events

And of course you can also choose just to dump the events table: Add the option

--events

to your "mysqldump" invocation. If you use a tool that invokes "mysqldump" indirectly check if the tool allows to inject additional parameters.

/etc/sudoers.d Pitfalls

From the sudoers manpage:

[...] sudo will read each file in /etc/sudoers.d, skipping file names 
that end in ~ or contain a . character to avoid causing problems with 
package manager or editor temporary/backup files. [...]

This mean if you have a Unix user like "lars.windolf" you do not want to create a file

/etc/sudoers.d/lars.windolf

The evil thing is neither sudo nor visudo warns you about the mistake and the rules just do not work. And if you have some other definition files with the same rule and just a file name without a dot you might wonder about your sanity :-)

How to Get Flash Working with WebkitGTK3

With the switch to GTK3 all Webkit using applications like Epiphany, Liferea, devhelp, yelp and others lost Flash support. The reason is that Linux-Flash is GTK2 only! And of course there won't be new releases from Adobe ever. So we have the following compatibility situation for Liferea

Release
Line
Uses Flash Status
1.6
1.8
GTK2 + WebkitGTK2 any native Flash Works
1.10 GTK3 + WebkitGTK3 v1.8 32bit native Flash Broken
1.10 GTK3 + WebkitGTK3 v1.8 64bit native Flash Broken
1.10 GTK3 + WebkitGTK3 v1.8 32bit Flash + nspluginwrapper Works
1.10 GTK3 + WebkitGTK3 v2.0 any native Flash Works

The WebkitGTK+ solution for the Flash problem was implemented in version 2.0 by having a second process linked against GTK2 to run browser plugins while Webkit itself is linked to GTK3. This makes Flash work again.

But the currently widely distributed WebkitGTK3 v1.8 does not have this feature yet and fails to use the native flash.

nspluginwrapper Workaround

The only workaround is to use nspluginwrapper to run the 32bit version of Flash. This is guaranteed to work on 64bit platforms. It might not work on 32bit hardware, sometimes also because nspluginwrapper is not available there. The steps to install it are:

  1. Install nspluginwrapper. On Debian
    apt-get install nspluginwrapper
  2. Download 32bit Flash .tar.gz from Adobe
  3. Extract /usr files according to the Adobe instructions
  4. In the tarball directory run
    nspluginwrapper -i -a -v -n libflashplayer.so

    to install the plugin

Now all WebkitGTK3 using applications should be able to run Flash. Ensure to restart them and check command line output for any plugin errors.

Upgrading to WebkitGTK3 2.0

If you can try upgrading to WebkitGTK3 2.0 (e.g. Debian Experimental).

PHP preg_match() Solutions for Typical Tasks

This post is to give an overview of when and how to use preg_match(). You will find that several task descriptions actually tell you not to use preg_match() which often is the first solution we think of when not knowing the PHP specific "best solution".

Extract date with preg_match

Format: DD.MM.YYYY

preg_match('/(?P<day>\d{2})\.(?P<month>\d{2})\.(?P<year>\d{4})/', $string, $result);

Format: MM/DD/YYYY

preg_match('/(?P<month>\d{2})\/(?P<day>\d{2})\/(?P<year>\d{4})/', $string, $result);

Format: YYYY-MM-DD

preg_match("/(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})/", $string, $result)

All three examples take the date to parse from $string return the day, month and year values in the $result hash. On successful matching $result will contain a result like:

array('year' => 2013, 'month' => 08, 'day' => 01);

Match IP with preg_match

To match an IPv4 address you can simply use:
preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $string, $result);

But as explained on StackOverflow this won't work for IPv6 and there is a better solution:

filter_var($var, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);

And for IPv6

filter_var($var, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);

Match Hostname with preg_match

Again a solution from StackOverflow, note that you need to do several checks for characters, total length and part length. For perfect RFC compliance this is propably not enough, but still good enough to untaint a hostname string:

function is_valid_domain_name($domain_name)
{
    return (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain_name) //valid chars check
            && preg_match("/^.{1,253}$/", $domain_name) //overall length check
            && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name)   ); //length of each label
}

Match Email Address with pgreg_match

First: Do not try to develop something yourself!. If you still think you can start reading this LinuxJournal article and the respective RFCs. This is of course more complex than the host name matching as an email address usually contains one.

The IMO most interesting solution in PHP is to use checkdnsrr() and was described by this devshed article. It boils down to

  1. Sanity checking characters
  2. Extracting host name
  3. Testing host name by MX record lookup with checkdnsrr()

So this solution even gives up one checking the hostname syntax by just resolving it. This solution of course only works if you do not have to do too many checks per second. This might not be a good solution for massive checking without having a DNS cache in place.

When you still want to do only syntax matching try to use the PHP filter

filter_var($email, FILTER_VALIDATE_EMAIL)

Match HTTP URL with preg_match

Another case of do not try. Use the PHP filter instead:

filter_var($url, FILTER_VALIDATE_URL)

Extract HTTP URL with preg_match

Another case of do not try. Use the PHP function parse_url() instead. The example from the PHP manual shows how:

Run

parse_url('http://username:password@hostname/path?arg=value#anchor');

and it returns an array with all the parts:

Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)

Liferea Sync Support Status (TinyTinyRSS, TheOldReader, Feedly, AOL Reader, Digg Reader)

There is slow progress in the world of news aggregation services. Since the last post on possible sync implementations I was able to submit API access requests for AOL Reader and Feedly. There is a chance that the request for AOL Reader will be successful. The unexpected thing with AOL is that they require OAuth2 authentication which Liferea does not yet support. Still it will be possible to add it.

My clear favourites are still AOL and Digg. With two 3rd party hosters and one self-hosted solution (TinyTinyRSS) Liferea would provide a reasonable set of choices.

Name API Status Implementation Status
Google Reader Deprecated Implemented, Now Useless
TinyTinyRSS Published. Implemented, Stable
TheOldReader Published. Implemented, Experimental
AOL Reader Published API Key Requested
Digg Reader Planned 1) %
NewsBlur Published Not Planned.
Feedly Secret 2) API Access Requested

1) Digg has announced they will be implementing Google Reader API and hope is they open it up
2) Feedly has announced there will be a public API with v17

Liferea 1.10 GnomeKeyring Issue

If you are using 1.10 with the GnomeKeyring plugin, which will be automatically activated in GNOME environments, you might run into a strange bug (see SF #1099).

It appears that the keyring "liferea" created by the plugin can become "stale" - it just doesn't work anymore. At the moment I have no idea what triggers this and what is exactly the problem. If this happens Liferea cannot store passwords into the keyring anymore and you get password prompts all the time.

Workaround: Delete the "liferea" keyring from GnomeKeyring using the "seahorse" keyring editor. Ensure you have installed "seahorse" and launch it from the command line

seahorse

and delete the keyring as shown in the screenshot:

Syndicate content