Saturday, 29 May 2010

Organising publications using KRename

I have to work with lot's of scientific publications at the moment. That means, I have a large directory with many PDFs that are related to my work. Sometimes, it is cumbersome to find the right PDF or publication to look something up. Of course, I could rename every PDF after I downloaded it by hand, but - you might guess it - I am to lazy for this.

But help is in sight! I added a plugin to KRename, which can rename files based on meta-data included in PDF files. Organising a large set of publications is now a matter of adding the PDF files to KRename and using the template "[pdfAuthor] - [pdfTitle]". Convenient, isn't it? The screenshot below shows KRename while renaming a few PDF files.



The supported tags are [pdfPages] (number of pages), [pdfProducer], [pdfTitle], [pdfSubject], [pdfKeyword], [pdfCreator] and, [pdfAuthor]. If you have an idea for further meta-tags, do not hesitate to contact me. It should be quite easy to add more information, the current implementation is a matter of 10 lines thanks to the PoDoFo library used.




A pity is that many PDF authors do not add proper meta-data to their PDF files. So, if you are writing on a publication at the moment, please make sure you add your information to the PDF metatags.

This feature is currently only available in KRename SVN trunk.

Thursday, 29 April 2010

PoDoFo Base 14 Font support

Today has seen a major contribution to the PoDoFo PDF library.

I integrated a patch by Ian Curington and his developers, which brings support for using the base 14 fonts in PDF files. What are the base 14 fonts, you might ask?

Every PDF viewer has to ship with these 14 fonts, therefore one can achieve much smaller file sizes, as these particular 14 fonts do not have to be embedded into the PDF. Still, the PDF is displayed the same on every system (should be displayed ...), as every PDF viewer has the same font metrics for these fonts. Among the base 14 fonts are Helvetica, Times, Courier and Symbol.

This contribution makes the base 14 fonts available to everyone creating PDFs using PoDoFo. As the base 14 fonts are automatically used, whenever you request a PdfFont like Helvetica, this should result in much smaller file sizes for PDFs created with PoDoFo, which only use these fonts. An example which does also compare one of the base 14 fonts (Helvetica) to a TrueType font (Arial) is also provided. Okular has some problem displaying the symbol fonts, which I have yet to investigate.

If you would like to try the change, please grab the latest PoDoFo from SVN. The change is not included in the latest 0.8.0 release.

Tuesday, 6 April 2010

A web-radio plasmoid for your desktop

Since I am in Limerick, Ireland, I started to listen quite a lot to RTÉ 2XM, which is a great web-radio station of the public broadcasting service in Ireland (Click for webstream).

RTÉ has a quite nice applet for the Windows Vista or Windows 7 sidebar. Unfortunately, the do not yet offer one for KDE and Plasma. Instead of waiting for the applet, I wrote a little web-radio applet by myself yesterday.



The plamoid has a simple list of radio stations and a play and a stop button. Easy, isn't it? Of course you can configure the list of stations. If you download and install it, it comes preconfigured with all the RTÉ stations and my favourite Austrian station FM4.



You can download the plasmoid from here: http://krename.sourceforge.net/data/plasmaradio-0.1.tar.gz.

To install the plasmoid, follow the following steps after downloading it:

tar xvfz plasmaradio-0.1.tar.gz
cd plasmaradio-0.1
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$KDEDIRS ..
make
make install


I would be happy to receive some feedback on this little piece of code. By the way, I think it really shows what great stuff can be done in so little time using the KDE4 API.

Wednesday, 24 February 2010

Detection of architecture violations in C/C++ applications

In a small project, I am experimenting with a cleaner and in this case layered architecture for certain parts of PoDoFo. I think it is a quite usual problem, to have an architecture and a grown application and you would like to check whether the sources adhere to the previously defined architecture. Therefore, it is important to have tools to check for architecture violations. These can be used to validate the architecture at certain points of time or even after each commit to the source repository on a continuous integration server.

I did not know any tool which can easily do this kind of validations for C/C++ source code, so I came up with a small bash script that does exactly this. The only configuration needed are some rules that define the architecture. Architecture is in this case a layered architecture where certain modules are only allowed to include certain other modules. See image 1 for a small UML diagram of the architecture.



These rules can be edited at the top of the script:

