Module: preformatted URLs (attachment + screenies, yay)

Kirill
Kirill's picture

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?
See: http://codex.gallery2.org/index.php/Gallery2:Modules:geturls

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]
(older 0.8.0 screenshot)

Features:

  • It's a proper module. Just extract archive into your modules/ directory and install it (sits under Extra Data) through the admin interface. No need to hack up your code.
  • Integrates cleanly with the permissions system, adding a new "[URLs] View formatted URLs]" permission to each item.
  • Distinguishes between a photo item and any other sort of item (but not on the permission level), link is only shown for photo items.
    As of 0.8.1:
  • Separate BBCode/HTML blocks
  • Also codes for clickable image thumbnails
  • Shows Item IDs (which are apparently useful for embedded installations)
    As of 0.8.2:
  • Complete site admin inteface to finetune all the options your little heart desires

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:
The latest version of this module is 0.9.2 and is attached to this first post. The latest version went through a code review and received a few new features.

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).[/]

AttachmentSize
geturls-0.9.2.zip (for Gallery 2.0.x)13.72 KB
geturls-0.9.5.zip (For Gallery 2.1.x, 2.2.x)13.88 KB
 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Fri, 2005-03-25 06:31

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?

[url=url to page here][img]urltoimage[/img][/url]
 
Kirill
Kirill's picture

Joined: 2004-12-22
Posts: 53
Posted: Fri, 2005-03-25 06:55

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?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-03-25 16:03

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.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-03-25 16:17

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?

 
Kirill
Kirill's picture

Joined: 2004-12-22
Posts: 53
Posted: Fri, 2005-03-25 18:36

Duly noted, mindless and valiant. I'll work on it some more.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-03-25 18:45

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.

 
Kirill
Kirill's picture

Joined: 2004-12-22
Posts: 53
Posted: Sat, 2005-03-26 04:03

Did some work today.

GetURLs 0.8.1 changelog

  • Module now checks for proper URLs.View permission before loading the page, something it should've been doing in the first version.
  • There were several unneeded callbacks in module.inc in the old version that I've overlooked since I just c/ped the comment module's module.inc to save time. They are now removed.
  • Smart permission checks now in place. The module throws a warning to the user if 'Everybody' does not have 'core.viewSource' set, and modifies the generated URLs to use the available resized version. If 'core.viewResizes' is also unavailable publicly, the module continues while informing the user that the links will probably end up broken. (Thanks mindless / valiant!)
  • A clickable thumbnail code for both HTML and BBCode is now generated as well (thanks fryfrog!).
  • Broke up the page into three blocks: the HTML formatted links, BBCode formatted links and Misc.
  • Misc. now shows the G2 IDs for the main image, thumbnail and resized version (if we used one).

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:

  • Select which code forms you want to show
  • Select if you want to show any Item IDs
  • Select the level of warning suppression desired, if any

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).[/]

[/]

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-03-26 10:41

thanks a bunch, Kirill. I'm seeing forward to check the it out and give some recommendations in the embedding docs for this module :)

 
Kirill
Kirill's picture

Joined: 2004-12-22
Posts: 53
Posted: Thu, 2005-04-07 01:25

0.8.3 was released to comply with the new API versions. If G2 starts yelling at you with things like:

 Incompatible module!
Core API Required: 4.1 (available: 5.1)
Module API Required: 0.9 (available: 0.10)

or

Error (ERROR_PLUGIN_VERSION_MISMATCH) : [geturls] db: (v: 0.8.2 core api: 4/1, module api: 0/9) code: (v: 0.8.9 core api: 5/1, module api: 0/10)

    * in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 169 (gallerystatus::error)
...

Please untar geturls-0.8.3.tar.gz in your modules/ directory OR make the following changes to geturls/module.inc

[Line 46]         $this->setRequiredCoreApi(array(5, 1));
[Line 47]         $this->setRequiredModuleApi(array(0, 10));

Thanks!

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sun, 2005-06-12 16:11

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:

        $this->setRequiredCoreApi(array(6, 0));
        $this->setRequiredModuleApi(array(0, 12));

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:

view=core:ShowItem
view=core:DownloadItem

to:

view=core.DownloadItem

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:

[CLK]
[IMG]
[TMB]

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! :)

{*
 * $Revision: 1.20 $
 * If you want to customize this file, do not edit it directly since future upgrades
 * may overwrite it.  Instead, copy it into a new directory called "local" and edit that
 * version.  Gallery will look for that file first and use it if it exists.
 *}
<div class="gbBlock gcBackground1">
  <h2> 	{g->text text="Quick URLs"} </h2>
