Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2007-12-04 16:55:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

OK, cracked it. v0.2 now supports download counts on remote files. In contrast to the existing ‘local’ downloads, remote files only increment the counter if the file exists at its destination AND its TXP status is ‘live’. With local files, if you cheat and adjust the URL manually in the address bar, the file will still download regardless of its hidden/pending status in the admin interface.

Note that smd_file_download_link is now optional. Use it only if you need to specify a particular remote url from the ones you have uploaded. Otherwise, you might as well use the built in file_download_link because it acts in exactly the same way, understands remote files and automatically load balances from the available remote files.

I’ve also added a few status messages like “file uploaded” and “file already exists”, BUT I don’t know how long they will work. Since I couldn’t find a way of inserting them in the page flow with pagetop() I added them to the DOM afterwards with jquery. This will likely break if the admin page layout changes in TXP 4.0.6 and beyond. Anyone with any specifics on how the HTML tags in the admin layout are going to look in 4.0.6 please let me know (or can anyone tell me how to poke status messages into the admin interface properly without calling pagetop() or file_list()…?)

As ever, take it away, play with it and have fun.

EDIT: Note that with this version, you will always “see” the .link on the end of the URL if you choose to display the filename on your site. If this bothers you, either use a different attribute to display on your page or smd_file_download_image to show a picture instead. It may be possible for me to get round this if there’s enough outcry, but the trade-off is I’ll need at least one more call to the database for every file download click (local and remote) so I can test which type of file has been chosen. It may not be possible at all, I haven’t looked into it yet.

Last edited by Bloke (2007-12-04 20:03:53)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#14 2007-12-04 17:00:38

aswihart
Member
From: Pittsburgh, PA
Registered: 2006-07-22
Posts: 345
Website

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

Awesome job Bloke, can’t wait to try it out!

Offline

#15 2007-12-04 23:33:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

I relented. v0.3 has the fix for the EDIT in my last post.

The native file_download_link will always display the .link on the end. If you don’t like it, you can now switch to smd_file_download_link instead: by default that omits the .link. If you find yourself yearning for the .link, add the show_link="1" attribute. This is all on the public side; the admin interface will always show the .link to remind you it’s a remote file.

In the process of fixing that I made a few minor, but possibly important, changes to the download procedure:

  1. File handling of both local and remote files are now disallowed if the status is anything other than “live”. This will be removed when the TXP core is patched
  2. Error handling is now passed back to TextPattern in the event of a 403 or 404. True local files are still handled by TXP after the initial verification of their status by the plugin
  3. Remote files will not be served if their file size differs from that in the database. This should not be a problem under normal circumstances. The docs explain more

Hopefully this version’s better. Shout if you think of anything or spot any nastiness.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#16 2007-12-05 21:08:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

A minor mod to take the plugin to v0.31. Mainly of use to those people at the bleeding edge of TXP development who keep their changesets up-to-date.

Mary kindly patched the core (r2720) to address point 1) of my last post. As a consequence, this rev of the plugin now checks if the file has already been denied access and gracefully does nothing in this eventuality, handing back to TXP to take action.

When 4.0.6 is released with this changeset a permanent feature I’ll revisit the plugin and strip out the unnecessary status-checking functionality for good.

Last edited by Bloke (2007-12-05 21:11:02)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#17 2007-12-13 00:19:06

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

An enhancement to the ifmissing attribute: you can now use an image to indicate a missing file download image(!)

Specify ifmissing="?image:42" if you want to refer to the image by id, or use something like ifmissing="?image:PicNotHere.jpg" to use an image name. Note the image has to be in the TXP database and if you reference an image that doesn’t exist, you’ll get nothing back. The online help details the new option.

IMPORTANT: In light of this change, I adjusted the naming of the argument used in v0.31 and below. Instead of ifmissing="?file" being the default, it is now ifmissing="?ref". The ‘?file’ version is no longer used, since it might imply you could replace the missing file with another file from the Files tab, which is not the case! Sorry for the inconvenience.

