Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm working on a project that requires this module and needs tracking functionality added to it. Much to my delight, the database table already existed but wasn't being used, so the attached patch adds the logging functionality. Step two obviously is creating a page to display it. I'll be working on that over the next few days but wanted to create an issue now in case anyone else wants to contribute to this feature.
Comment | File | Size | Author |
---|---|---|---|
#55 | shorturl_p36+p51.patch | 25.91 KB | utvikl |
#56 | shorturl_p36+p51.patch | 25.91 KB | utvikl |
#51 | shorturl_user_patch.patch | 509 bytes | AtomicStudios |
#36 | shorturl_stats_and_schema.patch | 22.67 KB | seanburlington |
#23 | shorturl.patch | 27.88 KB | seanr |
Comments
Comment #1
irakli CreditAttribution: irakli commentedHey Sean,
yeah, I implemented the data-model part, but never got to creating the UI, was kindof hoping somebody like you would help with that :)
If you are interested in contributing your code, that's definitely something this module would benefit from.
thanks
Comment #2
seanrI've been working with it and gotten quite a ways, but there's still plenty more to do. I'll try to get an updated patch up tonight. You can see what I've done here:
http://drupal6.webolutionary.com/shorturl
Comment #3
irakli CreditAttribution: irakli commentedVery nice.
I am going to start shorturl_ui submodule, soon and this and other such things could roll into that.
Another thing I want to add, and will work on is a settings page. First two settings:
1. ShortURL domain (e.g. Techcrunch.com uses tcrn.ch as its short URL domain and we need to give users easy way to indicate such domain)
2. A textarea where admin can enter comma-delimited list of reserved keywords.
Comment #4
seanrThe reserved keyworks issue is already handled by the shorten module. The other one could go as a patch against that too, unless you're looking to give shorturl its own form independent of shorten (and maybe that is worth doing?).
Comment #5
irakli CreditAttribution: irakli commentedGood point.
I think there is still need for settings if you just install shorturl and don't install shorten. Requiring shorten just for the sake of settings sounds like an overkill. I am also not sure how they tell shorturl to nor produce a blocked short url. Knowing shorturl code, I don't think shorten has a way of doing it. I will have to check. In any case, shorturl should work on its own too, I think.
What if we wrote the part of shorturl settings that shorten also has, into the same variables they do - that way whichever interface you change these settings from (if the two are both installed) - the settings will be synced.
I think it would be the safest integration? And would allow shorten to safely let shorturl know which pathes to not register.
Comment #6
seanrThat's possible. Here's a consideration, though. If you do the check in shorturl, how do you report the error back to shorten if someone submits a bad URL? I guess you'd have to do it as a form alter, at that point. I already did that with my tldrestrict module - something like that could be folded into this one (and maybe we'd make it more like the Access Rules page to accommodate both allow and deny).
Comment #7
irakli CreditAttribution: irakli commentedNot really a problem, unless I am missing something.
Shorturl does not really allow people to suggest URLs (like bit.ly does) it just generates new tokens. If a generated token conflicts with one of the "block URL" ones, it will disregard and re-generate and return the next one. So shorten does not really need to know about it, I think. It will just always get "good" ones and should be happy :)
Comment #8
irakli CreditAttribution: irakli commentedI was not able to find "reserved keywords" setting in the shorten module settings page (please see the attached image) even though I installed the dev release.
Am I missing something?
Comment #9
seanrirakli - not seeing it now myself either. Not sure what happened to it.
Comment #10
CarbonPig CreditAttribution: CarbonPig commentedHi seanr and irakli,
I've been following this module development and really like your ideas. What about using http://drupal.org/project/path_blacklist as a related module to reserve paths?
Just a thought from a novice.
-CarbonPig
Comment #11
seanrUpdated patch here. Now provides per user tracking and details pages for individual links (still needs work). It also adds a setting to allow duplicate links.
Comment #12
irakli CreditAttribution: irakli commentedThank you. Will try to review patch as soon as possible.
Many thanks.
Comment #13
seanrI'll have an updated patch coming soon. I've done some more work, but there's still a bit more to go.
Comment #14
irakli CreditAttribution: irakli commentedThank you!
Comment #15
Dave the Brave CreditAttribution: Dave the Brave commentedThis is looking great, seanr! I've been looking for something that emulates Pretty Links plugin over at Wordpress. Makes sense that we have tracking alongside shortened URLs.
I'll be testing, so looking forward to your next patch.
Update:
On clean install, admin/reports/shorturl -
Comment #16
seanrLooks like the install file needs a field. I'll fix that this weekend. I should actually get most of the remaining functionality done tomorrow, so I'll have another patch either way. BTW, that domain name kinda misses the point of a URL shortener. :-P
Comment #17
EgonO CreditAttribution: EgonO commentedsubscribe
Comment #18
gsgchoi CreditAttribution: gsgchoi commentedHi, I am trying to use this module but I am getting below error message. It looks like that it fails to create shorturl_link table. Can you please let me know what's the issue here.
# user warning: query: CREATE TABLE shorturl_link ( lid serial CHECK (lid >= 0)(22), orig_url varchar(255) NOT NULL default '', created int NOT NULL default 0, remote_ip varchar(20) default '', PRIMARY KEY (lid) ) in /var/www/webserver.wordstream.com/includes/database.inc on line 517.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "shorturl_link" does not exist in /var/www/webserver.wordstream.com/includes/database.pgsql.inc on line 139.
Comment #19
gsgchoi CreditAttribution: gsgchoi commentedThis is the full error message.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "(" at character 58 in /var/www/webserver.wordstream.com/includes/database.pgsql.inc on line 139.
# user warning: query: CREATE TABLE shorturl_link ( lid serial CHECK (lid >= 0)(22), orig_url varchar(255) NOT NULL default '', created int NOT NULL default 0, remote_ip varchar(20) default '', PRIMARY KEY (lid) ) in /var/www/webserver.wordstream.com/includes/database.inc on line 517.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "shorturl_link" does not exist in /var/www/webserver.wordstream.com/includes/database.pgsql.inc on line 139.
Comment #20
irakli CreditAttribution: irakli commentedggschol - please don't rename issues that are about another thing. Just open a new issue. Your query error has nothing to do with implementing metrics, which the original issue was about.
Now regarding your problem (but do open a new issue if you want to continue discussing it):
Looks like you are installing it on PostgreSQL. Module is not tested with Postgres and I would highly advise against using it with postgres. Postgres may have some benefits, but it's definitely way slower than MySQL. MySQL is much more appropriate if you need t use this module and set up a URL Shortener.
That said - if somebody has time to test it with Postgres and provide patch - i would be open to integrating it.
Comment #21
irakli CreditAttribution: irakli commented---
Comment #22
seanrHere's a final patch. I'd like to add some caching to it, but the functionality is 100% working at this point. If we can get this patch reviewed and committed soon, that'd be helpful, as I've had several people asking about it. It's currently live at http://go.usa.gov and http://drupa.ly.
Comment #23
seanrOK, final patch with all the improvements we talked about at the meetup.
Comment #24
seanrComment #25
rj CreditAttribution: rj commentedThe patch worked but there are a few concernd. When a link has zero clicks, instead of "details for XXX" node, it says "view all 2 links to this page", which only returns one result. See "agile approach" on this page here: http://cmd.to.
The "view own statistics" permission does not work as it should. Users without this permission can still view shorturl/user/uid and shorturl/link/lid, even though they cannot view shorturl/list/lid.
Finally, the All users menu tab is missing and I havent figured out why.
I'll hack away at this later. Thanks for the work, this is great.
Comment #26
rj CreditAttribution: rj commentedand another weird thing it's doing is creating 200+ links whenever I click on menu link to a node.
edit: I deleted all the created records (973) but can't get it to repeat. I'll submit as a bug next time.
edit: I'll submit this next question as a feature request, too
This may be off-topic, but have you considered implementing short URL as a content type + CCK fields? This would allow integration with views for tracking and metrics....
Comment #27
seanrRegarding links with zero clicks - I cannot reproduce that. I also don't see Agile Approach anywhere on the site you linked to. I couldn't reproduce the menu issue either. I'll look into the permissions issue.
Comment #28
rj CreditAttribution: rj commentedThe patch is no longer live on the site, I reverted back to the original module w/no stats. The site started creating exactly 200 menu links again for every non-shortened link. It's very intermittent; I would delete the excess links but they would re-appear after 24-48 hours. I can't get it to reproduce, I'll keep you posted if I do, any suggestions on testing would be appreciated. Thanks.
Comment #29
Matt V. CreditAttribution: Matt V. commentedIt took me a while to realize why the patch from comment #23 wasn't applying, which was due to the fact that it's based on the DRUPAL-6--1 branch, instead of 6.x-1.0-beta, which is the version mentioned here in the issue. Once I figured that out, the patch applied cleanly.
I think the patch is a worthy addition, as is. I'll report back if I notice any problems.
My main initial feedback would be to suggest using Views for generating the reports. That would provide a lot of flexibility in how the reports could be output.
Comment #30
youkho CreditAttribution: youkho commentedsubscribe
Comment #31
seanrFWIW, this patch has been running on http://go.usa.gov for a couple months now under heavy traffic with no issues (try a search for it on Twitter, BTW). I've also been running it at http://drupa.ly without issue. I haven't been able to reproduce the menu bug at all. Is there anything blocking this from being committed?
Comment #32
youkho CreditAttribution: youkho commentedCan't patch the module so please if someone can upload a patched version.
Comment #33
seanburlington CreditAttribution: seanburlington commentedIt looks like the module has been developed without use of this patch - and the patch no longer applied to the latest version.
This is a real shame as the patch looks very useful - and the hosted module also has useful developments
I'm currently evaluating this for my current client - right now I just want to document how to apply it
To get a copy of the module that does accept the patch
Comment #34
youkho CreditAttribution: youkho commentedthanks Sean but i couldn't get this to work :/
Comment #35
seanburlington CreditAttribution: seanburlington commentedhmm.. I'm so unfamiliar with CVS these days that I'd actually imported to git in order to figure out what code I wanted and then tried to write what I thought where the CVS commands
I've redone and tested the following (NB password for CVS is "anonynous" )
I've uploaded a copy of the patched module here (NB it doesn't contain the latest development changes - which include bugfixes)
http://www.practicalweb.co.uk/blog/10/02/22/drupal-url-shortener
Comment #36
seanburlington CreditAttribution: seanburlington commentedI've re-rolled the patch and also incorporated the critical bugfix #627668: Wrong database schema (totally breaks -dev version)
This now applies against the latest development version
I'll update this page in a moment
http://www.practicalweb.co.uk/blog/10/02/22/drupal-url-shortener
and add an updated download
Comment #37
designerbrent CreditAttribution: designerbrent commentedI got this to work fine with the patch in 36 and would love to see this committed.
However there is a related issue that rj raises in #25: When a link has been created but has no click throughs, the summary report says "view all 2 links to this page" but while for ones that have been clicked on, it says "details for lql". And that doesn't matter how many clicks it's had or how many links are on that page. Something just doesn't seem right about that. I looked at the code and found on line 205 it creates that $links variable but it appears to be backwards. My guess is that should be the other way. However, I couldn't exactly figure out the intent of the developer on this so I didn't try to fix it.
Comment #38
irakli CreditAttribution: irakli commentedThanks to everybody who has contributed.
There're several issues with the patch:
Overall, while this is a wonderful functionality, code itself needs significant work.
I realize it's important and don't want to hold back applying changes, but It's no small patch so it can not be done unless we address major concerns listed above, first.
Comment #39
irakli CreditAttribution: irakli commentedComment #40
seanburlington CreditAttribution: seanburlington commented@designerbrent - glad you found it useful
@irakli - I'm continuing to develop a version of this module it's getting to be really quite different from the one in CVS
Many of my changes are not suitable for general purpose use - I've gone for an optimised solution with stats collated by parsing logfiles instead of using hook_init and various other tweaks that require root access - so even if I address the issue above I no longer have code that you're likely to want.
I may be able to release the final work as a seperate module - but this depends on my client.
Comment #41
irakli CreditAttribution: irakli commentedSean,
that's fine. Can you write your module so that it is re-using code in this module rather than forking it, though? That would be important for not allowing code duplication.
Let me know if you need this module to implement any hooks to allow you do that.
Comment #42
seanburlington CreditAttribution: seanburlington commentedHi Irakali,
I tried really hard to avoid forking - that's why I started by posting the patch to try and get metrics into the main codebase.
I think in effect the code forked when seanr's code wasn't integrated into the main branch before further development.
I've been posting issues for several weeks - but without response I just had to carry on coding - refactoring where needed.
If you want to include the patch above that would be great - and increases the chances that the further work I've done will be compatible.
But I understand if you don't want to do this.
Comment #43
seanburlington CreditAttribution: seanburlington commentedoops - posted twice
Comment #44
irakli CreditAttribution: irakli commentedI apologize for not following up to Seanr's patch in a more timely manner, but I maintain a lot of modules and it's not easy.
That said, it's perfectly fine to create a module which provides additional functionality to an existing module. Allowing such things easily is why most of us love Drupal, in the first place. So there's nothing wrong with you writing a separate module that provides statistics to shorturl and maintaining that module yourself, as far as you don't just copy/paste entire code of an existing module.
Instead, a more elegant and maintainable solution would be, if you keep writing your module, but let me know what hooks you need me to create, so I can call your code when appropriate and you can remove code already existing in this module from your module.
Makes sense?
Comment #45
seanburlington CreditAttribution: seanburlington commentedHey - no problem - we all get busy
However it is too late now for the approach you suggest.
Comment #46
sillygwailoComment #47
ddorian CreditAttribution: ddorian commentedany update on this?
Comment #48
Danny Englandersubscribing
Comment #49
Fidelix CreditAttribution: Fidelix commentedsubscribing.
I am in need of something like this, it would be an excelent feature.
Comment #50
irakli CreditAttribution: irakli commentedNeed to do more research, but I think this is now handled by shorten, in which case, there is little sense in re-implementing the same here.
In any case, this is not a bug so changing to "Feature Request".
Comment #51
AtomicStudios CreditAttribution: AtomicStudios commentedI found a bug in this patch where the user object wasn't being called in the get_token hook. Simple fix attached.
Comment #52
STINGER_LP CreditAttribution: STINGER_LP commentedI'm looking forward for this feature! Any specific time frame when it will be implemented in module release?
Is it safe to use patch in comment #51 for production sites?
Comment #53
MrAdamJohn CreditAttribution: MrAdamJohn commentedWhat are next steps to get'r done? Willing and able to help out - contact me via d.o contact form any time.
Comment #54
mgiffordOk, so if you want metrics you start with #36 & then apply #51 and voila you've got basic metrics.
So what is stopping this from getting into the module?
trick is that #patch #36 hasn't kept up with version = "6.x-1.1" & datestamp = "1277261409"
patching file shorturl.install
Hunk #1 FAILED at 12.
Hunk #2 FAILED at 64.
2 out of 2 hunks FAILED -- saving rejects to file shorturl.install.rej
Comment #55
utvikl CreditAttribution: utvikl commentedIt's a pity that it needs to be this way, but here is a patch that should apply cleanly to 6--1 (patch 36+51).
Has anyone any information regarding progress with metrics and shorten? Couldn't find any traces in the code nor info on the project.
SEE: 56 for correct patch
Comment #56
utvikl CreditAttribution: utvikl commentedWas a small error there with size of orig_url. Fixed here.