Updating Scripture Filter to take advantage of the ESV API
andykemp - June 6, 2007 - 22:29
| Project: | Scripture Filter |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | andykemp |
| Status: | needs review |
Description
I have been setting up a new site in drupal and having recently moved from using wordpress missed many of the excellent features of both:
So I have set about porting some of those features over to Scripture Filter...
I don't know how to make patch files but have tried to mostly add stuff below the original code with a couple of exceptions which I have commented on within the code itself. Feel free to comment/change as you see fit! I just though others might like some of these features!
The scripturefilter.module and scripturefilter.inc files have both been edited, in addition you also need two js files and a css file.
Andy
| Attachment | Size |
|---|---|
| scripturefilter.module.txt | 14.21 KB |

#1
#2
#3
#4
I'm sure there must be quicker way to upload more than one file!
Test page where you can see the module working (currently set to collapsing block display)
#5
Sorry didn't notice that changing the title for the comment would change the whole title... Still learning!
#6
Two little tweaks to make the code XHTML Strict Compliant, and to clear out the Input_filter cache so changes to setting are visible straight away.
#7
File didn't upload...
#8
And the inc file
#9
The changes to the inc file, replacing the span with a div, causing the module to break the paragraph where the text occours if you have the ESV text displaying in a collasible block...
It might be possible to replace all the p, h etc tags with span tags and give them the same properties as the paragraph tags which are not compliant if within a span tag... I will try and take another look at it later...
#10
Some more changes! To make it (mostly) compliant, I have replaced all the h2,h3 and p tags that the esv feed generates, and replaced them with span tags with display:block. However the flash audio player they inject isn't compliant, so if you plan on using that you should be aware. Currently flash is VERY difficult to insert and remain compliant if you want it to work on most players...
Rather than continue to upload odd files here and there as I make changes I thought I would upload the whole lot as a zip file and host it on my website for a while...
Latest Version can be found: here
If anyone has any thoughts and/or suggestions, let me know and I'll try and work them in... The problem is there is so much extra code now it is more new than old. If people feel this is too much bloat, should I consider forking this off into another module?
Cheers,
Andy
#11
The latest version now takes advantage of the work Chris did on the Regex, so it will now accept references like - Romans 1:5-2:7...
Any body fancy doing some testing and letting me know if it works on other systems...
Latest Version: Download - Same link as above...
Andy
#12
Errors on IE7 are now fixed! Trying to get rid of the p tags I ended up removing the param tags as well!
The new regex also allows you to enter things like Matthew 5:3;7;8;12!
Andy
#13
I have been playing around with jQuery and have managed to trim down the module a little by doing away with one of the js files and replacing it with a graphically more insteresting and code-wise much smaller piece of jquery script.
I have also tidyed up the menu's a little...
Latest version is at the same links as above.
Any comments?
#14
Incase this is preferable to anyone this is a patch version.
I amworking on getting a sandbox version together so people can have a play!
#15
I have now also created a sandbox site where people can have a play and get a better idea for the changes I have made to this module and the extra features which are now available.
Sandbox site can be found at http://sandbox.1kemp.co.uk/
#16
Spotted a little error... New patch attached
#17
First attempt as making the collapsing block gracefully degrade when js not available.
#18
the .html() jQuery command seems to crash IE, so I have had to rewrite it as an .after followed by a .remove which seems to work...
I'll do a fresh patch when I get home.
#19
the .html() jQuery command seems to crash IE, so I have had to rewrite it as an .after followed by a .remove which seems to work...
I'll do a fresh patch when I get home.
#20
Sorry about the double post! Here is the patch which now inlcudes the js files... finally worked out how to use patch properly within turtoiseCVS!
#21
I have done quite a bit of an initial tidyup of the code. I have also attempted to make it compliant with Bibleref Semantic Markup. It is not fully compliant as it doesn't correctly follow this following, as these are embeded within A tags anyway:
The title attribute format specification does not allow discontinuous spans of verses as a single reference. For example, a reference like "2Tim 2:14-19, 3:16-17" should be marked as two references.
I have also changed it so that there is now an option to just display the verse as a link for the ESV, and have got the Translation Regex happy (problem with NIV-UK being read as NIV) so you can enter passages as 1 Tim 2:3 NIV-UK or Romans 12:8 ESV. Because of this change the module now calls the necessary code for collapsible block or tooltip even when the default translation isn't the ESV that way if you add ESV after a quote it will still benefit from the js advantages following the style implied in the settings.
Default setting could be set to display verse as a link to reduce the overhead for those not planning on using the ESV - thoughts??
Would still really like to hear someone elses thoughts on this module? Am I wasting my time or are other people interested?
Cheers
Andy
#22
Okay! I think we are finally finished!
I have added in a couple of new translations NLV from bible gateway and the NRSV and Greek LXX - with a nice flash player which hides itself away in a collapsed div!
I'm sure there are probably still a few bugs in it, and a few bits that could be coded a little neater, but it is now basically finished.
Latest version is running on sandbox site: http://sandbox.1kemp.co.uk and the zip file is there as well.
Attached is a patch file.
Let me know any thoughts/ problems.
Cheers
Andy
#23
Sorry!! Couple of silly typo's now fixed
#24
Some of these features look great. I love it.
I'm going to be on vacation (my honeymoon) and basically out of the loop for the next 3 weeks. When I get back I'll give this a good review of functionality, UI, and a code review. This is great. Keep up the good work.
#25
Thanks, Andy! I have scripturefilter incorporated into our church's website which is set to go live in less than a week. It's working just fine, and it fills a very real need. A couple observations:
Keep up the great work! Thanks again, --Gary
#26
Thanks for the comments!
I'm not sure what happened to the access controls... They were definatly there at one point, I must have deleted them by accident! I'll take another look and add them back in!
With regard to the target="_BLANK", Ithough about this but left it out as this is no longer standards compliant, we could easily add a class id, and then use js to do this if you think it is a worthwhile addition.
The CCK field idea sounds interesting, and I would love to hear your ideas fleshed out as I am not quite certain how it would work.
Thanks again.
Andy
#27
target="_blank" should not be used anymore. There are a lot of us who just don't like this. It's more of a let the user decide thing these days. Right click a link and choose new window or tab if that's what you want.
The compliant thing to do is use javascript to make this happen if you want to force it.
#28
Thanks for the comments.
I have added the option to have links open a new window/tab it uses a js file which is called when that option is selected and then adds the "ref=external" attribute to the link. The JS then adds the target=_blank afterwards...
Follows the system outlined here
Also added back the admin level option.
Any more comments/thoughts?
Patch File and Zip on Sandbox site have both been updated.
Cheers
Andy
#29
Thanks for the updates, Andy. I'll update our scripturefilter with the new code soon. The link you provided was helpful for understanding the issue, as well.
It turns out that the idea of a "scripture reference" CCK field is largely moot--you've already provided it! I just added regular text fields to my "Daily Reading" content type labeled "Reading" and "Key Verse", and then selected Filtered Input rather than plain text. Works great. Probably the additional functionality that would go into a dedicated scripture field-type would have to do with ensuring that the input was a valid Scripture reference (or try to tweak it into one). I couldn't justify the dev time, since scripturefilter meets the need quite well already.
#30
Thanks for the update! I'll give some more thought to the scripturefilter CCK field. It shouldn't be that hard to write a field which validates the field as a scripture passage and then runs it through the input filter. Most of the code should already exist for this within scripture filter...
I would envisage it being an add-on module with CCK and Scripture Filter as dependencies... But I am gladfor now you have found a satisfactory workaround!
Cheers
Andy
#31
John Staffin spotted a little mistake in that references were being prefixed with a space (due to the space between volume and book), which was causing problems...
I have added a trim around the $displaybook variable which fixes this
Patch attached.
#32
Were you ever able to get ahold of Steve Simms about this?
#33
No I emailed him several times and he promised to look at it but I never heard anything else... I got the code to a point where I was happy with it and am using it regularly on my own site. It is just a shame it couldn't have been shared more widely.
I actually wonder now though if it isn't time for a complete rewrite in light of the eBible API which would enable us to do some of the nice things we are currently able to do for the ESV for a much wider range of translations (and I suspect for less work)...
#34
Hi Andy,
Sorry for not ever getting back to you on this. With all of the revisions and added features, it's basically an entirely different module, so I'm not sure how I could go about reviewing it -- I should have mentioned that a lot sooner, rather than letting it stand and hoping I'd get the chance to look at it in depth. That clearly hasn't happened.
If you're still interested in working on this module vs. creating your own as you mentioned elsewhere, could you split this patch up into smaller chunks, with one issue per patch, and create separate issues here for each one? As I mentioned in #221485: Port to 6.0, I'd especially like patches that make the code simpler and easier to maintain, and will probably not approve changes that add a lot of complexity -- that might help in your decision whether to work with this module or create your own.
What do you think?
#35
(I've also just updated all of the other open issues, so you can find some other thoughts there on possible improvements to the module.)
#36
@Andy: What's the status here? Maybe it is time to breakout and create your own module. I like many of the things at http://drupal.org/node/202907 also that have not been added to this module. From the work I see here it looks like you would be a good guy to main a module. Also your sandbox is giving me a 500 error.