</div>


<div class="gbBlock"

{if $error.cantviewsource && $error.cantviewresizes && !$options.suppressSourceWarning}
<h2 class="giError">{g->text text="Warning! The permissions for this item are set so that unauthenticated users may not view it. If you are planning on linking to this item in a public forum or HTML page, the viewers will most likely not be able to access it."}</h2>
{/if}

{if $error.cantviewsource && !$error.cantviewresizes && !$options.suppressResizedWarning}
<h2 class="giError">{g->text text="Warning! The permissions for this item are set so that unauthenticated users may not view the full sized version, but the resized version is available. Links to the resized version are being used, this may not be what you want."}</h2>
{/if}

<p class="gbDescription">
	{g->text text="Through this page you can quickly get formatted URLs for this image."}
	  <br/>
	{g->text text="These can be used to post the image on forums and HTML pages by copying the code in the boxes below and pasting it into your application/browser."}
</p>

</div>

{if $options.HTMLlink || $options.HTMLinline || $options.HTMLthumbnail}
<div class="gbBlock">
<h2>{g->text text="HTML Formatted Links"}</h2>

{if $options.HTMLlink}
<p class="gbDescription">
	{g->text text="Link to the page of the image in HTML:"}
	<br />
	<input name="forum" type="text" readonly="true" size="85" value="&a href=&{g->url arg1="view=core:ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}&&click for image&/a&">
</p>
{/if}

{if $error.cantviewsource && !$error.cantviewresizes && $options.HTMLinline}
<p class="gbDescription">
	{g->text text="Show image directly in HTML (resized version will be shown):"}
	<br />
	<input name="forum" type="text" readonly="true" size="85" value="&img src=&{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.resizeid`"}&&">
</p>

{else}
	{if $options.HTMLinline}
<p class="gbDescription">
	{g->text text="Show image directly in HTML:"}
	<br />
	<input name="forum" type="text" readonly="true" size="85" value="&img src=&{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}&&">
</p>
	{/if}
{/if}