Enjoy v0.32 and shout if you spot anything, good or bad.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#18 2008-02-03 01:13:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

A new version is out to coincide with the release of TXP v4.0.6.

!! v0.4 (compressed) is for TXP 4.0.6 and higher ONLY !!

Running it on any prior version will result in an ugly warning message on the Files tab.

Enhancements in this version:

  • Better upload support. When editing a .link remote file you can now upload an additional URL directly from the edit screen, optionally overwriting all other URLs if you wish
  • Reduced the timeout to try and avoid horrible error messages when remote servers take too long to respond to a file size request. Not sure if it’s fixed as the server I’m testing it against is working fine :-\
  • Removed the hack that checks the file status, since Mary kindly updated the core to handle it
  • Slightly improved error messages thanks to some language updates in the core

Known issue:

  • If editing a “normal” file (not a .link) and you hit the Upload button without specifying a file, the URL upload box does not appear on the File List page. Hitting the Files tab again or performing some other action re-instates it. *shrug* no idea why but it’s not a major hassle. If anyone has any clues, please let me know.

Enjoy, and report anything squiffy here as always.

Last edited by Bloke (2008-02-03 01:14:44)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#19 2008-04-02 10:32:28

aswihart
Member
From: Pittsburgh, PA
Registered: 2006-07-22
Posts: 345
Website

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

Just got around to trying out smd_remote_file, great work Stef. Not sure why but my remote file links still have the .link attached to them, I even tried adding the attribute show_link="0" to no avail. Any ideas?

BTW, I have your plugin working with Amazon S3 now, just like I had dreamed (hehe). Now I include S3-hosted files in article-specific file download lists using upm_file along with the download count tracker built-in to Textpattern. See my Final Rotation movie page for an example. Now I just need to figure out how to load the FLV player with different files by clicking on links (along with the regular links to the files). Thanks a lot!

Last edited by aswihart (2008-04-02 10:44:28)

Offline

#20 2008-04-02 16:07:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

aswihart wrote:

Not sure why but my remote file links still have the .link attached to them,

Y’know, the other day I spotted that too and thought it must have been my setup but I just checked and it’s gotta be something that screwed up in the latest version (or maybe something subtle changed in TXP4.0.6 that I have to compensate for). Thing is, when I modded the plugin to make it work with 4.0.6 I didn’t touch that bit of the code. Hmmm, I’ll see if I can figure out what I’ve done wrong and post a fix sharpish.

Thanks for the confirmation that it’s not just me going slowly mad. Unlike the guy in Final Rotation :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#21 2008-04-02 16:54:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

Heh, or it could be me being a total tool.

Try v0.41 [ compressed ] which adds the smd_file_download_name tag. Sometimes I’m such a dilbert; fancy offering an option to remove the .link from the URL and forgetting to add an option to allow you to remove the .link from the file name that you display to visitors, duh!

Under TXP4.0.6 you should now be able to use smd_file_download_link and smd_file_download_name; both tags in their default configuration will remove the .link. Add show_link="1" to re-instate it (or use the built-in file_download_* tags).

Sorry about my dimness. Let me know if that gets you going.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#22 2008-04-02 18:35:57

aswihart
Member
From: Pittsburgh, PA
Registered: 2006-07-22
Posts: 345
Website

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

Works great Bloke, thanks so much for this awesome plugin.

Offline

#23 2008-04-09 09:01:53

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

Minor bug fix for handling of the .link extension in smd_file_download_link. Sometimes the .link was left behind.

v0.42 [ compressed ]


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#24 2008-05-01 10:31:01

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: smd_remote_file: Manage remote URL downloads via TXP's Files tab

Bloke – which file services have you used (apart from fileden) with this plugin?

does it only work with the services that allow a direct link to the file (as opposed to the ones that make you wait 30 seconds, etc)?

Offline

Board footer

Powered by FluxBB