webgen 0.3.8 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +2565 -14
- data/README +4 -6
- data/Rakefile +207 -89
- data/TODO +175 -17
- data/VERSION +1 -1
- data/bin/webgen +1 -2
- data/data/webgen/gallery-creator/default.png +0 -0
- data/data/webgen/gallery_styles/default/README +6 -0
- data/data/webgen/gallery_styles/default/gallery_gallery.template +38 -0
- data/data/webgen/gallery_styles/default/gallery_image.template +30 -0
- data/data/webgen/gallery_styles/default/gallery_main.template +18 -0
- data/data/webgen/gallery_styles/slides/README +18 -0
- data/data/webgen/gallery_styles/slides/collage.rb +334 -0
- data/data/webgen/gallery_styles/slides/gallery_gallery.template +62 -0
- data/data/webgen/gallery_styles/slides/gallery_image.template +53 -0
- data/data/webgen/gallery_styles/slides/gallery_main.template +32 -0
- data/data/webgen/resources/images/generated_by_webgen.png +0 -0
- data/data/webgen/resources/images/webgen_logo.png +0 -0
- data/data/webgen/website_styles/1024px/README +10 -0
- data/data/webgen/website_styles/1024px/default.css +188 -0
- data/data/webgen/website_styles/1024px/default.template +62 -0
- data/data/webgen/website_styles/1024px/images/background.gif +0 -0
- data/data/webgen/website_styles/andreas00/README +10 -0
- data/data/webgen/website_styles/andreas00/default.css +290 -0
- data/data/webgen/website_styles/andreas00/default.template +62 -0
- data/data/webgen/website_styles/andreas00/images/bg.gif +0 -0
- data/data/webgen/website_styles/andreas00/images/front.jpg +0 -0
- data/data/webgen/website_styles/andreas00/images/menubg.gif +0 -0
- data/data/webgen/website_styles/andreas00/images/menubg2.gif +0 -0
- data/data/webgen/website_styles/andreas01/README +11 -0
- data/data/webgen/website_styles/andreas01/default.css +310 -0
- data/data/webgen/website_styles/andreas01/default.template +63 -0
- data/data/webgen/website_styles/andreas01/images/bg.gif +0 -0
- data/data/webgen/website_styles/andreas01/images/front.jpg +0 -0
- data/data/webgen/website_styles/andreas01/print.css +35 -0
- data/data/webgen/website_styles/andreas03/README +11 -0
- data/data/webgen/website_styles/andreas03/default.css +223 -0
- data/data/webgen/website_styles/andreas03/default.template +60 -0
- data/data/webgen/website_styles/andreas03/images/bodybg.png +0 -0
- data/data/webgen/website_styles/andreas03/images/contbg.png +0 -0
- data/data/webgen/website_styles/andreas03/images/footerbg.png +0 -0
- data/data/webgen/website_styles/andreas03/images/gradient1.png +0 -0
- data/data/webgen/website_styles/andreas03/images/gradient2.png +0 -0
- data/data/webgen/website_styles/andreas04/README +12 -0
- data/data/webgen/website_styles/andreas04/default.css +290 -0
- data/data/webgen/website_styles/andreas04/default.template +83 -0
- data/data/webgen/website_styles/andreas04/images/blinkarrow.gif +0 -0
- data/data/webgen/website_styles/andreas04/images/bodybg.png +0 -0
- data/data/webgen/website_styles/andreas04/images/contentbg.png +0 -0
- data/data/webgen/website_styles/andreas04/images/entrybg.png +0 -0
- data/data/webgen/website_styles/andreas04/images/flash.gif +0 -0
- data/data/webgen/website_styles/andreas04/images/flash2.gif +0 -0
- data/data/webgen/website_styles/andreas04/images/globe.gif +0 -0
- data/data/webgen/website_styles/andreas04/images/globebottom.gif +0 -0
- data/data/webgen/website_styles/andreas04/images/linkarrow.gif +0 -0
- data/data/webgen/website_styles/andreas04/images/menuhover.png +0 -0
- data/data/webgen/website_styles/andreas05/README +11 -0
- data/data/webgen/website_styles/andreas05/default.css +33 -0
- data/data/webgen/website_styles/andreas05/default.template +42 -0
- data/data/webgen/website_styles/andreas05/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas05/images/front.png +0 -0
- data/data/webgen/website_styles/andreas06/README +11 -0
- data/data/webgen/website_styles/andreas06/default.css +353 -0
- data/data/webgen/website_styles/andreas06/default.template +72 -0
- data/data/webgen/website_styles/andreas06/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas06/images/boxbg.gif +0 -0
- data/data/webgen/website_styles/andreas06/images/greypx.gif +0 -0
- data/data/webgen/website_styles/andreas06/images/header.jpg +0 -0
- data/data/webgen/website_styles/andreas06/images/innerbg.gif +0 -0
- data/data/webgen/website_styles/andreas06/images/leaves.jpg +0 -0
- data/data/webgen/website_styles/andreas06/images/tabs.gif +0 -0
- data/data/webgen/website_styles/andreas07/README +12 -0
- data/data/webgen/website_styles/andreas07/browserfix.css +7 -0
- data/data/webgen/website_styles/andreas07/default.css +92 -0
- data/data/webgen/website_styles/andreas07/default.template +44 -0
- data/data/webgen/website_styles/andreas07/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas07/images/sidebarbg.gif +0 -0
- data/data/webgen/website_styles/andreas08/README +11 -0
- data/data/webgen/website_styles/andreas08/default.css +224 -0
- data/data/webgen/website_styles/andreas08/default.template +53 -0
- data/data/webgen/website_styles/andreas09/README +11 -0
- data/data/webgen/website_styles/andreas09/default.css +308 -0
- data/data/webgen/website_styles/andreas09/default.template +70 -0
- data/data/webgen/website_styles/andreas09/images/bodybg-black.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/bodybg-green.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/bodybg-orange.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/bodybg-purple.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/bodybg-red.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/bodybg.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/footerbg.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/menuhover-black.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/menuhover-green.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/menuhover-orange.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/menuhover-purple.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/menuhover-red.jpg +0 -0
- data/data/webgen/website_styles/andreas09/images/menuhover.jpg +0 -0
- data/data/webgen/website_styles/default/README +6 -0
- data/data/webgen/website_styles/default/default.css +1 -1
- data/data/webgen/website_styles/default/default.template +9 -3
- data/data/webgen/website_styles/plain/README +12 -0
- data/data/webgen/website_styles/plain/default.css +244 -0
- data/data/webgen/website_styles/plain/default.template +63 -0
- data/data/webgen/website_styles/plain/images/a_hover.jpg +0 -0
- data/data/webgen/website_styles/plain/images/desc.jpg +0 -0
- data/data/webgen/website_styles/plain/images/li.gif +0 -0
- data/data/webgen/website_styles/plain/images/mainbar.jpg +0 -0
- data/data/webgen/website_styles/plain/images/menu.jpg +0 -0
- data/data/webgen/website_styles/plain/images/submenua.gif +0 -0
- data/data/webgen/website_styles/plain/images/submenua_hover.jpg +0 -0
- data/data/webgen/website_templates/default/README +7 -5
- data/data/webgen/website_templates/personal_hp/README +7 -5
- data/data/webgen/website_templates/project/README +8 -6
- data/doc/config.yaml +2 -2
- data/doc/examples/website_styles/1024px/README +9 -0
- data/doc/examples/website_styles/1024px/config.yaml +2 -0
- data/doc/examples/website_styles/1024px/src/about.page +12 -0
- data/doc/examples/website_styles/1024px/src/default.css +188 -0
- data/doc/examples/website_styles/1024px/src/default.template +62 -0
- data/doc/examples/website_styles/1024px/src/download.page +15 -0
- data/doc/examples/website_styles/1024px/src/features.page +8 -0
- data/doc/examples/website_styles/1024px/src/images/background.gif +0 -0
- data/doc/examples/website_styles/1024px/src/index.page +9 -0
- data/doc/examples/website_styles/1024px/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas00/README +9 -0
- data/doc/examples/website_styles/andreas00/config.yaml +2 -0
- data/doc/examples/website_styles/andreas00/src/about.page +12 -0
- data/doc/examples/website_styles/andreas00/src/default.css +290 -0
- data/doc/examples/website_styles/andreas00/src/default.template +62 -0
- data/doc/examples/website_styles/andreas00/src/download.page +15 -0
- data/doc/examples/website_styles/andreas00/src/features.page +8 -0
- data/doc/examples/website_styles/andreas00/src/images/bg.gif +0 -0
- data/doc/examples/website_styles/andreas00/src/images/front.jpg +0 -0
- data/doc/examples/website_styles/andreas00/src/images/menubg.gif +0 -0
- data/doc/examples/website_styles/andreas00/src/images/menubg2.gif +0 -0
- data/doc/examples/website_styles/andreas00/src/index.page +9 -0
- data/doc/examples/website_styles/andreas00/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas01/README +9 -0
- data/doc/examples/website_styles/andreas01/config.yaml +2 -0
- data/doc/examples/website_styles/andreas01/src/about.page +12 -0
- data/doc/examples/website_styles/andreas01/src/default.css +310 -0
- data/doc/examples/website_styles/andreas01/src/default.template +63 -0
- data/doc/examples/website_styles/andreas01/src/download.page +15 -0
- data/doc/examples/website_styles/andreas01/src/features.page +8 -0
- data/doc/examples/website_styles/andreas01/src/images/bg.gif +0 -0
- data/doc/examples/website_styles/andreas01/src/images/front.jpg +0 -0
- data/doc/examples/website_styles/andreas01/src/index.page +9 -0
- data/doc/examples/website_styles/andreas01/src/print.css +35 -0
- data/doc/examples/website_styles/andreas01/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas03/README +9 -0
- data/doc/examples/website_styles/andreas03/config.yaml +2 -0
- data/doc/examples/website_styles/andreas03/src/about.page +12 -0
- data/doc/examples/website_styles/andreas03/src/default.css +223 -0
- data/doc/examples/website_styles/andreas03/src/default.template +60 -0
- data/doc/examples/website_styles/andreas03/src/download.page +15 -0
- data/doc/examples/website_styles/andreas03/src/features.page +8 -0
- data/doc/examples/website_styles/andreas03/src/images/bodybg.png +0 -0
- data/doc/examples/website_styles/andreas03/src/images/contbg.png +0 -0
- data/doc/examples/website_styles/andreas03/src/images/footerbg.png +0 -0
- data/doc/examples/website_styles/andreas03/src/images/gradient1.png +0 -0
- data/doc/examples/website_styles/andreas03/src/images/gradient2.png +0 -0
- data/doc/examples/website_styles/andreas03/src/index.page +9 -0
- data/doc/examples/website_styles/andreas03/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas04/README +9 -0
- data/doc/examples/website_styles/andreas04/config.yaml +2 -0
- data/doc/examples/website_styles/andreas04/src/about.page +12 -0
- data/doc/examples/website_styles/andreas04/src/default.css +290 -0
- data/doc/examples/website_styles/andreas04/src/default.template +83 -0
- data/doc/examples/website_styles/andreas04/src/download.page +15 -0
- data/doc/examples/website_styles/andreas04/src/features.page +8 -0
- data/doc/examples/website_styles/andreas04/src/images/blinkarrow.gif +0 -0
- data/doc/examples/website_styles/andreas04/src/images/bodybg.png +0 -0
- data/doc/examples/website_styles/andreas04/src/images/contentbg.png +0 -0
- data/doc/examples/website_styles/andreas04/src/images/entrybg.png +0 -0
- data/doc/examples/website_styles/andreas04/src/images/flash.gif +0 -0
- data/doc/examples/website_styles/andreas04/src/images/flash2.gif +0 -0
- data/doc/examples/website_styles/andreas04/src/images/globe.gif +0 -0
- data/doc/examples/website_styles/andreas04/src/images/globebottom.gif +0 -0
- data/doc/examples/website_styles/andreas04/src/images/linkarrow.gif +0 -0
- data/doc/examples/website_styles/andreas04/src/images/menuhover.png +0 -0
- data/doc/examples/website_styles/andreas04/src/index.page +9 -0
- data/doc/examples/website_styles/andreas04/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas05/README +9 -0
- data/doc/examples/website_styles/andreas05/config.yaml +2 -0
- data/doc/examples/website_styles/andreas05/src/about.page +12 -0
- data/doc/examples/website_styles/andreas05/src/default.css +33 -0
- data/doc/examples/website_styles/andreas05/src/default.template +42 -0
- data/doc/examples/website_styles/andreas05/src/download.page +15 -0
- data/doc/examples/website_styles/andreas05/src/features.page +8 -0
- data/doc/examples/website_styles/andreas05/src/images/bodybg.gif +0 -0
- data/doc/examples/website_styles/andreas05/src/images/front.png +0 -0
- data/doc/examples/website_styles/andreas05/src/index.page +9 -0
- data/doc/examples/website_styles/andreas05/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas06/README +9 -0
- data/doc/examples/website_styles/andreas06/config.yaml +2 -0
- data/doc/examples/website_styles/andreas06/src/about.page +12 -0
- data/doc/examples/website_styles/andreas06/src/default.css +353 -0
- data/doc/examples/website_styles/andreas06/src/default.template +72 -0
- data/doc/examples/website_styles/andreas06/src/download.page +15 -0
- data/doc/examples/website_styles/andreas06/src/features.page +8 -0
- data/doc/examples/website_styles/andreas06/src/images/bodybg.gif +0 -0
- data/doc/examples/website_styles/andreas06/src/images/boxbg.gif +0 -0
- data/doc/examples/website_styles/andreas06/src/images/greypx.gif +0 -0
- data/doc/examples/website_styles/andreas06/src/images/header.jpg +0 -0
- data/doc/examples/website_styles/andreas06/src/images/innerbg.gif +0 -0
- data/doc/examples/website_styles/andreas06/src/images/leaves.jpg +0 -0
- data/doc/examples/website_styles/andreas06/src/images/tabs.gif +0 -0
- data/doc/examples/website_styles/andreas06/src/index.page +9 -0
- data/doc/examples/website_styles/andreas06/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas07/README +9 -0
- data/doc/examples/website_styles/andreas07/config.yaml +2 -0
- data/doc/examples/website_styles/andreas07/src/about.page +12 -0
- data/doc/examples/website_styles/andreas07/src/browserfix.css +7 -0
- data/doc/examples/website_styles/andreas07/src/default.css +92 -0
- data/doc/examples/website_styles/andreas07/src/default.template +44 -0
- data/doc/examples/website_styles/andreas07/src/download.page +15 -0
- data/doc/examples/website_styles/andreas07/src/features.page +8 -0
- data/doc/examples/website_styles/andreas07/src/images/bodybg.gif +0 -0
- data/doc/examples/website_styles/andreas07/src/images/sidebarbg.gif +0 -0
- data/doc/examples/website_styles/andreas07/src/index.page +9 -0
- data/doc/examples/website_styles/andreas07/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas08/README +9 -0
- data/doc/examples/website_styles/andreas08/config.yaml +2 -0
- data/doc/examples/website_styles/andreas08/src/about.page +12 -0
- data/doc/examples/website_styles/andreas08/src/default.css +224 -0
- data/doc/examples/website_styles/andreas08/src/default.template +53 -0
- data/doc/examples/website_styles/andreas08/src/download.page +15 -0
- data/doc/examples/website_styles/andreas08/src/features.page +8 -0
- data/doc/examples/website_styles/andreas08/src/index.page +9 -0
- data/doc/examples/website_styles/andreas08/src/screenshots.page +18 -0
- data/doc/examples/website_styles/andreas09/README +9 -0
- data/doc/examples/website_styles/andreas09/config.yaml +2 -0
- data/doc/examples/website_styles/andreas09/src/about.page +12 -0
- data/doc/examples/website_styles/andreas09/src/default.css +308 -0
- data/doc/examples/website_styles/andreas09/src/default.template +70 -0
- data/doc/examples/website_styles/andreas09/src/download.page +15 -0
- data/doc/examples/website_styles/andreas09/src/features.page +8 -0
- data/doc/examples/website_styles/andreas09/src/images/bodybg-black.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/bodybg-green.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/bodybg-orange.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/bodybg-purple.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/bodybg-red.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/bodybg.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/footerbg.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/menuhover-black.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/menuhover-green.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/menuhover-orange.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/menuhover-purple.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/menuhover-red.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/images/menuhover.jpg +0 -0
- data/doc/examples/website_styles/andreas09/src/index.page +9 -0
- data/doc/examples/website_styles/andreas09/src/screenshots.page +18 -0
- data/doc/examples/website_styles/default/README +9 -0
- data/doc/examples/website_styles/default/config.yaml +2 -0
- data/doc/examples/website_styles/default/src/about.page +12 -0
- data/doc/examples/website_styles/default/src/default.css +84 -0
- data/doc/examples/website_styles/default/src/default.template +38 -0
- data/doc/examples/website_styles/default/src/download.page +15 -0
- data/doc/examples/website_styles/default/src/features.page +8 -0
- data/doc/examples/website_styles/default/src/index.page +9 -0
- data/doc/examples/website_styles/default/src/screenshots.page +18 -0
- data/doc/examples/website_styles/plain/README +9 -0
- data/doc/examples/website_styles/plain/config.yaml +2 -0
- data/doc/examples/website_styles/plain/src/about.page +12 -0
- data/doc/examples/website_styles/plain/src/default.css +244 -0
- data/doc/examples/website_styles/plain/src/default.template +63 -0
- data/doc/examples/website_styles/plain/src/download.page +15 -0
- data/doc/examples/website_styles/plain/src/features.page +8 -0
- data/doc/examples/website_styles/plain/src/images/a_hover.jpg +0 -0
- data/doc/examples/website_styles/plain/src/images/desc.jpg +0 -0
- data/doc/examples/website_styles/plain/src/images/li.gif +0 -0
- data/doc/examples/website_styles/plain/src/images/mainbar.jpg +0 -0
- data/doc/examples/website_styles/plain/src/images/menu.jpg +0 -0
- data/doc/examples/website_styles/plain/src/images/submenua.gif +0 -0
- data/doc/examples/website_styles/plain/src/images/submenua_hover.jpg +0 -0
- data/doc/examples/website_styles/plain/src/index.page +9 -0
- data/doc/examples/website_styles/plain/src/screenshots.page +18 -0
- data/doc/examples/website_templates/default/README +8 -0
- data/doc/examples/website_templates/default/config.yaml +2 -0
- data/doc/examples/website_templates/default/src/default.css +84 -0
- data/doc/examples/website_templates/default/src/default.template +38 -0
- data/doc/examples/website_templates/default/src/index.page +8 -0
- data/doc/examples/website_templates/personal_hp/README +8 -0
- data/doc/examples/website_templates/personal_hp/config.yaml +2 -0
- data/doc/examples/website_templates/personal_hp/src/about.page +12 -0
- data/doc/examples/website_templates/personal_hp/src/default.css +84 -0
- data/doc/examples/website_templates/personal_hp/src/default.template +38 -0
- data/doc/examples/website_templates/personal_hp/src/index.page +9 -0
- data/doc/examples/website_templates/personal_hp/src/links.page +22 -0
- data/doc/examples/website_templates/personal_hp/src/projects.page +20 -0
- data/doc/examples/website_templates/project/README +9 -0
- data/doc/examples/website_templates/project/config.yaml +2 -0
- data/doc/examples/website_templates/project/src/about.page +12 -0
- data/doc/examples/website_templates/project/src/default.css +84 -0
- data/doc/examples/website_templates/project/src/default.template +38 -0
- data/doc/examples/website_templates/project/src/download.page +15 -0
- data/doc/examples/website_templates/project/src/features.page +8 -0
- data/doc/examples/website_templates/project/src/index.page +9 -0
- data/doc/examples/website_templates/project/src/screenshots.page +18 -0
- data/doc/metainfo.yaml +85 -0
- data/doc/plugin/emoticon.rb +19 -21
- data/doc/plugin/extension.rb +134 -55
- data/doc/plugin/gallery/slides/collage.rb +334 -0
- data/doc/plugin/listpluginparameters.rb +24 -26
- data/doc/plugin/resources.rb +20 -22
- data/doc/src/default.css +333 -154
- data/doc/src/default.template +92 -39
- data/doc/src/documentation/extending_webgen.page +1 -2
- data/doc/src/documentation/gettingstarted.page +161 -44
- data/doc/src/documentation/index.page +15 -28
- data/doc/src/documentation/plugins/contentconverter/default.page +15 -0
- data/doc/src/documentation/plugins/contentconverter/html.page +10 -0
- data/doc/src/documentation/plugins/contentconverter/markdown.page +21 -0
- data/doc/src/documentation/plugins/contentconverter/rdoc.page +11 -0
- data/doc/src/documentation/plugins/contentconverter/textile.page +21 -0
- data/doc/src/documentation/plugins/contentconverter/xmlbuilder.page +61 -0
- data/doc/src/documentation/plugins/core/configuration.page +11 -0
- data/doc/src/documentation/plugins/core/filehandler.page +214 -0
- data/doc/src/documentation/plugins/core/index.page +11 -0
- data/doc/src/documentation/plugins/core/resourcemanager.page +46 -0
- data/doc/src/documentation/plugins/core/tagprocessor.page +17 -0
- data/doc/src/documentation/plugins/file/copyhandler.page +26 -0
- data/doc/src/documentation/plugins/file/defaulthandler.page +15 -0
- data/doc/src/documentation/plugins/file/directoryhandler.page +37 -0
- data/doc/src/documentation/plugins/file/galleryhandler.page +181 -0
- data/doc/src/documentation/plugins/file/pagehandler.page +154 -0
- data/doc/src/documentation/plugins/file/templatehandler.page +34 -0
- data/doc/src/documentation/plugins/file/thumbnailwriter.page +39 -0
- data/doc/src/documentation/plugins/htmlvalidator/default.page +12 -0
- data/doc/src/documentation/plugins/htmlvalidator/xmllint.page +12 -0
- data/doc/src/documentation/plugins/index.page +32 -11
- data/doc/src/documentation/plugins/menustyle/default.page +19 -0
- data/doc/src/documentation/plugins/menustyle/horizontal.page +32 -0
- data/doc/src/documentation/plugins/{menustyles → menustyle}/horizontaldropdown.page +25 -19
- data/doc/src/documentation/plugins/menustyle/section.page +34 -0
- data/doc/src/documentation/plugins/menustyle/vertical.page +48 -0
- data/doc/src/documentation/plugins/menustyle/verticaldropdown.page +29 -0
- data/doc/src/documentation/plugins/misc/index.page +9 -0
- data/doc/src/documentation/plugins/{miscplugins → misc}/smileyreplacer.page +15 -14
- data/doc/src/documentation/plugins/misc/syntaxhighlighter.page +26 -0
- data/doc/src/documentation/plugins/tag/block.page +29 -0
- data/doc/src/documentation/plugins/tag/breadcrumbtrail.page +29 -0
- data/doc/src/documentation/plugins/tag/date.page +34 -0
- data/doc/src/documentation/plugins/tag/default.page +27 -0
- data/doc/src/documentation/plugins/tag/download.page +60 -0
- data/doc/src/documentation/plugins/tag/executecommand.page +29 -0
- data/doc/src/documentation/plugins/tag/includefile.page +30 -0
- data/doc/src/documentation/plugins/{tags → tag}/langbar.de.page +1 -1
- data/doc/src/documentation/plugins/tag/langbar.fr.page +6 -0
- data/doc/src/documentation/plugins/tag/langbar.page +41 -0
- data/doc/src/documentation/plugins/tag/menu.page +78 -0
- data/doc/src/documentation/plugins/{tags → tag}/meta.page +8 -7
- data/doc/src/documentation/plugins/tag/relocatable.page +46 -0
- data/doc/src/documentation/plugins/tag/resource.page +35 -0
- data/doc/src/documentation/plugins/tag/sitemap.page +35 -0
- data/doc/src/documentation/plugins/tag/wikilink.page +33 -0
- data/doc/src/documentation/references/index.page +0 -1
- data/doc/src/documentation/references/meta_info_reference.page +90 -13
- data/doc/src/documentation/references/parameter_reference.page +0 -1
- data/doc/src/documentation/references/webpage_format.page +249 -0
- data/doc/src/download.page +50 -21
- data/doc/src/examples/gallery_styles/default/default.gallery +78 -0
- data/doc/src/examples/gallery_styles/default/gallery_gallery.template +38 -0
- data/doc/src/examples/gallery_styles/default/gallery_image.template +30 -0
- data/doc/src/examples/gallery_styles/default/gallery_main.template +18 -0
- data/doc/src/examples/gallery_styles/index.page +22 -0
- data/doc/src/examples/gallery_styles/slides/gallery_gallery.template +62 -0
- data/doc/src/examples/gallery_styles/slides/gallery_image.template +53 -0
- data/doc/src/examples/gallery_styles/slides/gallery_main.template +32 -0
- data/doc/src/examples/gallery_styles/slides/slides.gallery +79 -0
- data/doc/src/examples/images/image01.jpg +0 -0
- data/doc/src/examples/images/image02.jpg +0 -0
- data/doc/src/examples/images/image03.jpg +0 -0
- data/doc/src/examples/images/image04.jpg +0 -0
- data/doc/src/examples/images/image05.jpg +0 -0
- data/doc/src/examples/images/image06.jpg +0 -0
- data/doc/src/examples/images/image07.jpg +0 -0
- data/doc/src/examples/images/image08.jpg +0 -0
- data/doc/src/examples/images/image09.jpg +0 -0
- data/doc/src/examples/images/image10.jpg +0 -0
- data/doc/src/examples/images/image11.jpg +0 -0
- data/doc/src/examples/images/image12.jpg +0 -0
- data/doc/src/examples/images/image13.jpg +0 -0
- data/doc/src/examples/images/image14.jpg +0 -0
- data/doc/src/examples/images/image15.jpg +0 -0
- data/doc/src/examples/images/image16.jpg +0 -0
- data/doc/src/examples/images/image17.jpg +0 -0
- data/doc/src/examples/images/image18.jpg +0 -0
- data/doc/src/examples/index.page +18 -0
- data/doc/src/examples/website_styles/1024px.page +5 -0
- data/doc/src/examples/website_styles/andreas00.page +5 -0
- data/doc/src/examples/website_styles/andreas01.page +5 -0
- data/doc/src/examples/website_styles/andreas03.page +5 -0
- data/doc/src/examples/website_styles/andreas04.page +5 -0
- data/doc/src/examples/website_styles/andreas05.page +5 -0
- data/doc/src/examples/website_styles/andreas06.page +5 -0
- data/doc/src/examples/website_styles/andreas07.page +5 -0
- data/doc/src/examples/website_styles/andreas08.page +5 -0
- data/doc/src/examples/website_styles/andreas09.page +5 -0
- data/doc/src/examples/website_styles/default.page +5 -0
- data/doc/src/examples/website_styles/index.page +71 -0
- data/doc/src/examples/website_styles/plain.page +5 -0
- data/doc/src/examples/website_templates/default.page +5 -0
- data/doc/src/examples/website_templates/index.page +24 -0
- data/doc/src/examples/website_templates/personal_hp.page +5 -0
- data/doc/src/examples/website_templates/project.page +5 -0
- data/doc/src/features.page +16 -14
- data/doc/src/images/bodybg.jpg +0 -0
- data/doc/src/images/footerbg.jpg +0 -0
- data/doc/src/images/menuhover.jpg +0 -0
- data/doc/src/images/node_diagram.svg +7132 -0
- data/doc/src/images/thumb_example.jpg +0 -0
- data/doc/src/images/thumb_example_cropped.jpg +0 -0
- data/doc/src/images/thumb_example_normal.jpg +0 -0
- data/doc/src/index.page +14 -102
- data/doc/src/news.page +154 -0
- data/doc/src/plugin.template +10 -0
- data/lib/webgen/cli.rb +427 -0
- data/lib/webgen/composite.rb +11 -11
- data/lib/webgen/config.rb +52 -0
- data/lib/webgen/content.rb +172 -0
- data/lib/webgen/extcommand.rb +23 -0
- data/lib/webgen/languages.rb +110 -0
- data/lib/webgen/listener.rb +1 -1
- data/lib/webgen/node.rb +196 -124
- data/lib/webgen/plugin.rb +480 -144
- data/lib/webgen/plugins/{contenthandlers → contentconverters}/default.rb +10 -9
- data/lib/webgen/plugins/{contenthandlers → contentconverters}/html.rb +11 -8
- data/lib/webgen/plugins/contentconverters/markdown.rb +54 -0
- data/lib/webgen/plugins/{contenthandlers → contentconverters}/rdoc.rb +16 -12
- data/lib/webgen/plugins/{contenthandlers → contentconverters}/textile.rb +18 -13
- data/lib/webgen/plugins/contentconverters/xmlbuilder.rb +58 -0
- data/lib/webgen/plugins/coreplugins/configuration.rb +11 -102
- data/lib/webgen/plugins/coreplugins/resourcemanager.rb +95 -74
- data/lib/webgen/plugins/filehandlers/copy.rb +41 -19
- data/lib/webgen/plugins/filehandlers/directory.rb +52 -50
- data/lib/webgen/plugins/filehandlers/filehandler.rb +370 -123
- data/lib/webgen/plugins/filehandlers/gallery.rb +368 -117
- data/lib/webgen/plugins/filehandlers/page.rb +160 -146
- data/lib/webgen/plugins/filehandlers/template.rb +65 -52
- data/lib/webgen/plugins/htmlvalidators/default.rb +9 -7
- data/lib/webgen/plugins/htmlvalidators/xmllint.rb +17 -33
- data/lib/webgen/plugins/menustyles/default.rb +27 -25
- data/lib/webgen/plugins/menustyles/horizontal.rb +22 -41
- data/lib/webgen/plugins/menustyles/horizontal_dropdown.rb +25 -39
- data/lib/webgen/plugins/menustyles/section.rb +68 -0
- data/lib/webgen/plugins/menustyles/vertical.rb +36 -56
- data/lib/webgen/plugins/menustyles/vertical_dropdown.rb +24 -32
- data/lib/webgen/plugins/miscplugins/smileyreplacer.rb +20 -17
- data/lib/webgen/plugins/miscplugins/syntax_highlighter.rb +72 -0
- data/lib/webgen/plugins/miscplugins/treewalker.rb +9 -36
- data/lib/webgen/plugins/tags/block.rb +65 -0
- data/lib/webgen/plugins/tags/breadcrumbtrail.rb +15 -11
- data/lib/webgen/plugins/tags/date.rb +11 -7
- data/lib/webgen/plugins/tags/download.rb +38 -38
- data/lib/webgen/plugins/tags/executecommand.rb +30 -15
- data/lib/webgen/plugins/tags/includefile.rb +26 -13
- data/lib/webgen/plugins/tags/langbar.rb +23 -18
- data/lib/webgen/plugins/tags/menu.rb +49 -70
- data/lib/webgen/plugins/tags/meta.rb +12 -9
- data/lib/webgen/plugins/tags/relocatable.rb +41 -13
- data/lib/webgen/plugins/tags/sitemap.rb +32 -28
- data/lib/webgen/plugins/tags/tag_processor.rb +279 -0
- data/lib/webgen/plugins/tags/wikilink.rb +25 -20
- data/lib/webgen/test.rb +202 -0
- data/lib/webgen/website.rb +310 -0
- data/test/fixtures/sample_site/src/chained.template +3 -0
- data/test/fixtures/sample_site/src/default.template +3 -0
- data/test/fixtures/sample_site/src/dir1/dir11/file111.de.page +3 -0
- data/test/fixtures/sample_site/src/dir1/dir11/file111.page +3 -0
- data/test/fixtures/sample_site/src/dir1/dir11/index.page +3 -0
- data/test/fixtures/sample_site/src/dir1/file11.page +3 -0
- data/test/fixtures/sample_site/src/dir2/file21.page +3 -0
- data/test/fixtures/sample_site/src/embedded.rhtml +1 -0
- data/test/fixtures/sample_site/src/file1.page +8 -0
- data/test/fixtures/sample_site/src/file2.de.page +6 -0
- data/test/fixtures/sample_site/src/index.de.page +4 -0
- data/test/fixtures/sample_site/src/index.en.page +1 -0
- data/test/fixtures/sample_site/src/invalid.template +3 -0
- data/test/fixtures/sample_site/src/test.jpg +1 -0
- data/test/fixtures/sample_site/src/test.template +3 -0
- data/test/fixtures/tc_content/blocks.yaml +40 -0
- data/test/fixtures/tc_content/correct.yaml +65 -0
- data/test/fixtures/tc_content/incorrect.yaml +42 -0
- data/test/fixtures/tc_filehandler_filehandler/backing/metainfo.yaml +9 -0
- data/test/fixtures/tc_filehandler_filehandler/backing_empty/metainfo.yaml +6 -0
- data/test/fixtures/tc_filehandler_filehandler/sample_plugin.rb +49 -0
- data/test/fixtures/tc_filehandler_filehandler/unmodified +0 -0
- data/test/fixtures/tc_filehandler_gallery/test.gallery +2 -0
- data/test/fixtures/tc_filehandler_gallery/test1.gallery +2 -0
- data/test/fixtures/tc_filehandler_gallery/test1.jpg +0 -0
- data/test/fixtures/tc_filehandler_gallery/test2.jpg +0 -0
- data/test/fixtures/tc_filehandler_gallery/test3.jpg +0 -0
- data/test/fixtures/tc_filehandler_gallery/test4.jpg +0 -0
- data/test/fixtures/tc_filehandler_page/testdata.yaml +10 -0
- data/test/fixtures/tc_menustyles_default/menustyle.rb +7 -0
- data/test/fixtures/tc_node/nodes.yaml +64 -0
- data/test/fixtures/tc_plugin/handlerplugin.rb +15 -0
- data/test/fixtures/tc_plugin/plugin1.rb +33 -0
- data/test/fixtures/tc_plugin/plugin2.rb +8 -0
- data/test/fixtures/tc_tags_includefile/testfile +1 -0
- data/test/fixtures/tc_tags_tag_processor/test_file1 +1 -0
- data/test/fixtures/tc_tags_tag_processor/testtag.rb +17 -0
- data/test/fixtures/tc_website/correct.yaml +6 -0
- data/test/fixtures/tc_website/incorrect_structure.yaml +2 -0
- data/test/fixtures/tc_website/incorrect_yaml.yaml +5 -0
- data/test/fixtures/tc_website/meta_info_test.yaml +10 -0
- data/test/fixtures/tc_website/testdir/README +1 -0
- data/test/fixtures/tc_website/testdir/falsedir/README +1 -0
- data/test/runtests.rb +2 -0
- data/test/unittests/tc_composite.rb +82 -0
- data/test/unittests/tc_config.rb +18 -0
- data/test/unittests/tc_content.rb +88 -0
- data/test/unittests/tc_contentconverters_default.rb +13 -0
- data/test/unittests/tc_contentconverters_html.rb +16 -0
- data/test/unittests/tc_contentconverters_markdown.rb +22 -0
- data/test/unittests/tc_contentconverters_rdoc.rb +16 -0
- data/test/unittests/tc_contentconverters_textile.rb +22 -0
- data/test/unittests/tc_contentconverters_xmlbuilder.rb +22 -0
- data/test/unittests/tc_filehandler_copy.rb +65 -0
- data/test/unittests/tc_filehandler_directory.rb +134 -0
- data/test/unittests/tc_filehandler_filehandler.rb +294 -0
- data/test/unittests/tc_filehandler_gallery.rb +165 -0
- data/test/unittests/tc_filehandler_page.rb +183 -0
- data/test/unittests/tc_filehandler_template.rb +60 -0
- data/test/unittests/tc_htmlvalidators_default.rb +12 -0
- data/test/unittests/tc_htmlvalidators_xmllint.rb +19 -0
- data/test/unittests/tc_languages.rb +57 -0
- data/test/unittests/tc_listener.rb +72 -0
- data/test/unittests/tc_menustyles_default.rb +51 -0
- data/test/unittests/tc_menustyles_horizontal.rb +18 -0
- data/test/unittests/tc_menustyles_horizontal_dropdown.rb +18 -0
- data/test/unittests/tc_menustyles_section.rb +59 -0
- data/test/unittests/tc_menustyles_vertical.rb +79 -0
- data/test/unittests/tc_menustyles_vertical_dropdown.rb +18 -0
- data/test/unittests/tc_node.rb +202 -0
- data/test/unittests/tc_plugin.rb +214 -0
- data/test/unittests/tc_resourcemanager.rb +42 -0
- data/test/unittests/tc_smileyreplacer.rb +25 -0
- data/test/unittests/tc_syntax_highlighter.rb +30 -0
- data/test/unittests/tc_tags_block.rb +27 -0
- data/test/unittests/tc_tags_breadcrumbtrail.rb +22 -0
- data/test/unittests/tc_tags_date.rb +15 -0
- data/test/unittests/tc_tags_download.rb +32 -0
- data/test/unittests/tc_tags_executecommand.rb +37 -0
- data/test/unittests/tc_tags_includefile.rb +53 -0
- data/test/unittests/tc_tags_langbar.rb +42 -0
- data/test/unittests/tc_tags_menu.rb +50 -0
- data/test/unittests/tc_tags_meta.rb +19 -0
- data/test/unittests/tc_tags_relocatable.rb +66 -0
- data/test/unittests/tc_tags_sitemap.rb +33 -0
- data/test/unittests/tc_tags_tag_processor.rb +107 -0
- data/test/unittests/tc_tags_wikilink.rb +22 -0
- data/test/unittests/tc_treewalker.rb +44 -0
- data/test/unittests/tc_website.rb +188 -0
- metadata +829 -312
- data/bin/webgen-gallery-editor +0 -654
- data/bin/webgen-gui +0 -10
- data/data/webgen/website_templates/default/config.yaml +0 -2
- data/doc/plugin/clidesc.rb +0 -46
- data/doc/plugin/source.rb +0 -21
- data/doc/src/about.page +0 -22
- data/doc/src/documentation/cli.page +0 -12
- data/doc/src/documentation/plugins/contenthandlers/html.page +0 -11
- data/doc/src/documentation/plugins/contenthandlers/index.page +0 -7
- data/doc/src/documentation/plugins/contenthandlers/markdown.page +0 -11
- data/doc/src/documentation/plugins/contenthandlers/rdoc.page +0 -11
- data/doc/src/documentation/plugins/contenthandlers/textile.page +0 -11
- data/doc/src/documentation/plugins/coreplugins/configuration.page +0 -12
- data/doc/src/documentation/plugins/coreplugins/index.page +0 -7
- data/doc/src/documentation/plugins/coreplugins/logging.page +0 -13
- data/doc/src/documentation/plugins/coreplugins/resourcemanager.page +0 -34
- data/doc/src/documentation/plugins/filehandlers/backing.page +0 -46
- data/doc/src/documentation/plugins/filehandlers/copy.page +0 -12
- data/doc/src/documentation/plugins/filehandlers/directoryhandler.page +0 -35
- data/doc/src/documentation/plugins/filehandlers/gallery.page +0 -86
- data/doc/src/documentation/plugins/filehandlers/index.page +0 -34
- data/doc/src/documentation/plugins/filehandlers/page.page +0 -170
- data/doc/src/documentation/plugins/filehandlers/template.page +0 -21
- data/doc/src/documentation/plugins/gallerylayouters/index.page +0 -18
- data/doc/src/documentation/plugins/htmlvalidators/index.page +0 -6
- data/doc/src/documentation/plugins/htmlvalidators/xmllint.page +0 -14
- data/doc/src/documentation/plugins/menustyles/horizontal.page +0 -21
- data/doc/src/documentation/plugins/menustyles/index.page +0 -12
- data/doc/src/documentation/plugins/menustyles/partial.page +0 -27
- data/doc/src/documentation/plugins/menustyles/vertical.page +0 -32
- data/doc/src/documentation/plugins/menustyles/verticaldropdown.page +0 -23
- data/doc/src/documentation/plugins/miscplugins/index.page +0 -7
- data/doc/src/documentation/plugins/tags/breadcrumbtrail.page +0 -20
- data/doc/src/documentation/plugins/tags/date.page +0 -19
- data/doc/src/documentation/plugins/tags/download.page +0 -23
- data/doc/src/documentation/plugins/tags/executecommand.page +0 -18
- data/doc/src/documentation/plugins/tags/includefile.page +0 -15
- data/doc/src/documentation/plugins/tags/index.page +0 -44
- data/doc/src/documentation/plugins/tags/langbar.page +0 -27
- data/doc/src/documentation/plugins/tags/menu.de.page +0 -12
- data/doc/src/documentation/plugins/tags/menu.page +0 -19
- data/doc/src/documentation/plugins/tags/multilang.de.page +0 -4
- data/doc/src/documentation/plugins/tags/multilang.fr.page +0 -4
- data/doc/src/documentation/plugins/tags/multilang.page +0 -4
- data/doc/src/documentation/plugins/tags/relocatable.page +0 -16
- data/doc/src/documentation/plugins/tags/resource.page +0 -22
- data/doc/src/documentation/plugins/tags/sitemap.page +0 -17
- data/doc/src/documentation/plugins/tags/wikilink.page +0 -18
- data/doc/src/documentation/webgen_gallery_editor.page +0 -82
- data/doc/src/images/screenshots/wge-image.png +0 -0
- data/doc/src/images/screenshots/wge-layout-preview.png +0 -0
- data/doc/src/images/screenshots/wge-main-disabled.png +0 -0
- data/doc/src/images/screenshots/wge-main.png +0 -0
- data/doc/src/meta.info +0 -30
- data/doc/src/screenshots.gallery +0 -33
- data/install.rb +0 -19
- data/lib/webgen.rb +0 -277
- data/lib/webgen/plugins/contenthandlers/markdown.rb +0 -50
- data/lib/webgen/plugins/coreplugins/logging.rb +0 -101
- data/lib/webgen/plugins/filehandlers/backing.rb +0 -159
- data/lib/webgen/plugins/gallerylayouters/default.rb +0 -152
- data/lib/webgen/plugins/menustyles/partial.rb +0 -95
- data/lib/webgen/plugins/tags/tags.rb +0 -254
data/lib/webgen/plugin.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#
|
|
2
2
|
#--
|
|
3
3
|
#
|
|
4
|
-
# $Id: plugin.rb
|
|
4
|
+
# $Id: plugin.rb 578 2007-01-04 20:35:37Z thomas $
|
|
5
5
|
#
|
|
6
6
|
# webgen: template based static website generator
|
|
7
7
|
# Copyright (C) 2004 Thomas Leitner
|
|
@@ -20,13 +20,18 @@
|
|
|
20
20
|
#++
|
|
21
21
|
#
|
|
22
22
|
|
|
23
|
+
require 'find'
|
|
23
24
|
require 'yaml'
|
|
24
25
|
require 'ostruct'
|
|
26
|
+
require 'logger'
|
|
27
|
+
require 'tsort'
|
|
28
|
+
require 'webgen/config'
|
|
25
29
|
|
|
26
30
|
class OpenStruct
|
|
27
31
|
public :table #:nodoc:#
|
|
28
32
|
end
|
|
29
33
|
|
|
34
|
+
|
|
30
35
|
module Webgen
|
|
31
36
|
|
|
32
37
|
# Base module for all plugins. This module should be included by classes which need to derive from
|
|
@@ -38,47 +43,6 @@ module Webgen
|
|
|
38
43
|
# PluginDefs module.
|
|
39
44
|
module ClassMethods
|
|
40
45
|
|
|
41
|
-
# Holds the plugin data from each and every plugin.
|
|
42
|
-
@@config = {}
|
|
43
|
-
@@configFileData = {}
|
|
44
|
-
|
|
45
|
-
# Reloads the configuration file data.
|
|
46
|
-
def load_config_file
|
|
47
|
-
@@configFileData = ( File.exists?( 'config.yaml' ) ? YAML::load( File.new( 'config.yaml' ) ) : {} )
|
|
48
|
-
@@configFileData = {} unless @@configFileData.kind_of?( Hash )
|
|
49
|
-
@@configFileData.each do |pluginName, params|
|
|
50
|
-
next if (pair = @@config.find {|pluginKlass, data| data.plugin == pluginName}).nil?
|
|
51
|
-
if params.kind_of?( Hash ) && !pair[1].params.nil?
|
|
52
|
-
pair[1].params.each do |name, value|
|
|
53
|
-
set_param( pluginName, name, params[name] ) if params.has_key?( name )
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# Reset the configuration data. The configuration has to be initialized again.
|
|
60
|
-
def reset_config_data
|
|
61
|
-
@@config.each do |pluginKlass, data|
|
|
62
|
-
if pluginKlass != Logging && pluginKlass != Configuration
|
|
63
|
-
data.obj = nil
|
|
64
|
-
end
|
|
65
|
-
data.params.each {|name, p| set_param( data.plugin, name, p.default ) } if data.params
|
|
66
|
-
end
|
|
67
|
-
load_config_file
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Return plugin data
|
|
71
|
-
def config
|
|
72
|
-
@@config
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Shortcut for getting the plugin with the name +name+.
|
|
76
|
-
def []( name )
|
|
77
|
-
pair = @@config.find {|k,v| v.plugin == name }
|
|
78
|
-
self.logger.warn { "Could not retrieve plugin '#{name}' as such a plugin does not exist!" } if pair.nil?
|
|
79
|
-
pair[1].obj unless pair.nil?
|
|
80
|
-
end
|
|
81
|
-
|
|
82
46
|
# Add subclass to plugin data.
|
|
83
47
|
def inherited( klass )
|
|
84
48
|
ClassMethods.extended( klass )
|
|
@@ -86,153 +50,525 @@ module Webgen
|
|
|
86
50
|
|
|
87
51
|
# Called when PluginDefs is included in another class. Add this class to plugin data.
|
|
88
52
|
def self.extended( klass )
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
53
|
+
callcc {|cont| throw :plugin_class_found, [cont, klass]}
|
|
54
|
+
klass.init_config
|
|
55
|
+
rescue NameError => e
|
|
56
|
+
raise "Plugin '#{klass}' managed by no PluginLoader"
|
|
93
57
|
end
|
|
94
58
|
|
|
95
|
-
|
|
96
|
-
|
|
59
|
+
# Initializes the plugin configuration structure.
|
|
60
|
+
def init_config
|
|
61
|
+
@config = OpenStruct.new
|
|
62
|
+
@config.plugin_klass = self
|
|
63
|
+
@config.params = {}
|
|
64
|
+
@config.infos = {}
|
|
65
|
+
@config.infos[:name] = self.name.sub(/^(#<.*?>|Webgen::DEFAULT_WRAPPER_MODULE)::/,'').sub('::','/')
|
|
66
|
+
@config.dependencies = []
|
|
97
67
|
end
|
|
98
68
|
|
|
69
|
+
# Returns the configuration structure for the plugin.
|
|
70
|
+
def config
|
|
71
|
+
@config
|
|
72
|
+
end
|
|
99
73
|
|
|
100
|
-
#
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
dep.each {|d| (@@config[self].dependencies ||= []) << d}
|
|
74
|
+
# Returns the name of the plugin. If not plugin name is set a default value is used.
|
|
75
|
+
def plugin_name
|
|
76
|
+
@config.infos[:name]
|
|
104
77
|
end
|
|
105
78
|
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
|
|
79
|
+
# Sets general information about the plugin (summary text, description, ...). The parameter
|
|
80
|
+
# has to be a Hash. The following fields are recognized:
|
|
81
|
+
# :name :: The name of the plugin. Should be of the form Namespace/Namespace/name and
|
|
82
|
+
# should contain only alphanumeric characters.
|
|
83
|
+
# :summary :: Summary of what the plugin does
|
|
84
|
+
# :description :: Extended description of the functionality
|
|
85
|
+
# :author :: The author of the plugin
|
|
86
|
+
# :instantiate :: Boolean value defining whether an instance of this plugin should be created
|
|
87
|
+
# :is_base_plugin :: Boolean value defining whether the plugin class is available from a plugin
|
|
88
|
+
# loader/manager after loading
|
|
89
|
+
def infos( param )
|
|
90
|
+
self.config.infos.update( param )
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Add a dependency to the plugin, ie. the name of another plugin. Dependencies are
|
|
94
|
+
# instantiated before the plugin gets instantiated. So only add those plugins here that you
|
|
95
|
+
# need to reference/use in the initialize method! The parameters have to be Strings!
|
|
96
|
+
def depends_on( *dep )
|
|
97
|
+
dep.each {|d| self.config.dependencies << d}
|
|
109
98
|
end
|
|
110
99
|
|
|
111
|
-
#
|
|
100
|
+
# Defines a parameter.The parameter can be changed in the configuration file later.
|
|
112
101
|
#
|
|
113
102
|
# Arguments:
|
|
114
103
|
# +name+:: the name of the parameter
|
|
115
104
|
# +default+:: the default value of the parameter
|
|
116
105
|
# +description+:: a small description of the parameter
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
106
|
+
def param( name, default, description )
|
|
107
|
+
data = OpenStruct.new( :name => name, :default => default, :description => description )
|
|
108
|
+
self.config.params[name] = data
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Returns the ancestor classes for the object's class which are not base plugins.
|
|
112
|
+
def ancestor_classes
|
|
113
|
+
ancestors.delete_if {|c| c.instance_of?( Module ) ||
|
|
114
|
+
(c.respond_to?( :config ) && c.config.infos[:is_base_plugin] == true) }[0..-2]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Appends the methods of this module as object methods to the including class and the methods
|
|
120
|
+
# defined in the module ClassMethods as class methods.
|
|
121
|
+
def self.append_features( klass )
|
|
122
|
+
super
|
|
123
|
+
klass.extend( ClassMethods )
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Assigns the PluginManager used for the plugin instance.
|
|
127
|
+
def initialize( plugin_manager )
|
|
128
|
+
@plugin_manager = plugin_manager
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Returns the parameter +name+ for the plugin. If +plugin+ is specified, the parameter +name+
|
|
132
|
+
# for the plugin +plugin+ is returned.
|
|
133
|
+
def []( name, plugin = nil)
|
|
134
|
+
@plugin_manager.param_for_plugin( plugin || self.class.plugin_name, name )
|
|
135
|
+
end
|
|
136
|
+
alias param []
|
|
137
|
+
|
|
138
|
+
CALLER_REGEXP = Regexp.new("`.*'")
|
|
139
|
+
|
|
140
|
+
# Logs the the result of +block+ using the severity level +sev_level+.
|
|
141
|
+
def log( sev_level, &block )
|
|
142
|
+
source = self.class.plugin_name + '#' + caller[0][CALLER_REGEXP][1..-2]
|
|
143
|
+
@plugin_manager.log_msg( sev_level, source, &block )
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
class ::Object
|
|
149
|
+
|
|
150
|
+
# This method should be used instead of +require+ when loading a plugin file.
|
|
151
|
+
def load_plugin( file )
|
|
152
|
+
file = file + '.rb' unless /\.rb$/ =~ file
|
|
153
|
+
wrapper, do_load = callcc {|cont| throw :load_plugin_file?, [cont, file]}
|
|
154
|
+
|
|
155
|
+
realfile = file
|
|
156
|
+
if /^(\/|\w:)/ !~ realfile
|
|
157
|
+
$:.each do |path|
|
|
158
|
+
realfile = File.join( path, file )
|
|
159
|
+
break if File.exists?( realfile )
|
|
127
160
|
end
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
wrapper.module_eval( File.read( realfile ), file, 1 ) if do_load
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Used to load optional parts. You have to specify a unique +name+ for the optional part and
|
|
167
|
+
# options with some information about it. The following keys can be used:
|
|
168
|
+
# :needed_gems :: an array of Rubygem's gem names that are required for the part
|
|
169
|
+
# :error_msg :: error message that should be displayed if the part can't be loaded
|
|
170
|
+
# :info :: information about what the part does
|
|
171
|
+
def load_optional_part( name, options = {} )
|
|
172
|
+
options[:loaded] = true
|
|
173
|
+
begin
|
|
174
|
+
yield
|
|
175
|
+
rescue LoadError => e
|
|
176
|
+
options[:loaded] = false
|
|
177
|
+
options[:error_msg] ||= e.message
|
|
178
|
+
end
|
|
179
|
+
callcc {|cont| throw :load_optional_part, [cont, name, options]}
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Responsible for loading plugins classes. Each PluginLoader has an array of plugin classes which
|
|
185
|
+
# it loaded. Several methods for loading plugins classes are available.
|
|
186
|
+
class PluginLoader
|
|
187
|
+
|
|
188
|
+
# The plugin classes loaded by this PluginLoader instance.
|
|
189
|
+
attr_reader :plugin_classes
|
|
190
|
+
|
|
191
|
+
# The optional parts managed (loaded or not) by this PluginLoader instance.
|
|
192
|
+
attr_reader :optional_parts
|
|
193
|
+
|
|
194
|
+
# Creates a new PluginLoader instance. The +wrapper_module+ is used when loading the plugins so
|
|
195
|
+
# that they do not pollute the global namespace.
|
|
196
|
+
def initialize( wrapper_module = Module.new )
|
|
197
|
+
@plugin_classes = []
|
|
198
|
+
@loaded_files = []
|
|
199
|
+
@wrapper_module = wrapper_module
|
|
200
|
+
@optional_parts = {}
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Loads all plugin classes in the given +dir+ and in its subdirectories. Before +require+ is
|
|
204
|
+
# actually called the path is trimmed: if +trimpath+ matches the beginning of the string,
|
|
205
|
+
# +trimpath+ is deleted from it. The loaded classes are wrapped in the wrapper module and won't
|
|
206
|
+
# pollute the namespace.
|
|
207
|
+
def load_from_dir( dir, trimpath = '')
|
|
208
|
+
Find.find( dir ) do |file|
|
|
209
|
+
trimmedFile = file.gsub(/^#{trimpath}/, '')
|
|
210
|
+
Find.prune unless File.directory?( file ) || (/\.rb$/ =~ file)
|
|
211
|
+
load_from_file( trimmedFile ) if File.file?( file ) && /\.rb$/ =~ file
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Loads all plugin classes specified in the +file+.The loaded classes are wrapped in the wrapper
|
|
216
|
+
# module and won't pollute the namespace.
|
|
217
|
+
def load_from_file( file )
|
|
218
|
+
load_from_block do
|
|
219
|
+
cont, file = catch( :load_plugin_file? ) do
|
|
220
|
+
load_plugin( file )
|
|
221
|
+
nil
|
|
147
222
|
end
|
|
148
|
-
|
|
223
|
+
do_load_file = !@loaded_files.include?( file ) unless file.nil?
|
|
224
|
+
@loaded_files << file unless file.nil? || @loaded_files.include?( file )
|
|
225
|
+
cont.call( @wrapper_module, do_load_file ) if cont
|
|
149
226
|
end
|
|
227
|
+
end
|
|
150
228
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
229
|
+
# Loads all plugin classes which get declared in the given block. Be aware that this method does
|
|
230
|
+
# not put the classes into the wrapper module!
|
|
231
|
+
def load_from_block( &block )
|
|
232
|
+
cont, klass = catch( :plugin_class_found ) do
|
|
233
|
+
cont, name, options = catch( :load_optional_part ) { yield }
|
|
234
|
+
if cont
|
|
235
|
+
@optional_parts[name] = options
|
|
236
|
+
cont.call
|
|
155
237
|
end
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
238
|
+
nil # return value for catch, means: all classes processed
|
|
239
|
+
end
|
|
240
|
+
add_plugin_class( klass ) unless klass.nil?
|
|
241
|
+
cont.call if cont
|
|
242
|
+
sort_out_base_plugins
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# Checks if this PluginLoader has loaded a plugin called +name+.
|
|
246
|
+
def has_plugin?( name )
|
|
247
|
+
plugin_class_for_name( name ) != nil
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Returns the plugin class called +name+ or +nil+ if it is not found.
|
|
251
|
+
def plugin_class_for_name( name )
|
|
252
|
+
@plugin_classes.find {|p| p.plugin_name == name}
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
#######
|
|
256
|
+
private
|
|
257
|
+
#######
|
|
258
|
+
|
|
259
|
+
def add_plugin_class( klass )
|
|
260
|
+
@plugin_classes << klass
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def sort_out_base_plugins
|
|
264
|
+
@plugin_classes.delete_if {|klass| klass.config.infos[:is_base_plugin] == true}
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
# Raised when a plugin which should have been loaded was not loaded.
|
|
271
|
+
class PluginNotFound < RuntimeError
|
|
272
|
+
|
|
273
|
+
attr_reader :name
|
|
274
|
+
attr_reader :needed_by
|
|
275
|
+
|
|
276
|
+
def initialize( name, needed_by )
|
|
277
|
+
@name = name
|
|
278
|
+
@needed_by = needed_by
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
def message
|
|
282
|
+
"Plugin '#{@name}' needed by '#{@needed_by}', but it was not loaded"
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
# Raised when a parameter for a plugin does not exist.
|
|
289
|
+
class PluginParamNotFound < RuntimeError
|
|
290
|
+
|
|
291
|
+
def initialize( plugin, param )
|
|
292
|
+
@plugin = plugin
|
|
293
|
+
@param = param
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def message
|
|
297
|
+
"Could not find parameter '#{@param}' for plugin '#{@plugin}'"
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
# This class should be passed as return value if the value for a parameter could not be found.
|
|
304
|
+
class PluginParamValueNotFound; end
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
# Helper class for calculating plugin dependencies.
|
|
308
|
+
class DependencyHash < Hash
|
|
309
|
+
include TSort
|
|
310
|
+
|
|
311
|
+
alias tsort_each_node each_key
|
|
312
|
+
def tsort_each_child(node, &block)
|
|
313
|
+
fetch(node).each(&block)
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
# Once plugin classes are loaded, they are ready to get used. This class is used for instantiating
|
|
319
|
+
# plugins and their dependencies in the correct order and provide the plugins the facility for
|
|
320
|
+
# retrieving current parameter values.
|
|
321
|
+
class PluginManager
|
|
322
|
+
|
|
323
|
+
# A hash of all instantiated plugins.
|
|
324
|
+
attr_reader :plugins
|
|
325
|
+
|
|
326
|
+
# Used for plugin dependency resolution.
|
|
327
|
+
attr_reader :plugin_loaders
|
|
328
|
+
|
|
329
|
+
# Used for retrieving current plugin parameter values. Should be set before calling #init.
|
|
330
|
+
attr_accessor :plugin_config
|
|
331
|
+
|
|
332
|
+
# The logger used by the instance and the plugin objects.
|
|
333
|
+
attr_accessor :logger
|
|
334
|
+
|
|
335
|
+
# Creates a new PluginManager instance.
|
|
336
|
+
def initialize( plugin_loaders = [], plugin_classes = [] )
|
|
337
|
+
@logger = nil
|
|
338
|
+
@plugins = {}
|
|
339
|
+
@plugin_classes = {}
|
|
340
|
+
@plugin_loaders = plugin_loaders
|
|
341
|
+
@plugin_config = nil
|
|
342
|
+
add_plugin_classes( plugin_classes )
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
# A list of all plugins that should get instantiated.
|
|
346
|
+
def plugin_classes
|
|
347
|
+
@plugin_classes.values
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
# Adds all Plugin classes in the array +plugins+ and their dependencies.
|
|
351
|
+
def add_plugin_classes( plugins )
|
|
352
|
+
deps = dependent_plugins( plugins )
|
|
353
|
+
(plugins + deps).each {|p| @plugin_classes[p.plugin_name] = p }
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
# Instantiates the plugins in the correct order, except the classes which have the plugin info
|
|
357
|
+
# +:instantiate+ set to +false+.
|
|
358
|
+
def init
|
|
359
|
+
@plugins = {}
|
|
360
|
+
#precalculate_param_values! #TODO: maybe activate this feature
|
|
361
|
+
dep = DependencyHash.new
|
|
362
|
+
@plugin_classes.each {|name, plugin| dep[name] = plugin.config.dependencies }
|
|
363
|
+
dep.tsort.each do |plugin_name|
|
|
364
|
+
config = plugin_class_for_name( plugin_name ).config
|
|
365
|
+
unless config.infos.has_key?(:instantiate) && !config.infos[:instantiate]
|
|
366
|
+
log_msg( :debug, 'PluginManager#init') { "Creating plugin of class #{config.plugin_name}" }
|
|
367
|
+
@plugins[plugin_name] = config.plugin_klass.new( self )
|
|
175
368
|
end
|
|
176
|
-
end"
|
|
177
|
-
module_eval s
|
|
178
369
|
end
|
|
370
|
+
end
|
|
179
371
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
372
|
+
# Returns the plugin instance for the plugin called +plugin_name+.
|
|
373
|
+
def []( plugin_name )
|
|
374
|
+
@plugins[plugin_name]
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
# Returns the parameter +param+ for the plugin called +plugin_name+.
|
|
378
|
+
def param_for_plugin( plugin_name, param )
|
|
379
|
+
plugin = plugin_class_for_name( plugin_name )
|
|
380
|
+
raise PluginParamNotFound.new( plugin_name, param ) if plugin.nil?
|
|
381
|
+
|
|
382
|
+
if @precalculated_param_values
|
|
383
|
+
value = @precalculated_param_values[plugin_name][param]
|
|
384
|
+
else
|
|
385
|
+
value = PluginParamValueNotFound
|
|
386
|
+
plugin.ancestor_classes.each do |plugin_klass|
|
|
387
|
+
value = get_plugin_param_value( plugin_klass.plugin_name, plugin_klass.config, param )
|
|
388
|
+
break unless value == PluginParamValueNotFound
|
|
389
|
+
end
|
|
183
390
|
end
|
|
184
391
|
|
|
392
|
+
if value != PluginParamValueNotFound
|
|
393
|
+
value
|
|
394
|
+
else
|
|
395
|
+
raise PluginParamNotFound.new( plugin.plugin_name, param )
|
|
396
|
+
end
|
|
185
397
|
end
|
|
186
398
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
399
|
+
# Returns the plugin class for the plugin +plugin_name+.
|
|
400
|
+
def plugin_class_for_name( plugin_name )
|
|
401
|
+
@plugin_classes[plugin_name]
|
|
190
402
|
end
|
|
191
403
|
|
|
192
|
-
#
|
|
193
|
-
def
|
|
194
|
-
|
|
404
|
+
# Returns the options hash for the given optional library.
|
|
405
|
+
def optional_part( name )
|
|
406
|
+
@plugin_loaders.each {|pl| return pl.optional_parts[name] if pl.optional_parts.has_key?( name ) }
|
|
195
407
|
end
|
|
196
|
-
alias get_param []
|
|
197
408
|
|
|
198
|
-
#
|
|
199
|
-
|
|
200
|
-
|
|
409
|
+
# Logs the result of executing +block+ under the severity level +sev_level+. The parameter
|
|
410
|
+
# +source+ identifies the source of the log message.
|
|
411
|
+
def log_msg( sev_level, source, &block )
|
|
412
|
+
@logger.send( sev_level, source, &block ) if @logger
|
|
413
|
+
nil
|
|
201
414
|
end
|
|
202
415
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
416
|
+
#######
|
|
417
|
+
private
|
|
418
|
+
#######
|
|
419
|
+
|
|
420
|
+
def precalculate_param_values!
|
|
421
|
+
@precalculated_param_values = nil
|
|
422
|
+
precalc = Hash.new {|h,k| h[k] = Hash.new( PluginParamValueNotFound ) }
|
|
423
|
+
@plugin_classes.each do |name, klass|
|
|
424
|
+
klass.ancestor_classes.each do |a_klass|
|
|
425
|
+
a_klass.config.params.each do |p_name, p_data|
|
|
426
|
+
precalc[name][p_name] = param_for_plugin( name, p_name )
|
|
427
|
+
end
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
@precalculated_param_values = precalc
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def dependent_plugins( classes )
|
|
434
|
+
deps = []
|
|
435
|
+
classes.each do |plugin|
|
|
436
|
+
plugin.config.dependencies.each do |dep|
|
|
437
|
+
p = nil
|
|
438
|
+
@plugin_loaders.each {|loader| p = loader.plugin_class_for_name( dep ); break unless p.nil? }
|
|
439
|
+
if p.nil?
|
|
440
|
+
raise PluginNotFound.new( dep, plugin.plugin_name )
|
|
441
|
+
else
|
|
442
|
+
deps << p unless deps.include?( p )
|
|
443
|
+
end
|
|
444
|
+
end
|
|
207
445
|
end
|
|
446
|
+
deps
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
def get_plugin_param_value( plugin_name, config, param )
|
|
450
|
+
return PluginParamValueNotFound unless config.params.has_key?( param )
|
|
451
|
+
|
|
452
|
+
value = PluginParamValueNotFound
|
|
453
|
+
value = @plugin_config.param_for_plugin( plugin_name, param ) if @plugin_config
|
|
454
|
+
value = config.params[param].default if value == PluginParamValueNotFound
|
|
455
|
+
|
|
456
|
+
value
|
|
208
457
|
end
|
|
209
458
|
|
|
210
459
|
end
|
|
211
460
|
|
|
212
|
-
module CommandPlugin; end
|
|
213
461
|
|
|
214
|
-
#
|
|
215
|
-
class
|
|
216
|
-
|
|
462
|
+
# Used for logging the messages of plugin instances.
|
|
463
|
+
class Logger < ::Logger
|
|
464
|
+
|
|
465
|
+
def initialize( logdev = STDERR )
|
|
466
|
+
super( logdev, 0, 0 )
|
|
467
|
+
self.level = ::Logger::ERROR
|
|
468
|
+
self.formatter = Proc.new do |severity, timestamp, progname, msg|
|
|
469
|
+
if self.level == ::Logger::DEBUG
|
|
470
|
+
"%5s -- %s: %s\n" % [severity, progname, msg ]
|
|
471
|
+
else
|
|
472
|
+
"%5s -- %s\n" % [severity, msg]
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
end
|
|
217
476
|
|
|
218
|
-
load_config_file
|
|
219
477
|
end
|
|
220
478
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
module Webgen
|
|
484
|
+
|
|
485
|
+
DEFAULT_PLUGIN_LOAD_PROC = proc do
|
|
486
|
+
|
|
487
|
+
# THE base class for all plugins.
|
|
488
|
+
#
|
|
489
|
+
# Information about a plugin can be set via the class method +infos+. If no name for the plugin
|
|
490
|
+
# is set, then the full plugin class name (including the namespace modules) is used, with
|
|
491
|
+
# slashes instead of the double colons.
|
|
492
|
+
class Plugin
|
|
493
|
+
|
|
494
|
+
include PluginDefs
|
|
495
|
+
|
|
496
|
+
infos :is_base_plugin => true
|
|
225
497
|
|
|
226
|
-
def self.append_features( klass )
|
|
227
|
-
super
|
|
228
|
-
PluginDefs.append_features( klass )
|
|
229
|
-
klass.extend( ClassMethods )
|
|
230
498
|
end
|
|
499
|
+
|
|
500
|
+
# You can use this class for easily handling similiar things, for example, various markup to
|
|
501
|
+
# HTML converters.
|
|
502
|
+
#
|
|
503
|
+
# To use it, just create a subclass of HandlerPlugin which will be the manager for a class of
|
|
504
|
+
# plugins. This subclass should specify all the methods, specific implementations should
|
|
505
|
+
# provide. The specific implementations should then be derived from this subclass, each using a
|
|
506
|
+
# different name for +register_handler+. Then you can retrieve a specific implementation by
|
|
507
|
+
# using the method registered_handlers[<NAME>] on the manager class.
|
|
508
|
+
class HandlerPlugin < Plugin
|
|
509
|
+
|
|
510
|
+
infos :is_base_plugin => true
|
|
511
|
+
|
|
512
|
+
# Defines the name for the specific handler under which the handler instance can be retrieved.
|
|
513
|
+
def self.register_handler( name )
|
|
514
|
+
self.config.infos[:handler_for] = name
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
# Returns the name of the specific handler.
|
|
518
|
+
def self.registered_handler
|
|
519
|
+
self.config.infos[:handler_for]
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
# Returns all handler instances as a hash. The names defined with
|
|
523
|
+
# HandlerPlugin#register_handler can be used to retrieve a specific handler instance.
|
|
524
|
+
def registered_handlers
|
|
525
|
+
if !defined?( @registered_handlers_cache ) || @cached_plugins_hash != @plugin_manager.plugins.keys.hash
|
|
526
|
+
@registered_handlers_cache = {}
|
|
527
|
+
@plugin_manager.plugins.each do |name, plugin|
|
|
528
|
+
if plugin.kind_of?( self.class ) && plugin.class.registered_handler
|
|
529
|
+
@registered_handlers_cache[plugin.class.registered_handler] = plugin
|
|
530
|
+
end
|
|
531
|
+
end
|
|
532
|
+
@cached_plugins_hash = @plugin_manager.plugins.keys.hash
|
|
533
|
+
end
|
|
534
|
+
@registered_handlers_cache
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
end
|
|
538
|
+
|
|
539
|
+
# This module should be included by classes derived from CommandParser::Command as it
|
|
540
|
+
# automatically adds an object of the class to the main CommandParser object. However, the
|
|
541
|
+
# +super+ call in the +initialize+ method calls the method from PluginDefs, you need to call
|
|
542
|
+
# +superclass_init+ to call the original +initialize+ method from the super class.
|
|
543
|
+
module CommandPlugin
|
|
544
|
+
|
|
545
|
+
def self.append_features( klass )
|
|
546
|
+
klass.instance_eval {alias_method( :superclass_initialize, :initialize )}
|
|
547
|
+
super
|
|
548
|
+
PluginDefs.append_features( klass )
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
end
|
|
552
|
+
|
|
231
553
|
end
|
|
232
554
|
|
|
233
|
-
|
|
234
|
-
|
|
555
|
+
def self.init_default_plugin_loader( mod = DEFAULT_WRAPPER_MODULE, block = DEFAULT_PLUGIN_LOAD_PROC )
|
|
556
|
+
loader = PluginLoader.new( mod )
|
|
557
|
+
loader.load_from_block( &block )
|
|
558
|
+
loader
|
|
559
|
+
end
|
|
235
560
|
|
|
236
|
-
|
|
561
|
+
def self.load_default_plugins( loader = DEFAULT_PLUGIN_LOADER )
|
|
562
|
+
loader.load_from_dir( File.join( File.dirname( __FILE__ ), 'plugins' ),
|
|
563
|
+
File.dirname( __FILE__ ).sub( /webgen$/, '' ) )
|
|
564
|
+
end
|
|
237
565
|
|
|
566
|
+
# Set this constant to +false+ before requiring the file to not load the default plugins.
|
|
567
|
+
LOAD_DEFAULT_PLUGINS = true unless defined?( LOAD_DEFAULT_PLUGINS )
|
|
238
568
|
|
|
569
|
+
# Default PluginLoader instance responsible for loading all plugins shipped with webgen.
|
|
570
|
+
DEFAULT_WRAPPER_MODULE = Module.new
|
|
571
|
+
DEFAULT_PLUGIN_LOADER = init_default_plugin_loader
|
|
572
|
+
load_default_plugins if LOAD_DEFAULT_PLUGINS
|
|
573
|
+
|
|
574
|
+
end
|