{if $options.HTMLthumbnail}
<p class="gbDescription">
	{g->text text="Show a clickable thumbnail to the bigger image in HTML:"}
	<br />
	<input name="forum" type="text" readonly="true" size="85" value="&a href=&{g->url arg1="view=core:ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}&&&img src=&{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.thumbid`"}&&&/a&">
</p>
{/if}
</div>
{/if}

{if $options.BBClink || $options.BBCinline || $options.BBCthumbnail}
<div class="gbBlock">
	<h2>{g->text text="BBCode Formatted Links"}</h2>

{if $options.BBClink}
	<p class="gbDescription">
		{g->text text="Link to the page of the image in BBCode:"}
		<br />
		<input name="forum" type="text" readonly="true" size="85" value="[url={g->url arg1="view=core:ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}]click for image[/url]">
	  <input name="forum2" type="text" readonly="true" size="85" value="[url={g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}]click for image[/url]">
	  <a onclick="javascript:clipboardData.setData('Text','[url={g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}]click for image[/url]');window.status = '[CLK]{$ItemGetURLsItem.id}[/CLK] copied to your clipboard for forum posting!';" href>[CLK]</a> 
	</p>
{/if}

{if $error.cantviewsource && !$error.cantviewresizes && $options.BBCinline}
	<p class="gbDescription">
		{g->text text="Show image directly in BBCode (resized version will be shown):"}
		<br />
		<input name="forum" type="text" readonly="true" size="85" value="[img]{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.resizeid`"}[/img]">
	</p>
{else}
	{if $options.BBCinline}
	<p class="gbDescription">
		{g->text text="Show image directly in BBCode:"}
		<br />
		<input name="forum" type="text" readonly="true" size="85" value="[img]{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}[/img]">
	  <input name="forum" type="text" readonly="true" size="85" value="[img]{g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}[/img]">
	  <a onclick="javascript:clipboardData.setData('Text','[IMG]{g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}[/IMG]');window.status = '[IMG]{$ItemGetURLsItem.id}[/IMG] copied to your clipboard for forum posting!';" href>[IMG]</a> 
	</p>
	{/if}
{/if}

{if $options.BBCthumbnail}
	<p class="gbDescription">
		{g->text text="Show a clickable thumbnail to the bigger image in BBCode:"}
		<br />
		<input name="forum" type="text" readonly="true" size="85" value="[url={g->url arg1="view=core:ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}][img]{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.thumbid`"}[/img][/url]">
    <input name="forum" type="text" readonly="true" size="85" value="[url={g->url arg1="view=core.ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}][img]{g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.thumbid`"}[/img][/url]">
	  <a onclick="javascript:clipboardData.setData('Text','[url={g->url arg1="view=core.ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}][img]{g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.thumbid`"}[/img][/url]');window.status = '[TMB]{$ItemGetURLsItem.thumbid}[/TMB] copied to your clipboard for forum posting!';" href>[TMB]</a>
	</p>
{/if}


</div>
{/if}

{if $options.MiscItemId || $options.MiscThumbnailId || $options.MiscResizeId}
<div class="gbBlock">
	<h2>{g->text text="Misc."}</h2>
	
{if $options.MiscItemId}
	<p class="gbDescription">{g->text text="The Gallery ID for this image is "} {$ItemGetURLsItem.id}.</p>
{/if}

{if $ItemGetURLsItem.resizeid && $options.MiscResizeId}
	<p class="gbDescription">{g->text text="The resized  version ID that we're using is "} {$ItemGetURLsItem.resizeid}.</p>
{/if}

{if $options.MiscThumbnailId}
	<p class="gbDescription">{g->text text="The thumbnail ID for this image is "} {$ItemGetURLsItem.thumbid}.</p>
{/if}
</div>
{/if}
 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Sun, 2005-06-12 16:12

oh - and btw: thx! this is nifty! :)

 
Stolnvw

Joined: 2005-06-14
Posts: 33
Posted: Tue, 2005-06-14 21:09

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

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Tue, 2005-06-14 21:17

oh really? that sounds nifty!!!

and the 'missing link' (pun intended!) to the resized image issue! :)

will you be posting this here i hope? :)

 
Stolnvw

Joined: 2005-06-14
Posts: 33
Posted: Tue, 2005-06-14 21:29

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

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Tue, 2005-06-14 21:41

very cool, looking forward to seeing what you've done! :)

 
Stolnvw

Joined: 2005-06-14
Posts: 33
Posted: Tue, 2005-06-14 21:49

its also edited to work with the 2005-6-13 nightly build

 
Stolnvw

Joined: 2005-06-14
Posts: 33
Posted: Tue, 2005-06-14 21:54

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

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Wed, 2005-06-15 00:16

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:

&a href=&http://www.cvreefers.org/v/CVR_members/whodah/whodah_zoanthids/whodah_zo_001-006/IMG_3570.jpg.html&&click for image&/a& 

and after fixing the html entities, now i get:

<a href="http://www.cvreefers.org/v/CVR_members/whodah/whodah_zoanthids/whodah_zo_001-006/IMG_3570.jpg.html">click for image</a>

are you seeing that too?

 
Stolnvw

Joined: 2005-06-14
Posts: 33
Posted: Wed, 2005-06-15 01:35

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

 
frederik.kunz
frederik.kunz's picture

Joined: 2005-03-21
Posts: 37
Posted: Wed, 2005-06-15 07:35

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.

 
LFrank

Joined: 2005-02-19
Posts: 1023
Posted: Thu, 2005-06-16 08:31

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

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Thu, 2005-06-16 14:57

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.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Thu, 2005-06-16 15:42

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...

 
Stolnvw

Joined: 2005-06-14
Posts: 33
Posted: Thu, 2005-06-16 22:24

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.

 
LFrank

Joined: 2005-02-19
Posts: 1023
Posted: Fri, 2005-06-17 06:10

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

 
LFrank

Joined: 2005-02-19
Posts: 1023
Posted: Fri, 2005-06-17 09:53

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

 
Kirill
Kirill's picture

Joined: 2004-12-22
Posts: 53
Posted: Fri, 2005-06-17 23:12

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.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Mon, 2005-06-20 16:07

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.

:)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-06-30 15:50

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

 
Asenath

Joined: 2005-06-04
Posts: 14
Posted: Thu, 2005-06-30 18:55

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?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-06-30 19:59

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)

 
Asenath

Joined: 2005-06-04
Posts: 14
Posted: Fri, 2005-07-01 14:04

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:

 
pixelherder

Joined: 2005-07-13
Posts: 6
Posted: Thu, 2005-07-14 19:21

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)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-07-14 20:32

someone needs to update the module, it shouldn't be that hard. maybe just change the required api stuff in module.inc.

 
Stolnvw

Joined: 2005-06-14
Posts: 33
Posted: Fri, 2005-07-15 02:51

changing the required api stuff in module.inc. fixes it fine

 
ZED28

Joined: 2005-05-22
Posts: 22
Posted: Fri, 2005-07-29 22:57

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? :-?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-08-05 00:38

Kirill, could you update your module, perhaps merge in the changes from the others?

 
g0d

Joined: 2005-03-12
Posts: 22
Posted: Sun, 2005-08-07 05:26

use this template file for mod_rewrite to work ...

the earlier file had core:ShowItem links instead of the core.ShowItems

 
sun-man

Joined: 2003-07-31
Posts: 45
Posted: Sun, 2005-08-07 09:22

Hi,
oh no, this module dont work with my G2:

Quote:
Core API Required 5.1 (Verfügbar sind: 6.4)
Module API Required: 0.10 (Verfügbar sind: 1.1)

Dont no. is it enough to change Line 46 and 47 ?

Quote:
$this->setRequiredCoreApi(array(6, 4));
$this->setRequiredModuleApi(array(1, 1));

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-08-07 11:18

i'd try it, just change the 2 lines.

 
ak17

Joined: 2005-07-31
Posts: 22
Posted: Sun, 2005-08-07 12:58

it seems that this version of distribution is missing the "copy-to-clipboard" link function for HTML code, can you add that in? Thanks.

 
ZED28

Joined: 2005-05-22
Posts: 22
Posted: Mon, 2005-08-08 02:39
g0d wrote:
use this template file for mod_rewrite to work ...

the earlier file had core:ShowItem links instead of the core.ShowItems

Nice, this worked, thanks! :D

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Mon, 2005-08-08 03:58
ak17 wrote:
it seems that this version of distribution is missing the "copy-to-clipboard" link function for HTML code, can you add that in? Thanks.

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?

 
ak17

Joined: 2005-07-31
Posts: 22
Posted: Mon, 2005-08-08 07:26

Hi, here you go... :)
I'm dumb in PHP, if not I can help to add that in. :P

Anthony.

whodah wrote:
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:

        $this->setRequiredCoreApi(array(6, 0));
        $this->setRequiredModuleApi(array(0, 12));

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:

view=core:ShowItem
view=core:DownloadItem

to:

view=core.DownloadItem

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:

[CLK]
[IMG]
[TMB]

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! :)

{*
 * $Revision: 1.20 $
 * If you want to customize this file, do not edit it directly since future upgrades
 * may overwrite it.  Instead, copy it into a new directory called "local" and edit that
 * version.  Gallery will look for that file first and use it if it exists.
 *}
<div class="gbBlock gcBackground1">
  <h2> 	{g->text text="Quick URLs"} </h2>
</div>


<div class="gbBlock"

{if $error.cantviewsource && $error.cantviewresizes && !$options.suppressSourceWarning}
<h2 class="giError">{g->text text="Warning! The permissions for this item are set so that unauthenticated users may not view it. If you are planning on linking to this item in a public forum or HTML page, the viewers will most likely not be able to access it."}</h2>
{/if}

{if $error.cantviewsource && !$error.cantviewresizes && !$options.suppressResizedWarning}
<h2 class="giError">{g->text text="Warning! The permissions for this item are set so that unauthenticated users may not view the full sized version, but the resized version is available. Links to the resized version are being used, this may not be what you want."}</h2>
{/if}

<p class="gbDescription">
	{g->text text="Through this page you can quickly get formatted URLs for this image."}
	  <br/>
	{g->text text="These can be used to post the image on forums and HTML pages by copying the code in the boxes below and pasting it into your application/browser."}
</p>

</div>

{if $options.HTMLlink || $options.HTMLinline || $options.HTMLthumbnail}
<div class="gbBlock">
<h2>{g->text text="HTML Formatted Links"}</h2>

{if $options.HTMLlink}
<p class="gbDescription">
	{g->text text="Link to the page of the image in HTML:"}
	<br />
	<input name="forum" type="text" readonly="true" size="85" value="&a href=&{g->url arg1="view=core:ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}&&click for image&/a&">
</p>
{/if}

{if $error.cantviewsource && !$error.cantviewresizes && $options.HTMLinline}
<p class="gbDescription">
	{g->text text="Show image directly in HTML (resized version will be shown):"}
	<br />
	<input name="forum" type="text" readonly="true" size="85" value="&img src=&{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.resizeid`"}&&">
</p>

{else}
	{if $options.HTMLinline}
<p class="gbDescription">
	{g->text text="Show image directly in HTML:"}
	<br />
	<input name="forum" type="text" readonly="true" size="85" value="&img src=&{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}&&">
</p>
	{/if}
{/if}

{if $options.HTMLthumbnail}
<p class="gbDescription">
	{g->text text="Show a clickable thumbnail to the bigger image in HTML:"}
	<br />
	<input name="forum" type="text" readonly="true" size="85" value="&a href=&{g->url arg1="view=core:ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}&&&img src=&{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.thumbid`"}&&&/a&">
</p>
{/if}
</div>
{/if}

{if $options.BBClink || $options.BBCinline || $options.BBCthumbnail}
<div class="gbBlock">
	<h2>{g->text text="BBCode Formatted Links"}</h2>

{if $options.BBClink}
	<p class="gbDescription">
		{g->text text="Link to the page of the image in BBCode:"}
		<br />
		<input name="forum" type="text" readonly="true" size="85" value="[url={g->url arg1="view=core:ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}]click for image[/url]">
	  <input name="forum2" type="text" readonly="true" size="85" value="[url={g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}]click for image[/url]">
	  <a onclick="javascript:clipboardData.setData('Text','[url={g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}]click for image[/url]');window.status = '[CLK]{$ItemGetURLsItem.id}[/CLK] copied to your clipboard for forum posting!';" href>[CLK]</a> 
	</p>
{/if}

{if $error.cantviewsource && !$error.cantviewresizes && $options.BBCinline}
	<p class="gbDescription">
		{g->text text="Show image directly in BBCode (resized version will be shown):"}
		<br />
		<input name="forum" type="text" readonly="true" size="85" value="[img]{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.resizeid`"}[/img]">
	</p>
{else}
	{if $options.BBCinline}
	<p class="gbDescription">
		{g->text text="Show image directly in BBCode:"}
		<br />
		<input name="forum" type="text" readonly="true" size="85" value="[img]{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}[/img]">
	  <input name="forum" type="text" readonly="true" size="85" value="[img]{g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}[/img]">
	  <a onclick="javascript:clipboardData.setData('Text','[IMG]{g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.id`"}[/IMG]');window.status = '[IMG]{$ItemGetURLsItem.id}[/IMG] copied to your clipboard for forum posting!';" href>[IMG]</a> 
	</p>
	{/if}
{/if}

