Package: transmogrify.siteanalyser
Introductiontransmogrify.siteanalyser.sitemappertransmogrify.siteanalyser.urltidytransmogrify.siteanalyser.attachtransmogrify.siteanalyser.titletransmogrify.siteanalyser.hidefromnavtransmogrify.siteanalyser.defaultpagetransmogrify.siteanalyser.relinkertransmogrify.pathsorterChangelog1.3 (2012-12-28)1.2 (2012-04-28)1.1 (2012-04-18)1.0 (2011-06-29)1.0b8 (2011-02-12)1.0b7 (2011-02-06)1.0b6 (2010-12-15)1.0b5 (2010-12-13)1.0b4 (2010-11-11)1.0b3 (2010-11-09)1.0b2 (2010-11-08)IntroductionTransmogrifier blueprints that look at how html items are linked to gather metadata
about items. They can help you restructure your content.transmogrify.siteanalyser.sitemapperTake navigation html such as a whole sitemap, breadcrumbs or navigation menus using nested links
and buildup a site structure and titles
for pages. This can then be used to cleanup urls and titles for items as well as hide content that shouldn’t be
displayed in menus. This is useful for cleaning up sites with a flat url scheme such ‘display?id=xxx’ type sites.Options:field:Name of a field from item which contains a sitemap or nested linksfield_expr:Expression to determine the field which contains a sitemapbreadcrumb_field:Key of the field which contains breadcrumb style html. e.g. <a href=”..”>Folder</a> &gt; Item.folder-type:If set will ensure all parents in sitemap are of this Type, moving item to defaultpage if neededexclude-from-navigation-key:Will set this key to ‘True’ if this item is not found in the sitemap. Defaults to ‘exclude-from-navigation’title-key:Update this field with the title taken from the sitemap if no title already existspath_sub:Newline seperated regular expressions and substitions to adjust paths so change where content is moved tocondition:TAL expression which if false, don’t move this itemtransmogrify.siteanalyser.urltidyWill  normalize ids in urls to be suitable for adding to plone.The following will tidy up the URLs based on a TALES expression$> bin/funnelweb --urltidy:link_expr="python:item['_path'].endswith('.html') and item['_path'][:-5] or item['_path']"If you’d like to move content around before it’s uploaded you can use the urltidy step as well e.g.$> bin/funnelweb --urltidy:link_expr=python:item['_path'].startswith('/news') and '/otn/news'+item['path'][5:] or item['_path']Options:condition:TAL Expression to apply transformlocale:TAL Expression to return the locale used for id normalisation. e.g. ‘string:en’link_expr:TAL Expression to alter the items ‘_path’use_title:Condition TAL Expression to change the end path element to a normalised version of item[‘_title’]transmogrify.siteanalyser.attachFind items and move them if they are tightly linked to a single page. For example if an image
is located in an images folder, but is only referenced from a single img element on a page in
/page then the image will be ‘merged’ with the page.
How the merge occurs depends on the ‘fields’ setting. Merging can either be moving the content
of the subitem into a field of the parent item, or it can be via containment.or the following will only move attachments that are images and useindex-htmlas the new
name for the default page of the newly created folder[funnelweb]
recipe = funnelweb
attachmentguess-condition = python: subitem.get('_type') in ['Image']
attachmentguess-defaultpage = index-htmlOptionsfields:TAL Expression to return the a dictionary of changes toitem. It will useitem,subitemandivariables.
e.g. python:{‘attachment’:subitem[‘text’]}. This will be called for all subitems. The subitems will be deleted.condition:TAL Expression to apply transform
(default=’python:True’)defaultpage:(default=’index-html’)transmogrify.siteanalyser.titleThis blueprint will take the _backlinks from the item generated by webcrawler
and if no Title field has been given to the item it will attempt to guess
it from the link names that linked to this document.
You can specify an option ‘ignore’ option to specify titles never to useIf it can’t guess it from the backlinks it will default to using the file name after
cleaning it up somewhatOptions:condition:TAL Expression to apply transformignore:New line seperated list of strings which won’t be use as titles. Defaults to ‘next’,’previous’transmogrify.siteanalyser.hidefromnavThis blueprint will guess which folders should be hidden from the navigation tree.
It does this by one of three rules1. Gather all links in the _template html left over after content extraction
and assume anything linked from outside the content should have their folders shown and
anything else should be hidden. #TODO
2. Any folders with content found only via img links will also be hidden. #TODO
3. The condition to set to tree for the item to hideOptionskey:Default is ‘_exclude-from-navigation’.condition:Default is ‘python:False’template_key:#TODO
Default is ‘_template’hide_img_folders:#TODO
Default is ‘True’transmogrify.siteanalyser.defaultpageTo determine if an item is a default page for a container (it has many links
to items in that container, even if not contained in that folder), and then move
it to that folder.Options:mode:‘links’ or ‘path’ (default=links).
‘links’ mode uses links
to determine if a item is a defaultpage of a subtree by looking at it’s links.
‘path’ mode uses parent_path expression to
determine if an item is a defaultpage of that parent.min_links:If a page has as at least this number of links that point to content in a folder
then move it there and make it the defaultpage. (default=2)max_uplinks:If a page has more than max_uplinks it won’t be moved. (default=2)parent_path:Rule is defined by entered
parent_path option which is expression with access to item,
transmogrifier, name, options and modules variables.
Returned value is used to find possible parent item by path. If found,
item is moved to that parent item, parent item _defaultpage key is set
appropriately, and we turn to processing another item in a pipeline. So
the first item in pipeline will take precedence in case parent_path rule
returns more than one item for the same parent.condition:default=python:Truetransmogrify.siteanalyser.relinkerHelp restructure your content.
If you’d like to move content from one path to another then in a
previous blueprints adjust the ‘_path’ to the new path. Create a new field
called ‘_origin’ and put the old path into that. Once you pass it through
the relinker all href, img tags etc will be changed in any html content where they
pointed to content that has since moved. All ‘_origin’ fields will be removed
after relinking.Options:ignore_duplicates:If ‘True’ there won’t be an error raised when two items were redirected from the same place. This can occur with
some CMS’s where content can be in different urls in the sitebroken_link_normalise:TAL expressions, each on a new line, which take ‘url’ from inside the html and returns a link that will match one of
the existing links in the site. Must return the full url, not the path. This is useful when many different links
could go to the same content.transmogrify.pathsorterIf items are at the same level in a folder then they will be sorted based on a
‘_sortorder’ key as given by transmogrify.webcrawler.In additionif a container has a ‘text’ key then a default page will be created.if item’s name is in ‘default_pages’ and it’s parent doesn’t already have a defaultpage
then the item will be set as the parents default page.Options:default_pages:Set item as to be set as the default page of it’s parent if it matches one of these names.
Default is ‘index.html’default_containers:if an item doesn’t exist for a given items parent it will be created. The _type key will
be set to the first item in ‘default_containers’. Default is ‘Folder’.Changelog1.3 (2012-12-28)added sitemapper blueprintconverted text to unicode baseNormalize because decomposition needs unicode valute to works properly [gborelli]add ignore_re attribute in Backlinks title for ignore regular expression condition [ivanteoh]add ‘ignore_duplicates’ and ‘broken_link_normalise’ to relinker [djay]added invalid_ids option [ivanteoh]relinker relinks any field which contains ‘<’ and additional specififed fields [djay]cleaned up logging [djay]fixed relinking of defaultpages [djay]titles from backlinks must be unique to be used [djay]1.2 (2012-04-28)moved transmogrify.pathsorter into transmogrify.siteanalyser.pathsorter [djay]1.1 (2012-04-18)added transmogrify.siteanalyser.sitemapper [djay]split transmogrify.siteanalyser.urltidy out of relinker [djay]ensure urltidy always create unique urls [djay]Added ability to take id from title to urltidy [djay]improved logging [djay]fixed bug in attach where two items can end up with same path [djay]1.0 (2011-06-29)1.0 release1.0b8 (2011-02-12)more robust parsing of html1.0b7 (2011-02-06)show error if text is Nonefix bug with bad chars in rewritten linksfix bug in losing itemsadd hidefromnav blueprint. does manual hiding1.0b6 (2010-12-15)remove nulls from links which cause lxml errorssummarise info in log to single entry1.0b5 (2010-12-13)condition was in the wrong place. resulted in dropping itemsimprove logginghandle default pages that don’t exist1.0b4 (2010-11-11)fix bug where _defaultpage wasn’t being relinked1.0b3 (2010-11-09)fix bug in quoting links in relinker1.0b2 (2010-11-08)Add conditions to site analyser blueprints