about bookpedia plug-in development
about bookpedia plug-in development
Hello, I'm DJ.HAN (I can't write English well, sorry)
I'm not professional programmer. (I only know about php or javascript) But I need a bookpedia search plug-in for me, so I downloaded source from http://www.bruji.com/plugins/. Also I read a thread about development.
Then I tried build with sample source. I open the project in Xcode, then put bookpedia App to build>debug folder. next, I push build and go button, but it's failed. Error log is followin as ;
Running custom shell script (2errors)
mkdir: /Users/djhan/Downloads/sampleplugin/build/Debug/DVDpedia.app/Contents: No such file or directory
cp: /Users/djhan/Downloads/sampleplugin/build/Debug/DVDpedia.app/Contents/Plug-ins: No such file or directory
Ii seemed that sample plugin source is made for dvdpedia. How can I change the setting to bookpedia, and build it?
Please answer my question, Thanks.
I'm not professional programmer. (I only know about php or javascript) But I need a bookpedia search plug-in for me, so I downloaded source from http://www.bruji.com/plugins/. Also I read a thread about development.
Then I tried build with sample source. I open the project in Xcode, then put bookpedia App to build>debug folder. next, I push build and go button, but it's failed. Error log is followin as ;
Running custom shell script (2errors)
mkdir: /Users/djhan/Downloads/sampleplugin/build/Debug/DVDpedia.app/Contents: No such file or directory
cp: /Users/djhan/Downloads/sampleplugin/build/Debug/DVDpedia.app/Contents/Plug-ins: No such file or directory
Ii seemed that sample plugin source is made for dvdpedia. How can I change the setting to bookpedia, and build it?
Please answer my question, Thanks.
Re: about bookpedia plug-in development
I downloaded samplepluginbook.zip file.
But I see same message too. xcode show message following as ;
mkdir: /Users/djhan/Desktop/SamplePluginBook/build/Release/DVDpedia.app/Contents: No such file or directory
cp: /Users/djhan/Desktop/SamplePluginBook/build/Release/DVDpedia.app/Contents/Plug-ins: No such file or directory
Please link proper file. or please teach me how can I set this source file as bookpedia plugin.
Thanks, good luck
But I see same message too. xcode show message following as ;
mkdir: /Users/djhan/Desktop/SamplePluginBook/build/Release/DVDpedia.app/Contents: No such file or directory
cp: /Users/djhan/Desktop/SamplePluginBook/build/Release/DVDpedia.app/Contents/Plug-ins: No such file or directory
Please link proper file. or please teach me how can I set this source file as bookpedia plugin.
Thanks, good luck
Re: about bookpedia plug-in development
Try the above download again and it should be fixed. Otherwise under "Target" on the left hand side expand sample and double click the "Quit Copy Launch" phase and change the first line taht says PROGRAM="DVDpedia" to PROGRAM="Bookpedia".
Re: about bookpedia plug-in development
Thanks for your support. Now, I try to making plugin for aladdin (Korean internet bookstore like Amazon. http://www.aladdin.co.kr).
But I have a big problem..... aladdin search form like as;
http://www.aladdin.co.kr/search/wsearch ... earchWord=%@
problem is that aladdin site wasn't support UTF-8. aladdin is euc-kr encoding.
I found searchstring variable declaration in sample code.
> NSMutableString *searchString = [NSMutableString string];
I think utf-8 is default encoding. But I don't know about how convert searchstring variable to euc-kr encoding.
(I am not professional programmer. Real amateur)
Also, aladdin return HTML code as euc-kr. How I can convert it to UTF-8?
Please help me. Thanks, good luck.
But I have a big problem..... aladdin search form like as;
http://www.aladdin.co.kr/search/wsearch ... earchWord=%@
problem is that aladdin site wasn't support UTF-8. aladdin is euc-kr encoding.
I found searchstring variable declaration in sample code.
> NSMutableString *searchString = [NSMutableString string];
I think utf-8 is default encoding. But I don't know about how convert searchstring variable to euc-kr encoding.
(I am not professional programmer. Real amateur)
Also, aladdin return HTML code as euc-kr. How I can convert it to UTF-8?
Please help me. Thanks, good luck.
Re: about bookpedia plug-in development
To change the encoding look towards the last method in the plug-in called connectionDidFinishLoading: In that method you will find:
change the encoding there to: NSJapaneseEUCStringEncoding or NSUnicodeStringEncoding or NSUTF32StringEncoding. I am not sure which one will work for EUC-KR encoding. I am hoping it will be compatible with the Japanese EUC version.
Also in resultNumber: look for the encoding and change it there as well to match.
Once you get the reading encoding correct you should be able to pass it to the plug-in without converting it, as the Pedias will take care of using the most appropriate encoding. e.i. UTF-8 or 16 if necessary.
Code: Select all
[[[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding] autorelease]
change the encoding there to: NSJapaneseEUCStringEncoding or NSUnicodeStringEncoding or NSUTF32StringEncoding. I am not sure which one will work for EUC-KR encoding. I am hoping it will be compatible with the Japanese EUC version.
Also in resultNumber: look for the encoding and change it there as well to match.
Code: Select all
NSString *results = [[[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil] encoding:NSISOLatin1StringEncoding] autorelease];
Re: about bookpedia plug-in development
Hello, I'm DJ.HAN.
Thanks for your support.
encoding:NSUTF8stringEncoding
to
encoding:-2147481280
Now, I can get euc-kr HTML pages. Thanks!
But It was failed korean keyword search yet..... keyword must be converted utf-8 to euc-kr!
I think that it need to be changed encoding in this sentence;
NSString *httpRequest = [NSString stringWithFormat:@"http://www.aladdin.co.kr/search/wsearch ... earchWord=%@", searchString];
maybe I was wrong.... anyway, How can I converted keyword encoding to euc-kr?
I need your help. Please help me. Thanks Good Luck!
Thanks for your support.
encoding:NSUTF8stringEncoding
to
encoding:-2147481280
Now, I can get euc-kr HTML pages. Thanks!
But It was failed korean keyword search yet..... keyword must be converted utf-8 to euc-kr!
I think that it need to be changed encoding in this sentence;
NSString *httpRequest = [NSString stringWithFormat:@"http://www.aladdin.co.kr/search/wsearch ... earchWord=%@", searchString];
maybe I was wrong.... anyway, How can I converted keyword encoding to euc-kr?
I need your help. Please help me. Thanks Good Luck!
Re: about bookpedia plug-in development
The URL specifications don't allow for other encodings. What you need to do is add the line that encodes a URL that has non ASCII characters into percent encoding, right before creating the httpRequest string encode the keyword with:
That should work, otherwise try:
Code: Select all
searchString = [searchString stringByAddingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding];
Code: Select all
searchString = [searchString stringByAddingPercentEscapesUsingEncoding:-2147481280];
Re: about bookpedia plug-in development
Thanks!
I make build of aladdin plugin. You can get the plugin in here;
http://www.kbdmania.net/images/mac/aladdin.plugin.zip
It's not perfect. I don't know how can using regular expression in xcode. So, you may get dirty text in summary, or comments.
Anyway it work...
Also, source is here;
http://www.kbdmania.net/images/mac/aladdin_source.zip
in this source, problem is it.
I wanna change these sentences to this form;
But I don't know how to using regular expression in cocoa. How can I do using replacement patterns?
(I'm really amateur, sorry )
Thanks for your support. Good Luck!
I make build of aladdin plugin. You can get the plugin in here;
http://www.kbdmania.net/images/mac/aladdin.plugin.zip
It's not perfect. I don't know how can using regular expression in xcode. So, you may get dirty text in summary, or comments.
Anyway it work...
Also, source is here;
http://www.kbdmania.net/images/mac/aladdin_source.zip
in this source, problem is it.
Code: Select all
[cleanString replaceOccurrencesOfString:@"<BR>" withString:@"\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0,[cleanString length])];
~~~~~ many of cleanString sentence ~~~~
[cleanString replaceOccurrencesOfString:@"</Font>" withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0,[cleanString length])];
[cleanString replaceOccurrencesOfString:@"<font color=#639A9C>" withString:@"" options:NSCaseInsensitiveSearch
Code: Select all
[cleanString replaceOccurrencesOfString:@"<[a-z0-9]>" withString:@"\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0,[cleanString length])];
(I'm really amateur, sorry )
Thanks for your support. Good Luck!
Re: about bookpedia plug-in development
Cocoa's NSString sadly does not have regular expression support. But you can add it to your plug-in by adding the following two files CSRegex.h and CSRegex.m (use new file under the file menu) you copy the contents for each file from (http://www.cocoadev.com/index.pl?CSRegex). This file will extend NSString to support regcomp()/regexec() functions available in the BSD. You can then do a while loop on a match and add the replace inside:
I personally have never used CSRegex, plus I made that and typed the above here on the spot, so it might not work, but it's a starting point for regular expressions.
Other options:
http://www.mactech.com/articles/mactech ... pressions/
http://sourceforge.net/projects/objpcre
http://regexkit.sourceforge.net/
http://www.cocoadev.com/index.pl?RegularExpressions
You might say you are a novice, but creating a plug-in is no easy matter – congratulations. The even better news is you can tweak it to fit your exact needs.
Code: Select all
NSString *nextMatch;
while (nextMatch = [cleanString substringMatchedByPattern:@"[a-z0-9]"]) {
[cleanString replaceOccurrencesOfString: nextMatch withString:@"\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0,[cleanString length])];
}
Other options:
http://www.mactech.com/articles/mactech ... pressions/
http://sourceforge.net/projects/objpcre
http://regexkit.sourceforge.net/
http://www.cocoadev.com/index.pl?RegularExpressions
You might say you are a novice, but creating a plug-in is no easy matter – congratulations. The even better news is you can tweak it to fit your exact needs.
Re: about bookpedia plug-in development
Thanks for your support.
but your code have a problem.
if cleanstring is NSmutablestring, this code wasn't work.
I'll trying find other way. Thanks, really thanks for your support and teaching. Good luck for you!
but your code have a problem.
Code: Select all
NSString *nextMatch;
while (nextMatch = [cleanString substringMatchedByPattern:@"[a-z0-9]"]) {
[cleanString replaceOccurrencesOfString: nextMatch withString:@"\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0,[cleanString length])];
}
I'll trying find other way. Thanks, really thanks for your support and teaching. Good luck for you!
Re: about bookpedia plug-in development
Why wouldn't it work? NSMutableString is a subclass of NSString, so it would inherit all the extension that are added to NSString such as the regex capabilities.
This is one of the confusing aspects of Cocoa. You have to look at the inheritance of a class to know all the methods it can perform. For example NSMutableString inherits from NSString and NSString from NSObject (every class inherits from NSObject, it's the root class). So NSMutableString can do all the NSMutableString methods, plus all the NSString methods, plus all the NSObject methods.
The CSRegex is a category of NSString that extends NSString by adding more methods to that class. NSMutableString would inherit all those extensions as well.
Let me the error you get and I might be able to narrow down the solution. As I mentioned I wrote the code here and do not have CSRegex, but in theory what I wrote should work. If you let me know the error maybe there is something new I can learn here too.
This is one of the confusing aspects of Cocoa. You have to look at the inheritance of a class to know all the methods it can perform. For example NSMutableString inherits from NSString and NSString from NSObject (every class inherits from NSObject, it's the root class). So NSMutableString can do all the NSMutableString methods, plus all the NSString methods, plus all the NSObject methods.
The CSRegex is a category of NSString that extends NSString by adding more methods to that class. NSMutableString would inherit all those extensions as well.
Let me the error you get and I might be able to narrow down the solution. As I mentioned I wrote the code here and do not have CSRegex, but in theory what I wrote should work. If you let me know the error maybe there is something new I can learn here too.
Re: about bookpedia plug-in development
Hello, I'm DJ.HAN.
Firstly, please DL my source code.
I add your source for getting comments part. like as ;
Then I build&go, xcode show me warning message under line of "NSMutableString *cleanString = [NSMutableString stringWithString:comments];". The message is....
Warnign : 'NSmutableString' may not respond to '-substringMatchedByPattern'
(Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)
What's wrong with my source code? If you can help me, I'll very happy
Thanks, Good Luck!
Firstly, please DL my source code.
I add your source for getting comments part. like as ;
Code: Select all
NSString *comments = [results stringBetween:@"<div id=\"bodyDescription\">" and:@"</DIV>"];
if (comments) {
// Remove HTML
NSMutableString *cleanString = [NSMutableString stringWithString:comments];
NSString *nextMatch;
while (nextMatch = [cleanString substringMatchedByPattern:@"[a-z0-9]"]) {
[cleanString replaceOccurrencesOfString: nextMatch withString:@"\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0,[cleanString length])];
}
[returnData setObject:cleanString forKey:@"comments"];
}
Warnign : 'NSmutableString' may not respond to '-substringMatchedByPattern'
(Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)
What's wrong with my source code? If you can help me, I'll very happy
Thanks, Good Luck!
Re: about bookpedia plug-in development
You did not include the CSRegex files that extend the NSString methods to do regular expressions. I have included them to your project. Download it and you will be able to add the code now.
Re: about bookpedia plug-in development
Thanks, thanks for your support!
I was success strip some HTML tag using regular expression. Thanks!
So, the aladdin plugin 0.3.5 is here ;
http://www.kbdmania.net/images/mac/alad ... .0.3.5.zip
now, you can test this plugin. (some korean book have english word. e.g) test, cinema ...)
and rebuilt source was uploaded same place, same name.
Anyway, really thanks for your support for korean users. Thanks, Good luck!
I was success strip some HTML tag using regular expression. Thanks!
So, the aladdin plugin 0.3.5 is here ;
http://www.kbdmania.net/images/mac/alad ... .0.3.5.zip
now, you can test this plugin. (some korean book have english word. e.g) test, cinema ...)
and rebuilt source was uploaded same place, same name.
Anyway, really thanks for your support for korean users. Thanks, Good luck!