RULES="content->structure \
content->datatype \
content->io \
content->util \
structure->datatype \
structure->io \
structure->util \
datatype->io \
datatype->util \
io->util \
content->fontconfig \
content->Carbon \
util->\.\. \
src->.* \
.*->tr1 \
.*->sys"

As you can see, it is also possible to use regular expressions. Also, I had to add some rules for includes like fontconfig (external libraries) that are not available in the UML diagram above.

The script produces quite a lot of output, but grepping for "violation" shows only the important results:


If you are interested you can get the bash script from here: check_architecture.sh The script should be self-explaining and pretty easy to adapt to your needs.

Sunday, 14 February 2010

Building KRename trunk from SVN

I just noticed that there is no up to date documentation on how to build KRename trunk from SVN on our website. Well, everyone who is interested in getting the latest version of KRename and does not want to wait for the next release - these are the steps to get KRename trunk from SVN and build it.


svn co https://krename.svn.sourceforge.net/svnroot/krename/trunk krename
cd krename
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$KDEDIR ../
make
sudo make install


This assumes that $KDEDIR is an environment variable pointing to your KDE installation. You can set $KDEDIR using the following bash command:

export KDEDIR=/usr


Most other KDE applications can be built the same way.

Saturday, 6 February 2010

Generic web-service queries on your desktop using Plasma

Some days ago, I applied for a new passport. In Munich, where I currently live, you apply for the passport at the city hall and usually can pick the passport up there 3 weeks later. I was surprised to see that they have a new service: You get an ID number with which you can check the status of your passport via a web-service. So, if you check regularly, the web-service will tell you when your
passport is ready to pick it up.

What is the usual you do in cases like that? Of course, you write a Plasmoid that checks the web-service periodically and informs you when your passport is ready. This plasmoid - PersonalKwery - can be seen in screenshot 1.


Thinking further about this quick hack, I came to the conclusion that with only a little bit of work, I could create a generic plasmoid that can query webservices and display the result on your desktop. I managed to create a plasmoid that takes the following configuration:

  • Base URL of the web-service

  • Attributes to the URL (like the ID number of my passport, or arguments to a Google query)

  • An optional XSLT to transform the results

  • An interval, how often the query should be performed



With this little configuration you can easily query many web-services. Of course, most users won't be in the mood to create their own XSLT transformations! Therefore it is possible to store the configurations as XML and share them - for example over "get hot new stuff". In this case, users can
download predefined web-service queries and only have to enter a few necessary attribute values. The screenshot below shows the configuration dialog for a query:


Another small example is a simple query, that get's your current internet IP address.


Of course, the tool is not perfect yet and can be made more user friendly. If you are interested, you can get the tarball here: personalkwery-0.1.tar.gz.

Sunday, 29 November 2009

"Modifiers" in KRename

Andi Clemens did some amazing work on the batch renamer included and integrated into digiKam. I really like the simple UI and some of the features he included. I think I can get some inspiration from him for KRename (e.g. syntax highlighting).

Lately he posted over the topic of "Modifiers" in the digiKam rename tool, which he added to digiKams renamer and was not able to find in KRename. Modifiers are a way to convert a token, let's say the name of a directory or the artist of a mp3 in some way before inserting it. For example if you insert the name of the directory into the new filename and the directory name is in all uppercase and to match the look of the new filename, you want it to be inserted in lowercase. In digiKam's renamer it is achieved by the token:
[dir.]{lower}

In KRename you would use:
[%dirname.]

So contrary to Andi's post, KRename has modifiers, too. You can add a modifier before any token (after the opening bracket and before the actual name of the token). The modifierst are those used to insert filename's and convert there case. To list the most important ones:





$No conversion, insert the token as it is
%Convert to lowercase
&Convert to uppercase
*Convert every first letter in a word to uppercase
##Format a number with leading zeros


So you can even use modifierst to format numbers for tokens that return number. For example [##tagTrack] will insert the track number of a MP3 formatted with one leading zero if the track number is less than 10.

It is true that KRename does not have a really readable syntax for modifiers here, I think appending {upper} or {lower} like digiKam does it, is a good idea. But there are several other places, too, where the KRename syntax could be improved. I hope that this post will help a few people that also did not know about this feature.

Modifiers in action