{if $options.BBCthumbnail}
	<p class="gbDescription">
		{g->text text="Show a clickable thumbnail to the bigger image in BBCode:"}
		<br />
		<input name="forum" type="text" readonly="true" size="85" value="[url={g->url arg1="view=core:ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}][img]{g->url arg1="view=core:DownloadItem" arg2="itemId=`$ItemGetURLsItem.thumbid`"}[/img][/url]">
    <input name="forum" type="text" readonly="true" size="85" value="[url={g->url arg1="view=core.ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}][img]{g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.thumbid`"}[/img][/url]">
	  <a onclick="javascript:clipboardData.setData('Text','[url={g->url arg1="view=core.ShowItem" arg2="itemId=`$ItemGetURLsItem.id`"}][img]{g->url arg1="view=core.DownloadItem" arg2="itemId=`$ItemGetURLsItem.thumbid`"}[/img][/url]');window.status = '[TMB]{$ItemGetURLsItem.thumbid}[/TMB] copied to your clipboard for forum posting!';" href>[TMB]</a>
	</p>
{/if}


</div>
{/if}

{if $options.MiscItemId || $options.MiscThumbnailId || $options.MiscResizeId}
<div class="gbBlock">
	<h2>{g->text text="Misc."}</h2>
	
{if $options.MiscItemId}
	<p class="gbDescription">{g->text text="The Gallery ID for this image is "} {$ItemGetURLsItem.id}.</p>
{/if}

{if $ItemGetURLsItem.resizeid && $options.MiscResizeId}
	<p class="gbDescription">{g->text text="The resized  version ID that we're using is "} {$ItemGetURLsItem.resizeid}.</p>
{/if}

{if $options.MiscThumbnailId}
	<p class="gbDescription">{g->text text="The thumbnail ID for this image is "} {$ItemGetURLsItem.thumbid}.</p>
{/if}
</div>
{/if}

 
vogelap
vogelap's picture

Joined: 2005-05-18
Posts: 7
Posted: Wed, 2005-08-10 15:08

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.

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Tue, 2005-08-16 01:20

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.

 
whodah
whodah's picture

Joined: 2003-05-17
Posts: 96
Posted: Wed, 2005-08-17 15:00

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?

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Wed, 2005-08-17 15:40

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.

 
marco@mydub

Joined: 2004-01-07
Posts: 48
Posted: Sat, 2005-08-27 16:39

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 ?

 
marco@mydub

Joined: 2004-01-07
Posts: 48
Posted: Sat, 2005-08-27 17:39

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!