Changeset 7057
- Timestamp:
- 01/15/08 00:11:26 (9 months ago)
- Files:
-
- plugins/nahoWikiPlugin/trunk (modified) (1 prop)
- plugins/nahoWikiPlugin/trunk/CHANGELOG (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/README (modified) (6 diffs)
- plugins/nahoWikiPlugin/trunk/config/app.yml (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/config/config.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/config/config_handlers.yml (added)
- plugins/nahoWikiPlugin/trunk/config/interwiki.yml (added)
- plugins/nahoWikiPlugin/trunk/data (added)
- plugins/nahoWikiPlugin/trunk/data/fixtures (added)
- plugins/nahoWikiPlugin/trunk/lib/helper/nahoWikiHelper.php (modified) (4 diffs)
- plugins/nahoWikiPlugin/trunk/lib/model/plugin/PluginnahoWikiContentPeer.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/lib/model/plugin/PluginnahoWikiPage.php (modified) (3 diffs)
- plugins/nahoWikiPlugin/trunk/lib/model/plugin/PluginnahoWikiPagePeer.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/lib/model/plugin/PluginnahoWikiRevision.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/lib/nahoWikiConfigHandler.php (added)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/lib/BasenahoWikiActions.class.php (modified) (10 diffs)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/lib/BasenahoWikiComponents.class.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_breadcrumbs.php (added)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_content.php (added)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_diff.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_index.php (added)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_page.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_page_actions.php (added)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_page_edit.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_page_history.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_page_tools.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/_toc.php (added)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/browseSuccess.php (added)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/diffSuccess.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/editSuccess.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/historySuccess.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/userSuccess.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/modules/nahoWiki/templates/viewSuccess.php (modified) (1 diff)
- plugins/nahoWikiPlugin/trunk/package.xml (modified) (3 diffs)
- plugins/nahoWikiPlugin/trunk/web/css/default.css (modified) (2 diffs)
- plugins/nahoWikiPlugin/trunk/web/images (added)
- plugins/nahoWikiPlugin/trunk/web/images/article.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/breadcrumbs.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/dir_closed.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/dir_open.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki.png (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/amazon.de.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/amazon.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/amazon.uk.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/coral.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/doku.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/dokubug.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/google.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/meatball.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/php.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/sb.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/wiki.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/wp.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/wpde.gif (added)
- plugins/nahoWikiPlugin/trunk/web/images/interwiki/wpmeta.gif (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/nahoWikiPlugin/trunk
- Property svn:ignore set to
*.tgz
- Property svn:ignore set to
plugins/nahoWikiPlugin/trunk/CHANGELOG
r6324 r7057 1 1 == 0.0.1 == 2 2 3 * [ 2007-12-05] by naholyr3 * [] by naholyr 4 4 - Initial public release/check-in. plugins/nahoWikiPlugin/trunk/README
r6325 r7057 3 3 == Overview == 4 4 5 This plugin allows you to embed a full Wiki system within your Symfony application with the following features : 6 - Using Markdown (requires sfMarkdownPlugin) as markup language 7 - Anyone can create or edit pages (if authenticated, the username is stored via getUser()->__toString(), else the IP is stored) 8 - Every change is stored in a new revision of a page 9 - To optimize the space in the database : old revisions keep a compressed version of the content, only latest revision has uncompressed version of the content 10 - You can view and edit old revisions of a page 11 - You can view history of a page 12 - You can view an inline diff of two revisions for a page 13 - As any action, you can restrict access to edition in security.yml (action "edit") 14 - Every page has an associated discussion page like in MediaWiki. 15 - Every user has a dedicated page with the list of all his contributions, and an associated discussion page. 16 17 You can use it as usual Wiki systems, you can easily add features («Special» pages are in the todo-list and will ease the extension of this plugin in your application), and thanks to helpers and/or components you could even think about using this as a simple CMS ! 5 This plugin allows you to embed a wiki within your symfony application with the following features: 6 - Create/edit pages with full versionning 7 - Basic permissions management 8 - Basic security features 9 - History of changes 10 - Graphical and unified diff between two given revisions 11 - Preview changes before saving 12 - Internal links, supporting namespaces 13 - Interwiki links 14 - Automatically generated table of contents 15 - Breadcrumbs 16 - Configurable 17 - Fully extendable 18 - A bunch of helpers to provide total integration in your application 19 20 Most features have been inspired from [http://www.splitbrain.org/projects/dokuwiki DokuWiki] (e.g. namespaces and Interwiki work the same way). 21 22 It is not aimed at replacing full-featured wiki packages, but offers a lightweight alternative for when you build a website that has to contain a simple wiki. It is very easy to configure and adapt, so it should fulfill most basic wiki requirements. 23 24 Please note that this plugin is in active development. If you want to help and improve it, please contact Nicolas Chambrier. 18 25 19 26 == Screenshots == 20 27 21 [[Image(nahoWikiPlugin_page.png, 30%)]] 22 [[Image(nahoWikiPlugin_diff.png, 30%)]] 23 [[Image(nahoWikiPlugin_user.png, 30%)]] 24 [[Image(nahoWikiPlugin_edit.png, 30%)]] 28 [[Image(nahoWikiplugin_1.png, 30%)]] 29 [[Image(nahoWikiplugin_2.png, 30%)]] 30 [[Image(nahoWikiplugin_3.png, 30%)]] 25 31 26 32 == Requirements == 27 33 28 34 The prerequisites for using the `nahoWiki` plugin are: 29 - Currently only the Markdown syntax is supported, and this makes the [http://trac.symfony-project.com/trac/wiki/sfMarkdownPlugin sfMarkdownPlugin] a mandatory dependancy.30 - You r `myUser` class must define a well written `__toString()` method, as the plugin will only store this data (no ID is stored, all the history of a user is based on his nickname given by `__toString()`). If you don't have a user-managerment system, [http://trac.symfony-project.com/trac/wiki/sfGuardPlugin sfGuardPlugin] is a good choice but is not mandatory.35 - As the plugin doesn't contain a user management module, the project where you install it must have a table managing authors, or users (whatever the name), and the related Propel class must have a `__toString()` method. Both these conditions are satisfied by the [http://trac.symfony-project.com/trac/wiki/sfGuardPlugin sfGuardPlugin], so installing this plugin is a good choice. 36 - You need the [http://trac.symfony-project.com/trac/wiki/sfMarkdownPlugin sfMarkdownPlugin] which will provide the ability to convert from wiki syntax to XHTML contents. 31 37 32 38 == Installation == 33 39 34 === Installing the plugin === 35 36 Choose one of the following solutions, depending on your environment and your preferences. 37 38 ==== PEAR ==== 39 40 To install the plugin for a symfony project, the usual process is to use the symfony command line requiring up-to-date PEAR installation : 41 {{{ 42 $ symfony plugin-install symfony/nahoWikiPlugin 43 }}} 44 45 ==== Subversion ==== 46 47 To install the plugin from SVN you have numerous options, just check it out (or export if you don't plan to update it later) from `http://svn.symfony-project.com/plugins/nahoWikiPlugin/trunk` : 48 {{{ 49 $ svn checkout http://svn.symfony-project.com/plugins/nahoWikiPlugin/trunk plugins/nahoWikiPlugin 50 }}} 51 52 Note that you can always use the `tags` directory if you want to use a given version. You will always be able to switch from a version to another : 53 {{{ 54 // Switch to a specific version (the trunk has a bug or a backward-incompatibility I can't live with) 55 $ svn switch http://svn.symfony-project.com/plugins/nahoWikiPlugin/tags/the.version.i.want plugins/nahoWikiPlugin 56 // Switch back to trunk (I'm ready to use it) 57 $ svn switch http://svn.symfony-project.com/plugins/nahoWikiPlugin/trunk plugins/nahoWikiPlugin 58 }}} 59 60 If your project is already under subversion, you can very easily use the SVN install with svn:externals 40 === PEAR Install === 41 42 To install the plugin for a symfony project, the usual process is to use the symfony command line: 43 {{{ 44 $ php symfony plugin-install http://plugins.symfony-project.com/nahoWikiplugin 45 }}} 46 47 === SVN Install === 48 49 If your project is not under subversion yet, you can simply checkout the plugin in your plugins directory: 50 {{{ 51 $ svn co http://svn.symfony-project.com/plugins/nahoWikiplugin/trunk plugins/nahoWikiplugin 52 }}} 53 54 If your project is under version control, you can use the svn:externals property: 61 55 {{{ 62 56 $ svn propedit svn:externals plugins 63 // Add the following line : 64 nahoWikiPlugin http://svn.symfony-project.com/plugins/nahoWikiPlugin/trunk 65 }}} 66 You will be able to switch later by just changing the URL. 67 68 ==== Manually ==== 69 70 Alternatively, if you don't have PEAR installed, you can download the latest package attached to this plugin's wiki page and extract it under your project's `plugins/` directory. 71 72 === Integrating in your application === 73 74 Check the contents of your `web/` folder, it must contains a folder (or a symlink) named `nahoWikiPlugin/`. If not, you will also have to copy the contents of the `plugins/nahoWikiPlugin/web/` directory into a `web/nahoWikiPlugin/` directory (or make a symlink). 75 76 Rebuild the model, generate the SQL code for the new tables and insert it into your database: 77 {{{ 78 $ php symfony propel-build-all 57 }}} 58 and add the following line: 59 {{{ 60 nahoWikiplugin http://svn.symfony-project.com/plugins/nahoWikiplugin/trunk plugins/nahoWikiplugin 61 }}} 62 63 After you installed `nahoWikiplugin` this way, you must copy (or symlink) `plugins/nahoWikiplugin/web` to `web/nahoWikiplugin`. 64 65 == General instructions == 66 67 Rebuild the model as you are used to, to create the new tables needed by the plugin. 68 {{{ 69 $ php symfony propel-build-all # Be careful, this command will erase all the existing tables of your model 79 70 }}} 80 71 … … 82 73 {{{ 83 74 $ php symfony cc 75 }}} 76 77 You can load the included fixtures to start using the forum with test data. 78 {{{ 79 $ php symfony propel-load-data frontend plugins/nahoWikiplugin/data/fixtures 84 80 }}} 85 81 … … 89 85 all: 90 86 .settings: 91 enabled_modules: [ default, nahoWiki]87 enabled_modules: [..., nahoWiki] 92 88 }}} 93 89 94 90 Start using the plugin by browsing to the frontend module's default page: 95 {{{ 91 {{{ 96 92 http://myproject/frontend_dev.php/nahoWiki 97 93 }}} 98 94 99 == Slots, Helpers, Components == 100 101 @TODO 95 == Slots == 96 97 The templates of the `nahoWiki` module define some slots that you can use inside your layout: 98 - wiki_page_actions : For the current page actions 99 - wiki_page_name : Name of the current page 100 - wiki_breadcrumbs : For the wiki breadcrumbs 101 102 If you want to insert the actions menu or the breadcrumbs in your layout at the place you exactly want, simply disable the auto-inclusion of it (see app.yml configuration) and include the corresponding slot in your layout. 103 104 Here is an example layout (in this example, options `include_page_actions` and `include_page_name` have been disabled in app.yml): 105 106 {{{ 107 ... 108 <body> 109 110 <div class="my-menus"> 111 <?php include_slot('wiki_page_actions') ?> 112 </div> 113 114 <h1><?php include_slot('wiki_page_name') ?></h1> 115 116 <?php echo $sf_data->getRaw('sf_content') ?> 117 118 </body> 119 </html> 120 }}} 102 121 103 122 == Configuration == … … 105 124 === Schema customization === 106 125 107 If you install [http://trac.symfony-project.com/wiki/sfPropelAlternativeSchemaPluginsfPropelAlternativeSchemaPlugin `sfPropelAlternativeSchema` plugin], you can customize this plugin's schema by creating a `nahoWikiPlugin_schema.custom.yml` file under your project's `config/` directory. This allows you to customize the connection name, table names, and even foreign class associations. Refer to the [http://trac.symfony-project.com/wiki/sfPropelAlternativeSchemaPluginsfPropelAlternativeSchemaPlugin README file] for more information. 126 If you install the `sfPropelAlternativeSchemaPlugin`, you can customize this plugin's schema by creating a `nahoWikiPlugin_schema.custom.yml` file under your project's `config/` directory. This allows you to customize the connection name, table names, etc… Refer to the [http://trac.symfony-project.com/wiki/sfPropelAlternativeSchemaPluginsfPropelAlternativeSchemaPlugin README file] for more information. 127 128 === Extending model, actions, or templates === 129 130 If you want to extend a class of the model, just create an empty file `lib/model/nahoWikiClass.php`, which will contain: 131 {{{ 132 <?php 133 134 class nahoWikiClass extends PluginnahoWikiClass { 135 136 // Here I add my own features, or override existing ones 137 138 } 139 }}} 140 141 If you want to extend the actions, the process is similar: create a file named `modules/nahoWiki/actions/actions.class.php` in your app's directory: 142 {{{ 143 <?php 144 145 // autoloading for plugin lib actions is broken as at symfony-1.0.2 146 require_once(sfConfig::get('sf_plugins_dir'). '/nahoWikiPlugin/modules/nahoWiki/lib/BasenahoWikiActions.class.php'); 147 148 class nahoWikiActions extends BasenahoWikiActions 149 { 150 151 // Here I add my own features, or override existing ones 152 153 } 154 155 To override a template file named `plugins/nahoWikiplugin/modules/nahoWiki/templates/theTemplate.php`, just copy it to `modules/nahoWiki/templates/theTemplate.php` in your app's folder, and then edit the copied file: it will be the one used by Symfony to render the pages. 156 In most cases, you will want to override `_page_actions.php` or `_breadcrumbs.php`, or `_toc.php`. Templates have been smartly exploded, you should be able to customize the rendering with a few efforts. 157 158 === Using another Wiki renderer === 159 160 The default engine is [http://daringfireball.net/projects/markdown Markdown] (if `sfMarkdownPlugin` is not installed, no conversion at all is done). If you want to use another engine, just override the method `nahoWikiContentPeer::doConvert($content)`. 161 162 Create a file named `lib/model/nahoWikiContentPeer.php`: 163 {{{ 164 <?php 165 166 class nahoWikiContentPeer extends PluginnahoWikiContentPeer { 167 168 public static function doConvert($content) 169 { 170 // Return converted $content from Wiki-syntax to XHTML 171 // Default behaviour is : return sfMarkdown::doConvert($content) 172 } 173 174 } 175 }}} 108 176 109 177 === app.yml === … … 114 182 all: 115 183 nahoWikiPlugin: 116 @TODO 184 # General config 185 start_page: index # Default start page 186 pagename_format: "a-z0-9\-_" # Pagename authorized characters (format compatible with PCRE) 187 ns_separator: ":" # Namespace separator character 188 max_breadcrumbs: 5 # Maximum number of links stored in the breadcrumbs 189 breadcrumbs_separator: " » " # Separator between breadcrumbs items 190 include_breadcrumbs: on # Include breadcrumbs slot (disable if you include the slot in your layout) ? 191 include_actions: on # Include actions list slot (disable if you include the slot in your layout) ? 192 include_pagename: on # Display page's name when viewing content ? 193 include_toc: on # Display Table of Contents at top of every page 194 routes_register: on # Enable embedded routing rules ? 195 wrap_class: nahoWiki # All pages are wrapped into a <div class="..."> tag. This is its class name. 196 197 # Rendering for internal links, you may need to customize the *_model options if you change rendering engine 198 internal_links: ["[[%name% %title%]]", "[[%name%]]"] 199 internal_link_model: "[%title%](%link%)" 200 internal_link_broken_model: "[%title%(?)](%link%)" 201 interwiki_links: ["[[%key%>%name% %title%]]", "[[%key%>%name%]]"] 202 interwiki_link_model: "[ %title%](%link%)" 203 204 # Regular expressions replacements *before* conversion 205 replace_before: [] 206 # - { from: "/a pcre mask/i", to: "something" } # replace "a pcre mask" with "something" 207 208 # Regular expressions replacements *after* conversion 209 replace_after: [] 210 # - { from: "/a pcre mask/i", to: "something" } # replace "a pcre mask" with "something" 211 212 # Strip some tags (and their contents) for security (this comes after conversion) 213 strip_tags: [script, embed, object] 214 215 # Permissions 216 credentials_edit: [] # Credentials required to be able to edit a page 217 allow_anonymous_edit: no # Are anonymous (not authenticated) users able to edit a page ? 117 218 }}} 118 219 119 220 === Routing rules === 120 221 121 The plugin comes with the following routing rules : 122 123 {{{ 124 @TODO 125 }}} 126 127 You can add your own routing rules in your `routing.yml` folder. 222 The plugin comes with the following default rules. You can prevent those routes to be added by disabling the option `routes_register`, and add your own routing rules. 223 224 Here are the default rules: 225 {{{ 226 wiki_home: 227 url: /wiki 228 param: { module: nahoWiki, action: index } 229 230 wiki_view: 231 url: /wiki/view/:page 232 param: { module: nahoWiki, action: view } 233 234 wiki_view_revision: 235 url: /wiki/view/:page/:revision 236 param: { module: nahoWiki, action: view } 237 238 wiki_edit: 239 url: /wiki/edit/:page 240 param: { module: nahoWiki, action: edit } 241 242 wiki_edit_revision: 243 url: /wiki/edit/:page/:revision 244 param: { module: nahoWiki, action: edit } 245 246 wiki_history: 247 url: /wiki/history/:page 248 param: { module: nahoWiki, action: history } 249 250 wiki_diff: 251 url: /wiki/diff 252 param: { module: nahoWiki, action: diff } 253 254 wiki_index: 255 url: /wiki/index 256 param: { module: nahoWiki, action: browse } 257 }}} 128 258 129 259 === Look and Feel === … … 136 266 }}} 137 267 268 == nahoWiki specific features == 269 270 === Helpers === 271 272 nahoWiki provides a bunch of helpers to help you integrate the wiki in your application. 273 274 You can insert links to wiki pages, anywhere in your application : 275 276 - link_to_diff($text, $page_name, $rev1, $rev2, $mode = 'inline') 277 - link_to_raw_diff($text, $page_name, $rev1, $rev2, $mode = 'unified') 278 - url_for_wiki($page_name, $revision = null) 279 - link_to_wiki($text, $page_name, $options = array(), $revision = null) 280 - url_for_wiki_user($username, $revision = null) 281 - link_to_wiki_user($text, $username, $options = array(), $revision = null) 282 - url_for_wiki_discuss($page_name, $revision = null) 283 - link_to_wiki_discuss($text, $page_name, $options = array(), $revision = null) 284 285 You can even insert the content of a wiki page using `include_wiki` : 286 287 - include_wiki($page_name, $revision = null, $options = array()) 288 - get_wiki($page_name, $revision = null, $options = array()) 289 290 The last two helpers are just shortcuts to use nahoWiki component. 291 292 === Interwiki === 293 294 nahoWiki provides basic support for Interwiki. 295 296 The main syntax is `[[Key>PageName Title]]`, and it outputs a link to the page "PageName" of the wiki named "Key", preceded by a nice icon telling the user this is an Interwiki link. 297 298 If the file named `web/nahoWikiPlugin/images/interwiki/key.gif` exists (or `.png` or `.jpg`) it will be used, else we use the generic `interwiki.png` [[Image(source:/plugins/nahoWikiPlugin/web/images/interwiki.png)]] 299 300 To add a new Interwiki, just create a file named `interwiki.yml` in your app's folder, and add the key you want : 301 302 {{{ 303 all: 304 Key: "http://UrlOfTheWiki?page=" 305 }}} 306 307 The page name provided in the link is just added to the corresponding URL. 308 309 === Internal links === 310 311 The syntax for internal links is `[[PageName Title]]`. 312 313 Page names support namespaces. 314 315 If an internal link points to a unexisting page, it's show to the user, using different models : `internal_link_model` for links to existing pages, `internal_link_broken_model` for links to unexisting pages. 316 317 ==== Namespaces ==== 318 319 Namespaces work just the same way than [http://www.splitbrain.org/projects/dokuwiki DokuWiki] 320 138 321 == TODO == 139 322 140 * Any page can have associated credentials, which will be required to view and/or edit the page and its subpages ("Page:SubPage" is a subpage of "Page"). These page-wide credentials can be managed in a auto-generated admin module. 141 * A page can display a menu of its subpages with a special tag 142 * A page has a menu of the page's sections on its top 143 * A special tag provides inner links (links to other pages in the wiki) 144 * Everything must be configurable : special tags, choice of the markup engine, etc... 145 * Integration of the InterWiki system (configurable, of course) 146 * Make helpers (e.g. for wiki-links) and components (e.g. for a CMS use) 147 * Support alternative languages for a page 148 * Add a Javascript toolbar to help contributor (depends on the markup engine) 149 * AJAX edition 150 * Provide the index by title, and index by date 151 * Provide the «last changes» action 152 * Search engine 153 * Media uploads 154 * Add and manage the states of a page : draft, hidden, public, etc... 323 * User manual for advanced features (mainly namespaces and interwiki) 324 * Add admin modules 325 * Add ACL (fine grained permissions management) 326 * Support multilingual versions of a page plugins/nahoWikiPlugin/trunk/config/app.yml
r6324 r7057 1 all: 2 nahoWikiPlugin: 3 default_page: Index 4 data_dir: %sf_data_dir%/nahoWikiPlugin 1 #all: 2 # nahoWikiPlugin: 3 # # General config 4 # start_page: index # Default start page 5 # pagename_format: "a-z0-9\-_" # Pagename authorized characters (format compatible with PCRE) 6 # ns_separator: ":" # Namespace separator character 7 # max_breadcrumbs: 5 # Maximum number of links stored in the breadcrumbs 8 # breadcrumbs_separator: " » " # Separator between breadcrumbs items 9 # include_breadcrumbs: on # Include breadcrumbs slot (disable if you include the slot in your layout) ? 10 # include_actions: on # Include actions list slot (disable if you include the slot in your layout) ? 11 # include_pagename: on # Display page's name when viewing content ? 12 # include_toc: on # Display Table of Contents at top of every page 13 # routes_register: on # Enable embedded routing rules ? 14 # wrap_class: nahoWiki # All pages are wrapped in a <div class="..."> tag. This is its class name. 15 # 16 # # Rendering for internal links, you may need to customize the *_model options if you change rendering engine 17 # internal_links: ["[[%name% %title%]]", "[[%name%]]"] 18 # internal_link_model: "[%title%](%link%)" 19 # internal_link_broken_model: "[%title%(?)](%link%)" 20 # interwiki_links: ["[[%key%>%name% %title%]]", "[[%key%>%name%]]"] 21 # interwiki_link_model: "[ %title%](%link%)" 22 # 23 # # Regular expressions replacements *before* conversion 24 # replace_before: [] 25 # # - { from: "/a pcre mask/i", to: "something" } # replace "a pcre mask" with "something" 26 # # Example for typos : [{from: '/"(.*?)"/', to: '«$1»'}, {from: '/-+>/', to: '→'}, {from: '/<-+/', to: '←'}] 27 # 28 # # Regular expressions replacements *after* conversion 29 # replace_after: [] 30 # # - { from: "/a pcre mask/i", to: "something" } # replace "a pcre mask" with "something" 31 # 32 # # Strip some tags (and their contents) for security (this comes after conversion) 33 # strip_tags: [script, embed, object] 34 # 35 # # Permissions 36 # credentials_edit: [] # Credentials required to be able to edit a page 37 # allow_anonymous_edit: no # Are anonymous (not authenticated) users able to edit a page ? plugins/nahoWikiPlugin/trunk/config/config.php
r6324 r7057 1 1 <?php 2 2 3 $page_path = '[A-Z][a-zA-Z0-9:]+(@\d+)?'; 3 // Load InterWiki config files 4 $interwiki_config_file = sfConfig::get('sf_app_config_dir_name').'/interwiki.yml'; 5 require_once(sfConfigCache::getInstance()->checkConfig($interwiki_config_file)); // app_nahoWikiPlugin_interwiki 4 6 5 if (sfConfig::get('app_nahoWikiPlugin_routes_register', true) && in_array('nahoWiki', sfConfig::get('sf_enabled_modules', array()))) 7 // Automatic routes 8 $routes_register = sfConfig::get('app_nahoWikiPlugin_routes_register', true); 9 $enabled_module = in_array('nahoWiki', sfConfig::get('sf_enabled_modules', array())); 10 if ($routes_register && $enabled_module) 6 11 { 7 12 $r = sfRouting::getInstance(); 8 13 9 14 // preprend our routes 10 /*$r->prependRoute('sf_wiki_view', 11 '/wiki/:page', 12 array('module' => 'nahoWiki', 'action' => 'view'), 13 array('page' => $page_path)); 14 $r->prependRoute('sf_wiki_view_rev', 15 '/wiki/page/:page/revision/:revision', 16 array('module' => 'nahoWiki', 'action' => 'view'), 17 array('page' => $page_path)); 18 $r->prependRoute('sf_wiki_history', 19 '/wiki/:page/history', 20 array('module' => 'nahoWiki', 'action' => 'history'), 21 array('page' => $page_path)); 22 $r->prependRoute('sf_wiki_edit', 23 '/wiki/:page/edit', 24 array('module' => 'nahoWiki', 'action' => 'edit'), 25 array('page' => $page_path)); 26 $r->prependRoute('sf_wiki_start', 27 '/wiki/start', 28 array('module' => 'nahoWiki', 'action' => 'index'));*/ 15 $r->prependRoute('wiki_home', 16 '/wiki', 17 array('module' => 'nahoWiki', 'action' => 'index')); 18 19 $r->prependRoute('wiki_view', 20 '/wiki/view/:page', 21 array('module' => 'nahoWiki', 'action' => 'view')); 22 23 $r->prependRoute('wiki_view_revision', 24 '/wiki/view/:page/:revision', 25 array('module' => 'nahoWiki', 'action' => 'view')); 26 27 $r->prependRoute('wiki_edit', 28 '/wiki/edit/:page', 29 array('module' => 'nahoWiki', 'action' => 'edit')); 30 31 $r->prependRoute('wiki_edit_revision', 32 '/wiki/edit/:page/:revision', 33 array('module' => 'nahoWiki', 'action' => 'edit')); 34 35 $r->prependRoute('wiki_history', 36 '/wiki/history/:page', 37 array('module' => 'nahoWiki', 'action' => 'history')); 38 39 $r->prependRoute('wiki_diff', 40 '/wiki/diff', 41 array('module' => 'nahoWiki', 'action' => 'diff')); 42 43 $r->prependRoute('wiki_index', 44 '/wiki/index', 45 array('module' => 'nahoWiki', 'action' => 'browse')); 46 29 47 } plugins/nahoWikiPlugin/trunk/lib/helper/nahoWikiHelper.php
r6324 r7057 1 1 <?php 2 2 3 /** 4 * Get link to the diff page between two revisions of a page 5 * 6 * @param string $page_name 7 * @param int $revision 8 * 9 * @return string 10 */ 3 11 function link_to_diff($text, $page_name, $rev1, $rev2, $mode = 'inline') 4 12 { … … 6 14 } 7 15 16 /** 17 * Get link for the discussion page of a page in the wiki 18 * 19 * @param string $text text of the link 20 * @param string $page_name 21 * @param int $revision 22 * 23 * @return string 24 */ 8 25 function link_to_raw_diff($text, $page_name, $rev1, $rev2, $mode = 'unified') 9 26 { … … 11 28 } 12 29 30 /** 31 * Get URL for a page in the wiki 32 * 33 * @param string $page_name 34 * @param int $revision 35 * 36 * @return string 37 */ 13 38 function url_for_wiki($page_name, $revision = null) 14 39 { … … 16 41 } 17 42 18 function link_to_wiki($page_name, $revision = null) 43 /** 44 * Get link for a page in the wiki 45 * 46 * @param string $text text of the link (if null, we create it from the pagename+revision) 47 * @param string $page_name 48 * @param array $options params added to the link 49 * @param int $revision 50 * 51 * @return string 52 */ 53 function link_to_wiki($text, $page_name, $options = array(), $revision = null) 19 54 { 20 $text = htmlspecialchars($page_name); 21 if (!is_null($revision)) { 22 $text .= ' rev. ' . $revision; 55 if (is_null($text)) { 56 $text = htmlspecialchars($page_name); 57 if (!is_null($revision)) { 58 $text .= ' rev. ' . $revision; 59 } 23 60 } 24 61 25 return link_to($text, 'nahoWiki/view?page=' . urlencode($page_name) . '&revision=' . $revision );62 return link_to($text, 'nahoWiki/view?page=' . urlencode($page_name) . '&revision=' . $revision, $options); 26 63 } 64 65 /** 66 * Get URL for the presentation page of a user in the wiki 67 * 68 * @param string $username 69 * @param int $revision 70 * 71 * @return string 72 */ 73 function url_for_wiki_user($username, $revision = null) 74 { 75 return url_for_wiki($text, 'user:' . $username); 76 } 77 78 /** 79 * Get link for the presentation page of a user in the wiki 80 * 81 * @param string $text text of the link 82 * @param string $username 83 * @param array $options params added to the link 84 * @param int $revision 85 * 86 * @return string 87 */ 88 function link_to_wiki_user($text, $username, $options = array(), $revision = null) 89 { 90 return link_to_wiki($text, 'user:' . $username, $options, $revision); 91 } 92 93 /** 94 * Get URL for the discussion page of a page in the wiki 95 * 96 * @param string $page_name 97 * @param int $revision 98 * 99 * @return string 100 */ 101 function url_for_wiki_discuss($page_name, $revision = null) 102 { 103 return url_for_wiki('discuss:' . $page_name, $revision); 104 } 105 106 /** 107 * Get link for the discussion page of a page in the wiki 108 * 109 * @param string $text text of the link 110 * @param string $page_name 111 * @param array $options params added to the link 112 * @param int $revision 113 * 114 * @return string 115 */ 116 function link_to_wiki_discuss($text, $page_name, $options = array(), $revision = null) 117 { 118 return link_to_wiki($text, 'discuss:' . $page_name, $options, $revision); 119 } 120 121 /** 122 * Include (display) a wiki page 123 * 124 * Options that can be used : 125 * - display_toc => false # Hide the Table of contents 126 * - display_pagename => false # Hide the page name 127 * 128 * @param string $page_name fully qualified page name 129 * @param array $options additional options 130 * @param int $revision 131 */ 132 function include_wiki($page_name, $revision = null, $options = array()) 133 { 134 $options['pagename'] = $page_name; 135 $options['revision'] = $revision; 136 include_component('nahoWiki', 'content', $options); 137 } 138 139 /** 140 * Returns XHTML content of a wiki page 141 * 142 * Options that can be used : 143 * - display_toc => false # Hide the Table of contents 144 * - display_pagename => false # Hide the page name 145 * 146 * @param string $page_name fully qualified page name 147 * @param array $options additional options 148 * @param int $revision 149 */ 150 function get_wiki($page_name, $revision = null, $options = array()) 151 { 152 $options['pagename'] = $page_name; 153 $options['revision'] = $revision; 154 return get_component('nahoWiki', 'content', $options); 155 } plugins/nahoWikiPlugin/trunk/lib/model/plugin/PluginnahoWikiContentPeer.php
r6324 r7057 10 10 class PluginnahoWikiContentPeer extends BasenahoWikiContentPeer 11 11 { 12 13 public static function doConvert($content) 14 { 15 if (class_exists('sfMarkdown')) { 16 return sfMarkdown::doConvert($content); 17 } else { 18 return $content; 19 } 20 } 21 22 public static function makeReplacements($replaces, $content) 23 { 24 foreach ($replaces as $replace) { 25 if (is_array($replace['to'])) { 26 $content = preg_replace_callback($replace['from'], $replace['to'], $content); 27 } else { 28 $content = preg_replace($replace['from'], $replace['to'], $content); 29 } 30 } 31 32 return $content; 33 } 34 35 public static function preConvert($page, $content) 36 { 37 // Convert nahoWiki-specific internal links to a syntax compatible with the chosen wiki engine 38 $content = self::convertInternalLinks($page, $content); 39 $content = self::convertInterwikiLinks($content); 40 41 // Regexp replacements 42 $replaces = sfConfig::get('app_nahoWikiPlugin_replace_before', array()); 43 44 return self::makeReplacements($replaces, $content); 45 } 46 47 public static function postConvert($page, $html) 48 { 49 $replaces = sfConfig::get('app_nahoWikiPlugin_replace_after', array()); 50 51 // Add the rule to insert ID to titles (support for anchors) 52 $replaces[] = array( 53 'from' => '/<(h[1-6])( .*+)?>(.*?)<\/\1>/i', 54 'to' => array('self', 'callbackNameTitle') 55 ); 56 57 // Add the rule to apply security filters 58 $tags = sfConfig::get('app_nahoWikiPlugin_strip_tags', array('script', 'embed', 'object')); 59 if (count($tags)) { 60 $replaces[] = array( 61 'from' => '/<(' . implode('|', $tags) . ')( .+?)?>.*?<\/\1>/i', 62 'to' => '' 63 ); 64 } 65 66 return self::makeReplacements($replaces, $html); 67 } 68 69 protected static function extractLinkReplacements($content, $masks, $pcre_masks) 70 { 71 $replaces = array(); // hash of string-replacements to make 72 foreach ($masks as $mask) { 73 // extract mask elements 74 preg_match_all('/%(' . implode('|', array_keys($pcre_masks)) . ')%/', $mask, $elements); 75 $elements = $elements[1]; 76 // convert the mask to preg-compatible one 77 $mask = preg_quote($mask, '/'); 78 foreach ($pcre_masks as $mask_id => $pcre) { 79 $mask = str_replace('%' . $mask_id . '%', '(' . $pcre . ')', $mask); 80 } 81 // extract all corresponding items 82 preg_match_all('/' . $mask . '/i', $content, $items, PREG_SET_ORDER); 83 // delete them from working copy of content 84 $content = preg_replace('/' . $mask . '/', '', $content); 85 foreach ($items as $item) { 86 if (!isset($replaces[$item[0]])) { 87 // We did not handle this link yet 88 $name = $title = ''; 89 foreach ($elements as $i => $element) { 90 // Initialize $name and $title found by regexp 91 $$element = $item[$i+1]; 92 } 93 // default values & required elements 94 if (!$name) { 95 continue; 96 } 97 @list($name, $anchor) = explode('#', $name, 2); 98 $replaces[$item[0]] = array('name' => $name, 'title' => $title, 'anchor' => $anchor, 'link' => '#'); 99 } 100 } 101 } 102 103 return $replaces; 104 } 105 106 protected static function makeLinkReplacements($content, $replaces, $link_model, $existing_page = null, $broken_link_model = null) { 107 // make full-text replacements 108 foreach ($replaces as $source => $replace) { 109 if (@$replace['link']) { 110 // use the good model in app.yml, depending on wether the page exists or not 111 if (!is_null($existing_page) && !is_null($broken_link_model) && !isset($existing_page[$replace['name']])) { 112 $destination = $broken_link_model; 113 } else { 114 $destination = $link_model; 115 } 116 // replace by the customized model 117 $destination = str_replace( 118 array('%name%', '%title%', '%link%', '%image%', '%alttext%'), 119 array($replace['name'], $replace['title'], $replace['link'], @$replace['image'], @$replace['alttext']), 120 $destination); 121 $content = str_replace($source, $destination, $content); 122 } 123 } 124 125 return $content; 126 } 127 128 public static function convertInternalLinks($page, $content) 129 { 130 $masks = sfConfig::get('app_nahoWikiPlugin_internal_links', array('[[%name% %title%]]', '[[%name%]]')); 131 $pcre_masks = array( 132 'name' => nahoWikiPagePeer::pageNameFormat() . '(?:#[A-Za-z0-9_\-]+)?', 133 'title' => '.*?', 134 ); 135 136 $replaces = self::extractLinkReplacements($content, $masks, $pcre_masks); 137 138 // Extract names and complete the replacements array 139 $names = array(); 140 $controller = sfContext::getInstance()->getController(); 141 foreach ($replaces as &$replace) { 142 // Full name 143 $replace['name'] = $page->resolveAbsoluteName($replace['name']); 144 // Title 145 if (!$replace['title']) { 146 $replace['title'] = nahoWikiPagePeer::getBasename($replace['name']); 147 } 148 // Link 149 $url = 'nahoWiki/view?page=' . urlencode($replace['name']); 150 if (@$replace['anchor']) { 151 $url .= '#' . $replace['anchor']; 152 } 153 $replace['link'] = $controller->genUrl($url, false); 154 // Store name 155 $names[] = $replace['name']; 156 } 157 158 // Find all existing pages 159 $existing_page = array(); 160 $pages = nahoWikiPagePeer::retrieveByNames($names); 161 foreach ($pages as $page) { 162 $existing_page[$page->getName()] = true; 163 } 164 165 $link_model = sfConfig::get('app_nahoWikiPlugin_internal_link_model', '[%title%](%link%)'); 166 $broken_link_model = sfConfig::get('app_nahoWikiPlugin_internal_link_broken_model', '[%title%(?)](%link%)'); 167 168 return self::makeLinkReplacements($content, $replaces, $link_model, $existing_page, $broken_link_model); 169 } 170 171 public static function convertInterwikiLinks($content) 172 { 173 $masks = sfConfig::get('app_nahoWikiPlugin_interwiki_links', array('[[%name% %title%]]', '[[%name%]]')); 174 $pcre_masks = array( 175 'name' => '[a-z]+>' . nahoWikiPagePeer::pageNameFormat() . '(?:#[A-Za-z0-9_\-]+)?', 176 'title' => '.*?', 177 ); 178 179 $replaces = self::extractLinkReplacements($content, $masks, $pcre_masks); 180 181 // Complete the replacements array 182 $interwiki = sfConfig::get('app_nahoWikiPlugin_interwiki', array()); 183 $web_root = sfContext::getInstance()->getRequest()->getRelativeUrlRoot(); 184 $dir_root = sfConfig::get('sf_web_dir'); 185 $plugin_dir = '/nahoWikiPlugin/images/'; 186 foreach ($replaces as &$replace) { 187 list($key, $name) = explode('>', $replace['name'], 2); 188 if (isset($interwiki[$key])) { 189 $replace['link'] = $interwiki[$key] . rawurlencode($name); 190 if ($replace['link']) { 191 $replace['alttext'] = $key; 192 $key = strtolower($key); 193 if (is_file($dir_root . ($image = $plugin_dir . 'interwiki/' . $key . '.png'))) { 194 $replace['image'] = $web_root . $image; 195 } elseif (is_file($dir_root . ($image = $plugin_dir . 'interwiki/' . $key . '.gif'))) { 196 $replace['image'] = $web_root . $image; 197 } elseif (is_file($dir_root . ($image = $plugin_dir . 'interwiki/' . $key . '.jpg'))) { 198 $replace['image'] = $web_root . $image; 199 } else { 200 $replace['image'] = $web_root . $plugin_dir . 'interwiki.png'; 201 } 202 } 203 if (!$replace['title']) { 204 $replace['title'] = $name; 205 } 206 } 207 } 208 209 $link_model = sfConfig::get('app_nahoWikiPlugin_interwiki_link_model', '[ %title%](%link%)'); 210 211 return self::makeLinkReplacements($content, $replaces, $link_model); 212 } 213 214