Code is in place, for a demonstration I moved the node pieces out to their respective files.

The dynamic parts can't be moved but most help can.

For admin/help#node the name of the help file is admin_help.node.help , slash is replaced by underscore, fragment by the dot.

Modifying extractor.php to support the new code is left as an exercise to the reader :)

CommentFileSizeAuthor
#11 help_5.patch7.01 KBchx
#2 help_4.patch.txt7.73 KBAnonymous (not verified)
help_4.patch7.72 KBchx

Comments

gábor hojtsy’s picture

*The reader* here :) Updating extractor.php to support this seems to be quite simple.

Anonymous’s picture

StatusFileSize
new7.73 KB

patch that fixes typo in drupal_get_help() attached.

adrian’s picture

awesome plan.

i wonder if there is any use in making the help files overridable with help files in the active theme dir

Bèr Kessels’s picture

+  $help_filename = drupal_get_path('module', $module) .'/'. str_replace('/', '_', $path) . "$fragment.help";
+  if (is_file($help_filename)) {
+    return t(file_get_contents($help_filename), $help ? $help : array());
+  }

Could be replaced by far less code using glob (why we don't use glob in Drupal on other places has wondered me for ages). That way you can have an array of all available help-files ready, and you don't need to hit the filesystem twenty times on each load. Hittin the FS is notvery heavy, true. But the Files are locked-read-released, meaning that when hundred people load a Drupal page simultanously, the PHP for user 100 has to wait for 2000 (20 files, 100times) before it can proceed.

Bèr

chx’s picture

pardon? we do not lock the files, reading a file does not read lock it at, you can't write it, sure but read???

moshe weitzman’s picture

as long as it is fast enough, this seems like a good direction. my understanding is that the phptemplate patch is a bit slower because of this same reason (more files), so it would be nice to address that and then get both patches in :)

boris mann’s picture

Hmmm. While I think it is awesome to have the help text pulled out of the code where it definitely can't easily be edited....is it appropriate to include web-based editing as part of this effort?

If this is not deemed possible/necessary for core, then this should be done as a contrib (i.e. the deprecated helpedit module). WebCMS with static HTML?

Gary Feldman’s picture

If this goes forward, then I suggest wrapping the HTML source to fit a narrower width. Sure, it doesn't matter when the text is displayed by a browser doing its own wrapping. The problem is looking at patch files or diffs, when the lines can be huge and aren't wrapped. That just makes it unnecessarily hard to find small changes (e.g. a simply transposition typo) in a long line, which slows down proofreading of sources.
It also makes the patch larger than it needs to be, which is also annoying for proofreading purposes.

A corollary is that many HTML editors need to be avoided, because different such editors do their own reformatting of the source. Again, this wouldn't affect the resultant display, but would totally break the diff/patch mechanism (unless there's agreement on a single such editor). Personally, I use emacs with fill turned on for .html files, but even that could cause unnecessary reformatting.

Gary Feldman’s picture

A different question: How does this interact with localization? It's certainly easier to translate text when it's in a separate HTML file, but there needs to be a mechanism for picking out the correct file depending upon a user's language choice.

gábor hojtsy’s picture

Gary, this patch changes nothing in localization. The localization would still continue to be delivered from the database, imported from PO files.

chx’s picture

StatusFileSize
new7.01 KB

For each page, there are (number of modules) calls to drupal_get_help. This can be brought down to one if menu stores the module which defined the callback, because it's more than likely that the same module provides help that provides the callback.

gábor hojtsy’s picture

@Chx, I utilize the possibility of adding more help to some pages heavily. So I can add additional instructions without core hacking. This is a feature. Please do not try to remove it.

dww’s picture

subscribing. more later when i have a chance to actually look at the patches here. ;) i'm certainly in favor of the general thrust, even if the details are still slightly murky.

drumm’s picture

Version: x.y.z » 6.x-dev
keith.smith’s picture

Status: Needs review » Needs work

:( patch no longer applies. (and i really like this idea too, btw)

# patch -p0 < help_5.patch
patching file includes/common.inc
Hunk #1 succeeded at 2309 (offset 902 lines).
patching file includes/menu.inc
Hunk #1 FAILED at 502.
Hunk #2 succeeded at 1021 with fuzz 2 (offset -4 lines).
Hunk #3 FAILED at 1053.
Hunk #4 FAILED at 1218.
3 out of 4 hunks FAILED -- saving rejects to file includes/menu.inc.rej
patching file modules/help/help.module
Hunk #1 FAILED at 120.
1 out of 1 hunk FAILED -- saving rejects to file modules/help/help.module.rej
patching file modules/node/node.module
Hunk #1 FAILED at 14.
1 out of 1 hunk FAILED -- saving rejects to file modules/node/node.module.rej
[root@h99846 test]#

pancho’s picture

Version: 6.x-dev » 7.x-dev

Good idea, but needs to be moved to D7.

pasqualle’s picture

Status: Needs work » Closed (duplicate)