One particular module that I might like to contribute, providing my boss is amenable, is a small module I recently wrote for Drupal 7. I call it the "Internal Links" module. It is an input filter module which identifies internal links, and if they are to actual nodes, it:
1) changes the "href" attribute of the HTML link from node/[nid] -type paths to an existing URL alias, if found, which prevents links breaking if the URL alias changes, since relevant modules aren't yet available for D7 or weren't yet working well enough (Global Redirect/Path Redirect).
2) adds the node title of the linked node as the HTML "title" attribute for the link (good for SEO and usability/accessibility) to the link, but only if there is not already an existing "title" attribute. This was the primary purpose of the module and filled a request from copy editors who didn't want to deal with all the extra work of entering titles for the links.
3) Deals gracefully with "anchor" links (splits them off before identifying URL aliases and adds them, in parentheses, to the node title put in the HTML "title" for the link).
4) Leaves any other HTML attributes alone.
I'm also helping to maintain other modules maintained by Cocomore (so far only minor patches submitted), and am particularly interested in helping rfay with the Amazon Store module (http://drupal.org/project/amazon_store), since he has offered to accept me as a co-maintainer for the purposes of extending the module to deal with multiple locales (allowing visitors to a site to buy a product from more than one Amazon location, or from the location most convenient to them, assuming the same product is available from multiple Amazon regions.)
This is not really a Drupal module, but I'd also like to help with the Drupal project maintaining a tmbundle for Drupal-PHP development and help get a new branch working for Drupal 7 development.
Is that enough detail? ;-) If you have any questions, feel free to send me an email or provide a time we can go into Skype or chat/IRC and I can respond to any concerns you might have.
Best,
Lowell
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | intlinks.zip | 11.84 KB | lomo |
| #10 | intlinks.tar_.gz | 14.16 KB | lomo |
| #19 | intlinks.tgz | 10 KB | lomo |
| #17 | intlinks.tgz | 14.14 KB | lomo |
| #14 | EnableFilters.png | 64.12 KB | lomo |
Comments
Comment #1
rfay@LoMo, you are absolutely welcome to help out with Amazon Store. The way to start though is not with CVS maintainership. I wouldn't grant that until I'd seen some of your work in the issue queue. I don't see *any* posts from you in the amazon_store queue. I see only two posts in the amazon queue.
I would absolutely love help in the queue, and help with new features. But the way you start that is by offering patches and helping out. You don't just jump into CVS maintainership.
Again, I welcome you! Hope this helps explain how to start.
Comment #2
brianV commentedLoMo,
Since rfay hasn't approved you for co-maintainership, you will need to post a copy of your proposed module to this issue so it can be reviewed.
Comment #3
avpadernoComment #4
lomo commentedSorry, didn't meant to imply that you (rfay) had already approved my co-maintainer status or anything. I don't remember now exactly what you said (some time back), but I did know that I would need a CVS account to increase my ability to contribute and that that project was one that I might be willing to put some time into, to make it more useful for sites that might have visitors who would want to view links to different Amazon Store domain "locales" (.com/.de/.co.uk, etc). So it's been in the back of my mind as a reason to learn to write Drupal module code.
I'm attaching a small module that I've built up for a Drupal 7 project I was working on. It's the one I referenced in my initial post, but there is another input filter in it now and it's been through a few changes. While I was still in the middle of that, I didn't want to submit it for consideration.
I look forward to helping out with Amazon Store and/or other projects, but I'm not rushing to join any projects, yet, as a co-maintainer. And I'm sure it will take some time to digest and understand well enough how a module like Amazon Store works for me to be able to contribute any useful patches. In the meantime, I hope some others find this small module useful. I think it can help with SEO and certainly streamlines editorial workflow since it rewrites links to "normal Drupal paths" as SEO/visitor -friendly URL aliases.
I'm open to any feedback to help improve my first module. ;-)
Comment #5
donSchoe commentedHello,
please change the status to 'needs review' as soon as you update your application.
Status changed.
Comment #6
lomo commentedThanks, donSchoe... I forgot to change that. :-)
Comment #7
donSchoe commentedHello, just having a glance at your code.
Doxygen documentation looks very good, it's easy to follow your code.
As well as the code convention, it seems you did your homework.
Still, some annotations:
Is that just placeholder or mistake, your module is called 'intLinks'? Did you duplicate the title by accident? Reading the description of 'inLinks Integration' it seems to be something different.
// 'settings callback' => 'intlinks_title_filter_settings',Same here.
// ******* Following are "stubs" for common functionality which might be added ***And.
// @TODO: (if possible) get titles of any Views pathsOf course this is very usefull reading your code but you should check if you really need to comment everything.
I'm not working with Drupal 7 at the moment, so I only had a look at your bare code. Maybe someone else adds some additional hints for you. For now try to clean-up your module and prepare it to be ready for release.
Comment #8
lomo commentedThanks, again, for your observations, donSchoe. You are right: "inlinks" is a typo.
Of course I can remove some of the comments that are not really necessary. I left them in, only to make the code a little easier to follow, both for myself and others. I am still learning Drupal standards for documentation, etc, but the last run in "Coder" didn't make any mention of any of the documentation issues, so I am grateful for your feedback.
When I'm home, this evening, I'll amend my code to follow your recommended remedies and correct the mistakes.
Can't "@todo:" items be in the code just to make it clear where we might want to add extra functionality? I'm pretty sure I've seen them in released modules. (?)
Comment #9
rfayYes, you can leave TODO's in the code.
There are some comment lines longer than 80 characters. Probably want to break those.
If you haven't already run it through coder why don't you do that.
Overall, not bad, IMO.
Comment #10
lomo commentedThank you for confirming that, rfay. I appreciate you having taken the time to look at my code and provide feedback.
I've taken care of not only the comment lines, but all others are now 80 characters or less. I've also made a few minor tweaks to improve logic, to reduce some redundancy, and to comply with other Drupal coding standards I noticed on re-reading (again), etc.
I have used Coder several times in the process of writing this module, and it's been helpful. The other day, after I started using the "beta6" version, a new SQL warning appeared, but it doesn't make much sense to me and is linked to a non-existent page in the Drupal API. It had never complained about the functions which used db_query() before that, and they haven't changed, but that's a new feature in the coder module. Maybe someone can let me know if I really *should* change the following query?
//The message:
(from intlinks_title_filter.inc - Line 30: Potential problem: "SELECT FROM {node}" statements should probably be wrapped in d and with the alias for {node} table defined (e.g. {node} n).// The code in question:
There is a link to the supposed function in the Drupal API, but its path seem to be non-existent. The link just redirects to the main Drupal API page.
If there is an issue with that kind of query (there are a couple functions in the module that call db_query in this format), I'd appreciate a pointer to improve my code. Otherwise, the code passes with flying colors, even when I turn on reporting for the most trivial of issues. :-)
Comment #11
lomo commentedI was just reading other CVS applications and learned something new: Although I've seen l(t()) function wrapping in various contributed modules, apparently that's not the best way to do it.
The attached version uses what's considered better style. That is the only real change between this version and the last submitted (changes in the output of the "help" function).
Comment #12
donSchoe commentedHi,
I just installed your module and I was reading almost the whole readme.txt but still I'm not sure whether I understand what this module is actually doing. It seem's to work but could you give any examples of usage? I didn't notice any changes after activating the module (except in the admin menu
/admin/config/content/formats)...Comment #13
lomo commentedHi donSchoe... you need to activate one or more of the input filters for one or more of your text formats, just like any other input filter (line break converter, HTML corrector, etc). If you haven't done that, then you wouldn't see any effect. The difference between these filters and the standard ones is that it creates database queries necessary to re-write parts of the content on output (hence why I suggest that output be cached or this could be a bottleneck on very active sites or those with limited resources, e.g. on shared hosting).
Then you need to have some links from one node to another. The module's action is on "internal links". Assuming you've enabled the "title" filter for "Full HTML" and have content that's written in Full HTML, with links to other nodes (can be href="/path/to/other/node" or href="/node/123"), then you will see the link titles for the other nodes when you "hover" over them with your mouse pointer. And if you use "Drupal normal paths" (e.g. node/123) in the link, you'll also see those change to any URL alias you have entered, if there is one. Assuming you've enabled the "bad links" filter, any links you've added to unpublished or non-existent paths or nodes will be unlinked, within certain limits; I've coded it so that it errs on the side of caution, leaving in some links that you might want to have, if there's any real doubt. These are both meant to improve workflow for editors on sites with a lot of cross-linking between different articles -- it helps with SEO and user-friendliness while taking some of the drudge-work out of the equation.
If the module is accepted for contrib, I'll create an illustrated guide for its use, since it's not like most modules where you just turn it on and have some functionality and it doesn't (currently) have any real administration (some options may be added in a future iteration, especially if I hear requests for certain options). The "help" text is meant to explain how it works, but site builders without a lot of experience might still not understand that they need to edit the (for example) Full HTML configuration to turn on the action of the filter(s) they wish to use. And even for more experienced Drupalistas, it can be an easy step to forget. ;-)
Does that clarify it a bit more?
Comment #14
lomo commentedHmmm... looks like I can edit my last comment, but can't add a file. I'm attaching a screenshot.
This is the view of a typical Admin panel for enabling filters for a "text format". Obviously you need to enable the fiter(s) on a format that allows adding
<a>tags, or no links will appear. The path to these settings isadmin/config/content/formats/3for Full HTML.My module adds "help" info at
admin/help/intlinksand further information can be found in the general "filter help" at:admin/help/filter.(screenshot attached)
Comment #15
avpadernoComment #16
donSchoe commentedYes I know how to activate and arrange the filters. Maybe I need to look closer to the changes that happen to my Drupal as soon as I activate it.
/admin/help/intlinkshelp is working fine./admin/config/content/formatsconfiguration is working fine.But I don't see any changes after activating the filters like you did.
preview with filters enabled like you did on your screenshot.
Comment #17
lomo commented@donSchoe: LOL... Okay, but ... Those aren't nodes! They are all either special Drupal paths or, in the case of the last, a false "node/" path. By design, the last path is left linked, because it *might* be a special path that wasn't caught -- only "/node/" paths get that treatment since they can come in many flavors, including ones with node IDs in the middle or end. I may tighten up what is allowed (using Regex) for that, but the "hide bad" filter is really meant just to unlink unpublished content, not to catch any weird path (or non-path) that someone tries to throw to it. It unlinks a lot of other false paths, but errs on the side of caution. For now, I've left it relatively "plain Jane"; it does what the requirements needed for a normal editorial use case: unlinks unpublished content, which would otherwise not be viewable by an unprivileged visitor to the site (and would produce a "page not found" error).
The title filter will ONLY show any effect if you have other nodes you are linking to, so none of your links would qualify. You need at least one other node to link to in order to see any effect. I hope things are clearer now. :-)
I'm attaching a new "version" of the module that polishes up a couple of stray comments that weren't perfectly formatted.
Comment #18
lomo commentedI don't know if you've seen the module working now, donSchoe, but I'm guessing that since you have some nodes on your site with links from one to another, that you might have enabled and see the filter in action. You may need to clear caches if you didn't see it working.
Incidentally, the module is in use on a production site, so you can see at least the Internal links Title filter in action... here: http://schlafschlafen.de/muedigkeit/jetlag.html
(That's just one page that has a few links to other nodes, and if you roll over a link, you'll see the titles of those other nodes.) The site was created as an experiment with Drupal 7 and HTML5 with an emphasis on SEO, so it doesn't currently have a lot of images or other "nice stuff" for human visitors. It's just recently been launched and the staff maintaining the site do have plans to build it up more, over time, for human traffic. I was one of the developer/site builders and we started working out how to achieve the needs in the requirements docs and building the first parts when D7 was still in alpha.
I'm also attaching another version of the module which differs from the last only in that I've removed the LICENSE.txt file (which I understand is automatically added by the system) and the addition of a // in front of the $Id$ at the top of my README.txt file.
I'm currently working on building tests (Simpletest-based) for a much more ambitious mostly-Drupal 7-based project (with requirements docs that look like a full-length book and a number of technologies not usually bridged with Drupal), so I may take what I'm learning about test-writing to build some tests for this module, too... but in the meantime, I've tested it fairly extensively on several different development sites with just about every different type of root-relative path to other nodes I could come up with (links with #anchor-text appended to them — retained, even if the node-path is rewritten; URL aliases, Drupal "normal paths" — which get re-written to path aliases — links with other attributes added — which are retained, as they should be — links with existing titles, which are kept intact, links to unpublished content, which are unlinked by the "hide bad", and more... its only current weaknesses (that I know of) is that it doesn't get titles that might be on Views pages (and other special pages which are not node-based) and it may not recognize all system paths, especially those with wildcards, so that's at the top of my "todo" list (for the "hide bad links" filter; obviously getting titles of Views pages is for the Titles filter). Otherwise, the filters seem to "just work" and certainly work for all the "normal content" use cases the site I built it for was interested in, so I hope that's the experience in the greater Drupal community, too.
Thanks, again, to those who've taken the time to look at and comment on my code. This is a great opportunity to build my Drupal development skills and learn about "best practices", so I welcome all constructive criticism and feedback. :-)
Comment #19
lomo commentedNot sure what happened to the attachment... Let's try that again. The changes in this are trivial (for code review), but make some improvements to be sure the module is ready for CVS.
Comment #20
lomo commented@rfay: (BTW) You were right, of course. It was the Amazon Module that I was thinking of, with regard to locale selection. And of course you didn't offer to make me a co-maintainer if I created something to contribute. I guess that at the time I read your response, I was surprised you were open to allowing unknown people to "contribute", and at the time I guess I thought that meant committing to the code, now I'm not such a n00b that I would make that assumption -- I'd know you meant, "contribute a patch". :-P Until 6 weeks ago, I'd never made a patch, so I'm learning what's necessary to contribute, a step at a time.
I've mainly back-burnered personal projects while working on this internship, and may not get started again with the site where I was experimenting with the Amazon/store modules until I'm ready to migrate the site to D7, but perhaps I can work on helping port some modules to D7 and/or implement new features for some modules as I continue to learn my way around the API and get comfortable (again) with coding in PHP; till recently it had been a few years since I'd done much more than a template here or there, so I'm just getting back in the swing of things, PHP-wise.
Again, I really appreciate your feedback. Getting a few pairs of experienced eyes (like yours) on my code, and any responses that come to mind, can only help me improve.
Comment #21
rfayIMO LoMo has shown good faith, has been responsive in the queue, and has written code that would be fine in the issue queue. Let's not make this any harder, and get a good contributor into the community. RTBC.
Comment #22
avpadernoWelcome on board!
Comment #23
lomo commentedThank you both, rfay and kiamlaluno. :-)
I'm working on the HTML version of my project description now. Once I've done some decent documentation for this module, I'd like to see where I can pitch in on other docs-related efforts, so I'll be in touch with you Randy; I see you are very active in the documentation efforts and perhaps you have an idea where I could be of service.
Comment #24
rfay@LoMo, feel free to join us in the Documentation sprint today in #drupal-docs. It starts in about 2.5 hours. We'd love to have you. You don't have to ask too many times :-) We have oh-so-much to do.
Comment #25
lomo commented@rfay: Sorry, I'm I joined my wife to a birthday party not long after my last post here and didn't see your response for over a day since I've been trying to get Eclipse/CVS not to choke on checking out the full contrib repository... seems crazy that's required to add one tiny lil module. ;-) After the party I worked on finishing my project description and thought adding it would be simple, but it seems that's the hard part -- well, maybe it won't be once I have one full successful update of the repository, but even with 8GB RAM and what I'd think is plenty getting allocated to Eclipse, I see out of memory issues and it seems it keeps throwing up conflicts about "existing resources" (and terminating CVS processes), but there was nothing in the project before the checkout. (sigh). I'll get there... then I do want to help with some of the community tasks that are still remaining, including documentation.
The attached version is the one I'll be adding to CVS, though perhaps I'll have to do that from work tomorrow, depending on how things go here. There are some improvements to matching of paths in the menu_router table (to keep the "hide bad" links filter from removing links to some valid Drupal paths).
Comment #26
rfayYou may want to use the command line :-) If you're using Eclipse Helios, you might want to go back to Galileo. Helios is pretty famed for being quite a hog. However, you can up the java config to get it usable.
Comment #27
brianV commentedLomo - you can have CVS just check out the directory structure.
See http://drupal.org/handbook/cvs/quickstart#add
Note the -l parameter, which only checks out the directory you ask for, and not all it's contained files / subdirectories. You may have to use the command line to accomplish this properly.
Comment #28
lomo commented@brianV: Yeah, I was following directions that seemed to indicated downloading the whole repository was necessary. Anyway, I moved most of the other modules and themes, etc, out of the Eclipse "project" for now, so was finally able to "refresh" to see this module in my project and commit it. So the Internal links module is officially released. :-)
@rfay: I'm not sure if you can modify the java config for Eclipse in OS X or if it's normally necessary. It was using a lot when I looked... a lot more physical memory than the 256 MB they say is the default maximum - closer to 780MB. It is Helios, but I think the real problem was trying to open so much code at once. Looks like I even had D5 modules in the "project" and Eclipse was overwhelmed, flagging files that needed to have syntax errors corrected. Perhaps it would have been fine if I'd checked out only the D7 contrib modules or something.
Comment #29
lomo commentedOops... somehow managed to double-save my reply.