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:patch (code 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

AttachmentSize
scripturefilter.module.txt14.21 KB

#1

andykemp - June 6, 2007 - 22:30
Title:Updateing Scripture Filter to take advantage of the ESV API» And the INC File
AttachmentSize
scripturefilter.inc_.txt10.63 KB

#2

andykemp - June 6, 2007 - 22:31
Title:And the INC File» And the First JS File
AttachmentSize
esv_tooltip.js_.txt4.75 KB

#3

andykemp - June 6, 2007 - 22:32
Title:And the First JS File» And the Second JS File
AttachmentSize
esv_showhide.js_.txt718 bytes

#4

andykemp - June 6, 2007 - 22:34
Title:And the Second JS File» And the CSS File

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

andykemp - June 7, 2007 - 07:10
Title:And the CSS File» Updateing Scripture Filter to take advantage of the ESV API

Sorry didn't notice that changing the title for the comment would change the whole title... Still learning!

#6

andykemp - June 7, 2007 - 11:04
Title:Updateing Scripture Filter to take advantage of the ESV API» Updating Scripture Filter to take advantage of the ESV API

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.

AttachmentSize
scripturefilter.module.v2.txt0 bytes

#7

andykemp - June 7, 2007 - 11:05

File didn't upload...

AttachmentSize
scripturefilter.module.v2_0.txt14.28 KB

#8

andykemp - June 7, 2007 - 11:05

And the inc file

AttachmentSize
scripturefilter.inc_.v2.txt10.73 KB

#9

andykemp - June 7, 2007 - 11:44

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

andykemp - June 7, 2007 - 15:46

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

andykemp - June 7, 2007 - 17:33

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

andykemp - June 7, 2007 - 19:47

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

andykemp - June 11, 2007 - 13:29

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

andykemp - June 17, 2007 - 18:43

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!

AttachmentSize
scripturefilter.patch40.34 KB

#15

andykemp - June 17, 2007 - 21:49

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

andykemp - June 18, 2007 - 07:07

Spotted a little error... New patch attached

AttachmentSize
scripturefilter_0.patch40.2 KB

#17

andykemp - June 22, 2007 - 06:57

First attempt as making the collapsing block gracefully degrade when js not available.

AttachmentSize
scripturefilter_1.patch41.3 KB

#18

andykemp - June 22, 2007 - 10:49

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

andykemp - June 22, 2007 - 13:03

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

andykemp - June 22, 2007 - 16:32

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!

AttachmentSize
scripturefilter_2.patch46.83 KB

#21

andykemp - June 22, 2007 - 22:15

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

AttachmentSize
scripturefilter_3.patch44.19 KB

#22

andykemp - June 24, 2007 - 14:39

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

AttachmentSize
scripturefilter_4.patch56.44 KB

#23

andykemp - June 24, 2007 - 17:19

Sorry!! Couple of silly typo's now fixed

AttachmentSize
scripturefilter_5.patch56.45 KB

#24

mfer - June 25, 2007 - 13:27

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

gwhit - July 2, 2007 - 02:24

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:

  • the module doesn't show up in the 'Access control' listing; as a result, only 'user one' can administer the Scripture Filter options, since you can't give rights to any other user (such as the administrator role we have).
  • I added an crude hack on line 150 in scripturefilter.inc, adding 'target="_blank"' to the href so that links to Bible Gateway would open in a new window or tab rather than hijacking the drupal window. It would be nice to have a checkbox option to enable this behavior in the admin area. ( I'd be glad to try to implement this if you'd like--but only AFTER we have our site up and live!)
  • My original thought--before I ran across your discussion with Matt on the Geeks & God site--was to try to implement a CCK field that accepted a scripture reference and filtered it very much like this module does. My thought was that it might be useful to have the reference available as a field, allowing it's use in Views, etc. with more options for placement and theming... What do you think?

Keep up the great work! Thanks again, --Gary

#26

andykemp - July 3, 2007 - 17:37

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

mfer - July 10, 2007 - 22:23

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

andykemp - July 12, 2007 - 15:16

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

AttachmentSize
scripturefilter_6.patch58.48 KB

#29

gwhit - July 17, 2007 - 03:13

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

andykemp - July 17, 2007 - 09:16

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

andykemp - July 25, 2007 - 11:12

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.

AttachmentSize
scripturefilter_7.patch58.48 KB

#32

mfer - December 6, 2007 - 12:41

Were you ever able to get ahold of Steve Simms about this?

#33

andykemp - February 14, 2008 - 11:43

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

Steve Simms - February 19, 2008 - 02:04

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

Steve Simms - February 19, 2008 - 02:05

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

 
 

Drupal is a registered trademark of Dries Buytaert.