Page 1 of 2
Amazon Chooser Plugin
Posted: Wed Dec 22, 2004 5:36 pm
by mgroeninger
So, with Garvin's help, I put together an Amazon Chooser plugin..
This adds a button to the text editor toolbar which allows searches of the amazon website and inputs the information into the editor automagically (exactly like the media link does)..
It's in CVS additional_plugins as serendipity_event_amazonchooser, or you can download a copy from
http://www.theledge.net/index.php?/arch ... gin!!.html.
I believe it requires the most recent snapshot from CVS , since it uses some of the new plugin api hooks.
If you have any troubles with it, let me know...
Matthew
Posted: Thu Mar 17, 2005 2:39 pm
by martoq
Has anyone had trouble with this plugin besides me? It seems to work sometimes and other times it doesn't work at all. The plugin itself works, where it fails is when you hit DONE, it doesn't paste the code into the textbody. I have been pouring through the code, but just haven't come up with cause yet. I did find this in a java debug:
Error: uncaught exception: Permission denied to get property Window.editorref
the other error showing up in my httpd error log is this:
[Thu Mar 17 08:39:20 2005] [error] [client x.x.x.x] File does not exist: /datastore/ev/
public_html/templates/default/admin/{TEMPLATE_PATH}img, referer: http://www.euphoricallyvexed.c
om/index.php?/plugin/amazonch&txtarea=body&step=2&asin=B0000028RR
Posted: Thu Mar 17, 2005 5:19 pm
by Guest
I can't recreate your exact problem...
but I do get the same 404 error about templete path. (I have an idea as to why, too. I'll do a version that respects the new style stuff as soon as I can.)
I think the java error from your debug is a good indicator of what is causing the button to fail...
This is what I am thinking...
if you open up serendipity_amazonchooser.js and find these lines:
Code: Select all
if (self.opener.editorref) {
self.opener.editorref.surroundHTML(block, '');
} else {
self.opener.serendipity_imageSelector_addToBody(block, textarea);
}
and change it to:
Code: Select all
self.opener.serendipity_imageSelector_addToBody(block, textarea);
I think I was wrong to leave the editorref reference in there...
I've only tested this limitedly though, so please let me know if it helps or hurts...
Posted: Thu Mar 17, 2005 5:21 pm
by mgroeninger
That last reply was me... I forgot to log in..
Posted: Thu Mar 17, 2005 5:53 pm
by mgroeninger
I posted a new version of the plugin, with the change above and some changes to respect the new css schemes... it no longer passes admin/style.css unparsed but uses serendipity_admin.css correctly..
I also have the button suppressed when the wysiwyg editor is used.
It seems to be working on my machine just fine... I'll put it in CVS if I don't hear anything negative...
If anyone would like to test it I would appreciate it!
Download it directly:
http://www.theledge.net/uploads/serendi ... ser.tar.gz
from my post
http://www.theledge.net/index.php?/arch ... gin...html
Posted: Thu Mar 17, 2005 7:42 pm
by martoq
Will take a look at it shortly. In security training right now...

Posted: Thu Mar 17, 2005 8:17 pm
by martoq
Looks good, no more errors in the web server log. Was definitely the theme problem.
But now I am showing in my java console:
Error: uncaught exception: Permission denied to get property Window.serendipity_imageSelector_addToBody
Sorry I can't debug further, like I said in the middle of class atm.

Posted: Thu Mar 17, 2005 8:39 pm
by garvinhicking
martoq, did you check the the URL you use to access your Admin interface is exactly the same as you entered in Serendipity BaseURL configuration directive? The internet explorer complains if those two URLs do not match.
Regards,
Garvin
Posted: Thu Mar 17, 2005 10:06 pm
by martoq
Good call Garvin...well sorta. You pointed me in the right direction. You guys will love what cause the problem. The Blog Administrator. Well sort of. The base URL for my site is
http://www.euphoricallyvexed.com when I do my admin/entries, i use
https://www.euphoricallyvexed.com well, the https is whats causing the url to not match, hence the plugin chokes. I will keep testing this and see what else I can come up with, but thanks guys very much for helping me through this!
Posted: Thu Mar 17, 2005 10:12 pm
by martoq
Oh yeah, found a little typo just samantics really but right in the beginning of the main event php keyword instead of keywork
was:
Code: Select all
@define('PLUGIN_EVENT_AMAZONCHOOSER_SEARCH_DESC', 'Enter a keywork to search for:');
should be:
Code: Select all
@define('PLUGIN_EVENT_AMAZONCHOOSER_SEARCH_DESC', 'Enter a keyword to search for:');
Posted: Thu Mar 17, 2005 10:22 pm
by martoq
One other thing, its your code, completely your choice, but I noticed that amazon some times pushes pictures down at weird sizes depending on what your searching for. While the css handles the display on your page, in the search window theres no restriction. Don't know if you did it on purpose or not but I just wanted to point it out. I mainly search for music and I found most of their albumns to be 130px x 130px.
From:
Code: Select all
echo '<a href="'.$link.'"><img border="0" src='.$i['ImageUrlMedium'].'></a></td>';
To:
Code: Select all
echo '<a href="'.$link.'"><img border="0" src='.$i['ImageUrlMedium'].' width="130" height="130"></a></td>';
Posted: Thu Mar 17, 2005 11:14 pm
by martoq
Hell, while I was at it, I added some css support for the display when it hits the entry. Heres some sample css
Code: Select all
/* Amazon Chooser Plugin */
.serendipity_amazonchr_pic {
float: left;
margin: 2px;
boarder: 0px solid #000000;
display: block;
width: 60px;
height: 59px;
}
.serendipity_amazonchr_txt {
font-size: 10px;
}
.serendipity_amazonchr_txt {
}
heres the change in .js basically just added in some customization...
Code: Select all
img = "<img class='serendipity_amazonchr_pic' border='0' hspace='0' src='" + ImageUrl + "' alt='" + prodname + "' />";
block = '<table>'
+ '<tr>'
+ '<td align="center" valign="top" rowspan="1">'
+ '<a href="'
+ url
+ '">'
+ img
+ '</a>'
+ '<td valign="top"> <div class="serendipity_amazonchr_head"><b>'
+ '<a href="'
+ url
+ '">'
+ prodname
+ '</a>'
+ ('+ catalog +')alog +')</div>'
+ '<div class="serendipity_amazonchr_txt">'
+ extra
+ '<br />'
+ 'Released: '
+ released
+ '<br />'
+ '</div></td>'
+ '</td>'
+ '</tr>'
+ '</table>'
self.opener.serendipity_imageSelector_addToBody(block, textarea);
Cheers...
Posted: Thu Mar 17, 2005 11:58 pm
by mgroeninger
I like the css stuff... I'll play with it when I get a chance...
(Garvin, is there documentation for the templete stuff in 0.8, and is this what it is designed for? Or should I just use the css output hook?)
As far as the thumbnail size, I mainly search for books and the thumbnails are a different size I think (At least not square, I'm pretty sure...)
I'll take a look at what amazon returns after the query (I think they might return thumbnail sizes) and see about creating an aspect ratio setting...
(Target at a specific height, and display based on the thumbnail ratio, something like that...)
I may use a hardcoded http:// somewhere in there... I'll see if there is something I can do to make https work... If you think of anything let me know!
Thanks for using the plugin and thanks for the feedback!!!
Matt
Posted: Fri Mar 18, 2005 12:00 am
by mgroeninger
Garvin, never mind the templete question... this isn't what it is designed for (Sorry, I actually stopped to think about it after I posted)
I think it makes sense just to use the css hook to output some css and use martoq's code to wrap the div tags in the post....
Posted: Mon Mar 21, 2005 8:12 pm
by mgroeninger
Ok, I got the typo fixed, and added the css stuff... It is updated in CVS (should be available in ~24 hours)
I also fixed it so the button is displayed on extended body..
I'm still not sure about the https/http and I don't have a good way to test it right now...
As for image size, Amazon's soap doesn't return any image information... in order to do it correctly I would have to add another query to pull the image and check the size, and I'm not willing to do that at this time...
(I don't like the length of time the "done" page takes to load right now... adding the query increases that time)
I do think max-height and max-width might be useful here, but I'm not a css/style person.. Does anyone know if those can be used inside a table?
And if anyone really wants to help, if you get me an example of how those work I can get that added...
For a little more (but not much, really) you can look at
http://www.theledge.net/index.php?/arch ... ugins.html
Or you can download it at
http://www.theledge.net/uploads/serendi ... ser.tar.gz