Amazon Chooser Plugin
-
- Regular
- Posts: 546
- Joined: Mon Dec 20, 2004 11:57 pm
- Contact:
Amazon Chooser Plugin
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
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
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
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
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:
and change it to:
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...
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);
}
Code: Select all
self.opener.serendipity_imageSelector_addToBody(block, textarea);
I've only tested this limitedly though, so please let me know if it helps or hurts...
-
- Regular
- Posts: 546
- Joined: Mon Dec 20, 2004 11:57 pm
- Contact:
-
- Regular
- Posts: 546
- Joined: Mon Dec 20, 2004 11:57 pm
- Contact:
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
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
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
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
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
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!
Oh yeah, found a little typo just samantics really but right in the beginning of the main event php keyword instead of keywork
was:
should be:
was:
Code: Select all
@define('PLUGIN_EVENT_AMAZONCHOOSER_SEARCH_DESC', 'Enter a keywork to search for:');
Code: Select all
@define('PLUGIN_EVENT_AMAZONCHOOSER_SEARCH_DESC', 'Enter a keyword to search for:');
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:
To:
From:
Code: Select all
echo '<a href="'.$link.'"><img border="0" src='.$i['ImageUrlMedium'].'></a></td>';
Code: Select all
echo '<a href="'.$link.'"><img border="0" src='.$i['ImageUrlMedium'].' width="130" height="130"></a></td>';
Hell, while I was at it, I added some css support for the display when it hits the entry. Heres some sample css
heres the change in .js basically just added in some customization...
Cheers...
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 {
}
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);
-
- Regular
- Posts: 546
- Joined: Mon Dec 20, 2004 11:57 pm
- Contact:
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
(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
-
- Regular
- Posts: 546
- Joined: Mon Dec 20, 2004 11:57 pm
- Contact:
-
- Regular
- Posts: 546
- Joined: Mon Dec 20, 2004 11:57 pm
- Contact:
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
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