Module: preformatted URLs (attachment + screenies, yay)
Kirill
Joined: 2004-12-22
Posts: 53 |
Posted: Fri, 2005-03-25 05:34 | |||||
In the wake of boredom I have developed a quasi-useful module for G2. Behold! The G2 preformatted URL module. While I was initially developing it for my own G2, I figured that I might as well contribute back to the project that has given me so much. What does it do? It adds an option to each image that reads "get item URLs". When you click it, you get a nice page that wraps the URL to your photo (either direct, or to the page it's on) in the most common formats: bbcode and HTML. See screenshot below (click): [img]http://g2test.txtdump.com/d/22-1/g2geturls-0_8_1.png[/img] Features:
Installation/Requirements This module requires CoreAPI 6.10 and ModuleAPI 2.4 (latest nightly snapshot of G2). As for installation, it's as straightforward as it can get: untar the attachment into your modules/ directory, install through 'Site Admin' interface. Notice by G2 devs: Disclaimer: Since this tidbit of code is being released under the GPL it means that I am not responsible if it smokes your server or makes your dog scratch up your brand new furniture. I don't see how it could do either, but hey. Devs: if you feel that this module is useful and want to get it in the G2 codebase, I'd be willing to work with you to satisfy the necessary requirements (unit tests? localisation? proper code formatting?). If not, that's okay too: I'm just releasing something I find useful into the wild. Comments/Questions/Praise/Flames appreciated. Bharat's ten-page code reviews are not (just kidding, rip it apart).[/]
|
||||||
Posts: 3236
Another useful URL you could add in bbcode/html would be a thumbnail that is a link to the image, either just the image or its page in G2. Know what I mean?
Posts: 53
Yes, I see what you mean. I'm not sure how to use the URL Generator to create thumbnail image location URLs, is this possible?
The best idea would be to have a whole array (in the linguistic sense) of potential formats that could be activated/deactivated through the site admin interface. What do you guys think?
Posts: 8601
you can use the fetchThumbnailsByItemIds core api to get the thumbnail, and then generate an url for it.
also, i didn't look at the code, but curious if you're checking for core.viewSource permission before giving an url to the full size image.. the user may have only viewResizes permission.
Posts: 32509
it might also be a good idea to have a small disclaimer for all links an anonymous user doesn't have access to. i.e. you as athe logged in user have permission to see the thumb/resize/fullsize, but an anonymous user may or may not see these things. and what good is a link in a bulletin board for if they can't see the hyperlinked item?
Posts: 53
Duly noted, mindless and valiant. I'll work on it some more.
Posts: 32509
and a small feature request
If you could display the itemId, that would be great. People using a G2 integration in xaraya, wordpress etc. would like to include some G2 images/items in their website, i.e. in news or articles. If they could browse G2, click on your quick urls and get the itemId that way, that would be great!
(i.e. you could make the "show itemId" optional and turn it off by default.)
it's not a high priority request. i just thought it might be cool for integrated G2 and your module seems to be the right place to add something like that.
Posts: 53
Did some work today.
GetURLs 0.8.1 changelog
Screenie:
[img]http://g2test.txtdump.com/d/22-1/g2geturls-0_8_1.png[/img]
The core.viewSources and viewResizes permission checks seem sort of messy in the way I implemented them in the template, to be honest. If anyone has a better way to go about it (and I'm sure there is), I'm all ears. I'm also looking at the site admin interface to let the admin toggle the formats they want displayed (and the Item ID thingy) on/off.
The updated module is attached to the top post, but if it's easier for you to just wget it from your offsite server you can use http://www.txtdump.com/files/geturls-0.8.1.tar.gz.
----------------------------------
Alright, finished a complete site admin interface, which allows you to:
I've also cleaned up some stuff in the template and bumped the version number to get the plugin param registration going during upgrade();.
I've tested it fairly thoroughly and it seems that it works as expected with all options. I encourage you to download it and give it a try (attached to first post, once again).[/]
[/]
Posts: 32509
thanks a bunch, Kirill. I'm seeing forward to check the it out and give some recommendations in the embedding docs for this module
Posts: 53
0.8.3 was released to comply with the new API versions. If G2 starts yelling at you with things like:
or
Please untar geturls-0.8.3.tar.gz in your modules/ directory OR make the following changes to geturls/module.inc
Thanks!
Posts: 96
hello!
i'm running core 0.9.22 and had to do a little bit of modification to get this working. i added a new 'feature' and also i'm seeing a bug with this module in this core (i think!)
similar to your previous post, i had to change those lines to say:
then to get it working w/ url rewrite enabled, (i only messed w/ the 'BBCode Formatted Links' portion, but i'm sure the 'HTML Formatted Links' is very similar...) i had to change a few:
to:
lastly, i added a quick copy function for IE users (doesn't work in FF or more than likely any other browser... most argue that this takes advantage of an IE exploit more than a feature, heh) to push the data to the clipboard w/ one click instead of having to highlight the input text area. these links show up as:
to the right of the text box area. basically, open it up in IE and then click those 'links' and it'll push that info to your clipboard for you!
the bug i think i'm seeing is that it only produces links to the full-rez image in the event that there is a full rez and a sized image. no matter if you 'get item URLs' via the resized link or the full image link, you always get the full image id's. nor does the 'Misc.' section at the bottom 'The resized version ID that we're using is' work on either the sized or full image. i'm sure the issue is related - fix one, ya fix 'em both.
i wasn't sure how to fix that though...
at any rate - as i'm not sure i'm doing *any* of this correctly, i didn't modify your code so much as just add a few lines, heh! (except the core change of course. that had to be changed)
here it is, hope ya like it!
Posts: 96
oh - and btw: thx! this is nifty!
Posts: 33
whodah i been playing around with this for the past few hours and now mine is producing links to both the full and resized image. I have also made a few changes and have added an other option for how the links are made for the clickable thumbnails and the click here links. As admin you can have them eather go to the gallery2 page that the image is on, or have it just go to the image
Posts: 96
oh really? that sounds nifty!!!
and the 'missing link' (pun intended!) to the resized image issue!
will you be posting this here i hope?
Posts: 33
i got the BB code part done right now i am edting the html part and adding your IE click thing to the html part
Posts: 96
very cool, looking forward to seeing what you've done!
Posts: 33
its also edited to work with the 2005-6-13 nightly build
Posts: 33
Oh and thanks Kirill for makeing this, hope you like the changes i made, and maybe you can go over the changes i did and fix any of my code mistakes
Posts: 96
heya!
looks sweet!! thanks!
i'm noticing one bug on mine:
for the:
Link to the page of the image in HTML:
the greater than and less than and quotes are showing up as & only. almost like the rest of the html entity got truncated off (in ItemGetURLs.tpl)
for instance, out of the box, for the first one, i was getting:
and after fixing the html entities, now i get:
are you seeing that too?
Posts: 33
I had the HTML ones turned off.
Now that turning them on i am getting the same thing.
guess i got to look and see what i messed up on that one lol
Posts: 37
Very cool! How about adding an option to set the text-alignment of the image? Something like none, left, right. This way it can be pasted into a blog without any problems.
Posts: 1023
Cool module - only one issue, if I try to add a thumb to a Bulletin Board (to display the resized one on clicking), I get the thumbnail displayed perfectly - but clicking it displays a new page with
"Forbidden - You don't have permission to access /GALLERY2/main.php on this server. / Apache/2.0.53 (Win32) DAV/2 PHP/5.0.4 Server at localmail.dynip.com Port 80"
In addition, my links contain many "&" instead of the "<", ">" and """ any idea what I'm doing wrong?
Thanks
Lutz
Posts: 96
i'll have a fix for the broken html entities (& vs. < and > and ") here in a short bit.
i'm also gonna re-arrange the order a little from 'smallest to largest'.
i.e.
click text
thumbnail
sized
full size
this was requested by a user on my site and seems more intuitive then it's current order.
fix should be up w/in a couple hours.
Posts: 96
ok, re-arranging the thumbnail up top proved to be more work then it's worth, so i didn't re-arrange them...
however, here's the fix to the html entities...
lotsa changes, just easiest to replace:
modules/geturls/templates/ItemGetURLs.tpl
w/ the attachment...
Posts: 33
thanks whodah for fixing the html tags i messed up some how, I did not get a chance to go through them all last night after work
frederik.kunz as to your text aliment, i am not shur how to go about that maybe the original writer or someone eals can add that in
Lfrank on your Forbidden thing i am not shure why you getting that, have you tryed unchecking the " Show Clickable/Link image in gallery2, If left unchecked it will just link to the image " option.
Posts: 1023
Hi, links look perfect now - the forbidden is still an issue (may be my Apache setup - I've just recently switched from IIS)
Thx Lutz
Posts: 1023
Hi,
probalbly found a reason for the "Forbidden" Issue.
Edited 13:30
looking in yesterdays template, I find a mix-up of "core.action" and "core:action". Strange only the effect described below.
Regards,
Lutz
Old - long version:
Even having i.e. the BB Code
[u=http://localmail.dynip.com/GALLERY2/d/54850-1/xxxx.jpg][ig]http://localmail.dynip.com/GALLERY2/d/54851-2/yyyy.jpg[/ig][/u]
(which displays the thumb perfect)
the HTML-Code is
href="http://localmail.dynip.com/GALLERY2/d/54850-1/xxxx.jpg" img src="http://localmail.dynip.com/GALLERY2/main.php?g2_view=core%3ADownloadItem&g2_itemId=yyyy"(removed the url, < and >)
Again the Thumb is displayed - but not the full image.
Having Short URL activated, I saw the thumb using still the full URL (http://localmail.dynip.com/GALLERY2/main.php?g2_view=core%3ADownloadItem&g2_itemId=xxxx) the full image using a short URL (http://localmail.dynip.com/GALLERY2/d/54850-1/yyyy.jpg).
Changing the URL of the full sized image to a full URL solved the issue.
I've just tested to disable the URL rewrite's for show and download on my system and got a workaround after changing the "Core.Download" to "Core%3ADownload" in the URL for the full sized image !!
Pewh... strange
Best regards,
Lutz
Posts: 53
Wow - I've been slacking off lately and not keeping up with the code changes.
whodah, Stolnvw I am no expert but I'll try to incorporate your code into the 'official' module (with due credit to the authors, of course!) and get another tarball together.
I've been fairly busy lately, so it may take me a couple of days. Looking forward to working on this again.
Posts: 96
heya!
since we're making this a better module... i just noticed something else that's 'broken' w/ it...
if an image is so small that there is no resized image, it still attempts to create/report the resized links. but of course they are broken.
it'd be nifty to not report the 'resized' links if a resized image does not exist.
Posts: 32509
there are GalleryCoreApi:: functions to fetch the thumb / resizes / preferred derivative for a specific itemId. Just check the returned array, empty array -> no resizes etc.
modules/core/classes/GalleryCoreApi.class
Posts: 14
I have trouble with the BBCode shortcuts, neither the images or thumbnails work for me... maybe that's because the boards are too stupid to realise that the linked item IS an image even though there's no ".gif" or ".jpg" attached to the link?
Posts: 32509
phpbb and other boards are not smart enough to detect image links that don't end with a image extension.
therefore, you have to activate G2 short urls (url rewrite module) to be compatible with phpbb bbcode.
(i just changed my phpbb code such that it allows all urls as image urls)
Posts: 14
Thanks. Issue solved now. I missed the moment mod_rewrite was enabled on the server.
EDIT: Figured out why flushing all caches and optimizing the database didn't help... I had to have Gallery rebuild the resized pics and thumbnails.
I just put a note of it here for the case another dummy like me comes across this issue :lol:
Posts: 6
i'm getting this error in my admin panel
Incompatible module!
Core API Required: 5.1 (available: 6.4)
Module API Required: 0.10 (available: 2.0)
Gallery version = 2.0-beta-3+ core 0.9.31
PHP version = 4.3.11 apache
Webserver = Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.11 FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7a
Database = mysql 4.0.22-standard
Toolkits = ArchiveUpload, Gd, ImageMagick, NetPBM, Exif, Thumbnail, SquareThumb
Operating system = Linux victoria.sitehq5.com 2.4.21-27.0.2.EL #1 Wed Jan 12 23:46:37 EST 2005 i686
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 (ax)
Posts: 32509
someone needs to update the module, it shouldn't be that hard. maybe just change the required api stuff in module.inc.
Posts: 33
changing the required api stuff in module.inc. fixes it fine
Posts: 22
I've installed this module and though it generates the URL's just fine, they're not the shorter URL's that I expected to see as I have the re-write module active.
Did I miss something? :-?
Posts: 32509
Kirill, could you update your module, perhaps merge in the changes from the others?
Posts: 22
use this template file for mod_rewrite to work ...
the earlier file had core:ShowItem links instead of the core.ShowItems
Posts: 45
Hi,
oh no, this module dont work with my G2:
Dont no. is it enough to change Line 46 and 47 ?
Posts: 32509
i'd try it, just change the 2 lines.
Posts: 22
it seems that this version of distribution is missing the "copy-to-clipboard" link function for HTML code, can you add that in? Thanks.
Posts: 22
Nice, this worked, thanks! :D
Posts: 3236
Is there a version that includes this? If so, could you point us to it? Or are you asking for that feature to be added to the module?
Posts: 22
Hi, here you go...
I'm dumb in PHP, if not I can help to add that in. :P
Anthony.
Posts: 7
Thanks for this very useful plugin. It solved the issue I was having with linking to Gallery2 images from WordPress articles on my website.
I like linked pictures to open in new windows so the user doesn't lose their place in the article they're reading, so I hacked the template to add "target="_blank"" to the URL generated in the "Show a clickable thumbnail to the bigger image in HTML" option and wondered if that would be something you'd consider adding as an option.
Posts: 352
I've updated the geturls some, including:
1. it now does the correct permissions when viewing the page in guest preview mode
2. For all of us integrated cms users I have added the displaying of the direct url for the image or thumbnail without the html or bbcode around it.
3. I've added callback functionality
The code needs some refactoring but it's functional. I incremented the version to 0.8.4. I hope i'm not stepping on anyone's toes here but just wanted to submit what worked for me.
Posts: 96
wow - i dind't get any topic reply notifications on this. i had no idea there were so many replies!
shocksll: what do you mean by 'callback' functionality?
Posts: 352
I have an app where I was looping through all the album children in the template and couldn't figure out how to get the thumbid for a child. So using the code from geturls I copied it into callback.inc and created a callback function so you can get the thumbid of the itemid you send it. There may be a better way but I couldn't find it.
Posts: 48
The module does NOT work with RC2 - KTHXBYE
Formatted Links 0.8.2
Item admin option to fetch BBcode/HTML formatted URLs
Incompatible module!
Core API Required: 5.1 (available: 6.7)
Module API Required: 0.10 (available: 2.0)
and i am not quite sure why it says 0.8.2 ... i downloaded 0.8.3 ... weird.
any plans, or known tricks to make it work with KTHXBYE ?
Posts: 48
Steve,
your 0.8.4 version works fine with KTHXBYE - HOWEVER i have one question/request ...
under "Link to the page of the image in BBCode:"
there should be 2 options....
1. Full sized image
2. <640x640> the .html page resized image.
since the thumbnail is too small, and the Full sized image in many cases it too large ... the end user should be able to choose from a realistic size image?
just my $0.02 .. ...
and Thanks for the working version - this is GREAT MOD!