For the 2nd time I'm building a site where not all the content is going to be manually imported into Drupal (in these cases, it can't really be automated). So, at least for a while, there's going to be a directory tree in the webroot serving the old static content. I wanted these files in the XML sitemap, and instead of doing it one-off again, I decided to write a simple reusable API for this and wrap it in a drush command.

Are you willing to include this as part of xmlsitemap_custom or should I put this in a separate project? Seems generally useful for folks who need xmlsitemap_custom. This could be expanded to include an admin UI, for now a drush command is all I need.

Thoughts?

Thanks!
-Derek

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dww’s picture

Status: Active » Needs review
FileSize
5.02 KB
dww’s picture

Should be obvious from the patch, but if not -- this makes use of the 'subtype' field in {xmlsitemap} to keep track of all the links in a given directory tree. E.g. in my case, I'm invoking this like so:

drush xmlsitemap-custom-scan issues '/\.shtml/'

And ending up with this sort of thing in {xmlsitemap}:

mysql> SELECT id, subtype, loc FROM xmlsitemap WHERE type = 'custom' LIMIT 10;
+----+---------+-----------------------------------+
| id | subtype | loc                               |
+----+---------+-----------------------------------+
| 47 | issues  | issues/59/59.shtml                |
| 48 | issues  | issues/59/editorletter.shtml      |
| 49 | issues  | issues/59/feat-egyptstrikes.shtml |
| 50 | issues  | issues/59/feat-engels.shtml       |
| 51 | issues  | issues/59/feat-food.shtml         |
| 52 | issues  | issues/59/feat-geier.shtml        |
| 53 | issues  | issues/59/feat-iraq.shtml         |
| 54 | issues  | issues/59/feat-lenin.shtml        |
| 55 | issues  | issues/59/feat-shiva.shtml        |
| 56 | issues  | issues/59/feat-tibet.shtml        |
+----+---------+-----------------------------------+
10 rows in set (0.00 sec)

Once the editors import issue #59, we'll remove those files from the filesystem, run the scan again, and those links will disappear from the sitemap (and there will be redirects from the legacy path pointing to the happy new Drupal nodes).

Make sense?

Cheers,
-Derek

Chris Matthews’s picture

Assigned: dww » Unassigned
Issue summary: View changes

The 6 year old patch to xmlsitemap_custom.drush.inc and xmlsitemap_custom.scan.inc applied cleanly to the latest xmlsitemap 7.x-2.x-dev and if still applicable needs review.

Applied patch xmlsitemap_custom/xmlsitemap_custom.drush.inc cleanly.
Applied patch xmlsitemap_custom/xmlsitemap_custom.scan.inc cleanly.
pifagor’s picture

Status: Needs review » Reviewed & tested by the community

  • pifagor committed a50c2df on 7.x-2.x authored by dww
    Issue #2026551 by dww, Chris Matthews, pifagor: Add an API and drush...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed
Dave Reid’s picture

Priority: Normal » Major
Status: Fixed » Needs work

The xml_custom_scan_directories() function is not properly namespaced. It should be xmlsitemap_custom_scan_directories()?

pifagor’s picture

Status: Needs work » Needs review
FileSize
1.43 KB

Dear Dave.
I absolutely agree with you. This is a logical remark. I added a patch where I changed the function name.
Thank you for your comments

ciss’s picture

@pifagor Your namespace corrections to xml_custom_scan_directories() in #8 still need to be committed.

ciss’s picture

Status: Needs review » Reviewed & tested by the community
alex_optim’s picture

Looks good.

  • pifagor committed c23b9c7 on 7.x-2.x
    Issue #2026551 by dww, pifagor, ciss, Chris Matthews, alex_optim, Dave...
pifagor’s picture

pifagor’s picture

Status: Reviewed & tested by the community » Fixed
pifagor’s picture

Priority: Major » Normal

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.