This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Creating comic plugins (for comic plasmoid)

Tags: None
(comma "," separated)
mat69
KDE Developer
Posts
45
Karma
0
The following tutorial describes how to create your own comic plugin.

I hope they give enough information to be usefull for you. If you have some questions post them here.

http://techbase.kde.org/Development/Tut ... omicPlugin


mat69, proud to be a member of KDE forums since 2008-Oct.
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
Is there a qtscript function for padding numbers with some character? Particularly zero-padding to a certain number of digits (like turning 123 to 00123)? A lot of "number" type comics seem to use zero-padding in the file names so I would like to know if there is a simple way to do this.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
mat69
KDE Developer
Posts
45
Karma
0
I have to admit I'm not sure if there is a build in function, I doubt that though.

You can easily create your own function though, that you'd simply reuse in all the cases it is needed:

Code: Select all
function addPaddingZeros(number, desiredLength)
{
    var num = number.toString();
    while(num.length < desiredLength) {
        num = '0' + num;
    }

    return num;
}


mat69, proud to be a member of KDE forums since 2008-Oct.
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
I found another way to do it. If you want to pad to four digits, use:

Code: Select all
String("000" + comic.identifier).slice(-4)


If you need another number of digits, use a list of zeros one less than the pad length and set the number in the slice part to be equal to the pad length.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
I am having another issue. The data engine is somehow figuring out what the next and previous comic page url should be based on some pattern, even though I am not explicitly defining it. The problem is that, for this particular comic, at a certain point the pattern the url follows changes. So when the data engine reaches that point it fails. So I need some way to get it to change the pattern it is using at that point (going in both directions). Any ideas? Basically the subdirectory the comic is stored in changes.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
mat69
KDE Developer
Posts
45
Karma
0
TheBlackCat wrote:I am having another issue. The data engine is somehow figuring out what the next and previous comic page url should be based on some pattern, even though I am not explicitly defining it. The problem is that, for this particular comic, at a certain point the pattern the url follows changes. So when the data engine reaches that point it fails. So I need some way to get it to change the pattern it is using at that point (going in both directions). Any ideas? Basically the subdirectory the comic is stored in changes.


It only (in theory, maybe you found a bug) does that -- figuring out what prev and next are -- if you do not set these yourself.


mat69, proud to be a member of KDE forums since 2008-Oct.
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
How do you set the full previous and next url (or the previous and next subdirectory)? I can only see how to set the previous and next identifier, which won't help me because it is not the file name pattern that changes but the subdirectoy the files are stored in.

Last edited by TheBlackCat on Fri Mar 20, 2009 2:19 pm, edited 1 time in total.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
mat69
KDE Developer
Posts
45
Karma
0
TheBlackCat wrote:How do you set the full previous and next url (or the previous and next subdirectory)? I can only see how to set the previous and next identifier, which won't help me because it is not the file name pattern that changes but the subdirectoy the files are stored in.


Ah, now I understand.

You can not set the url of the next/prev you can only set the identifier.

Clicking next will make the next-identifier to the current identifier. You have to handle what url should be used manually. This might not be ideal, but it worked so far. What comic has this problem?


mat69, proud to be a member of KDE forums since 2008-Oct.
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
How do I handle what url should be used manually?

www.zebeth.com changes subdirectories between comic 999 and 1000.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
mat69
KDE Developer
Posts
45
Karma
0
TheBlackCat wrote:How do I handle what url should be used manually?

www.zebeth.com changes subdirectories between comic 999 and 1000.


I did not examine zebeth that closely, but something like the following should do it.

Code: Select all
function init()
{
...
  if(comic.identifier < 1000) {
    comic.websiteUrl = "http://www.zebeth.com/planetzebeth/archives/z" + comic.identifier + ".html";
  else {
    comic.websiteUrl = "http://www.zebeth.com/planetzebeth/archive1k/z" + comic.identifier + ".html";
  }
  comic.requestPage(comic.websiteUrl, comic.Page);


I did that "code" out of my head, so there might be some errors inside.

Last edited by mat69 on Sat Mar 21, 2009 8:10 pm, edited 1 time in total.


mat69, proud to be a member of KDE forums since 2008-Oct.
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
Thanks, that seems to work. I tried doing something like that, but I put it in pageRetrieved and it caused an endless loop.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
Another question. In some of the source code of the comics I am getting things like "&#8230;". I assume this is some sort of formatting or special character. Is there a way to handle these properly?


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
mat69
KDE Developer
Posts
45
Karma
0
TheBlackCat wrote:Another question. In some of the source code of the comics I am getting things like "…". I assume this is some sort of formatting or special character. Is there a way to handle these properly?


I'm not sure where that was used, but it appears to me like a proper use of an html entity that describes an UTF character in the source code.


mat69, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]