DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:nspages

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:nspages [2018-05-28 19:51] – [Installation] Klap-inplugin:nspages [2024-03-07 19:33] (current) – Tested OK with Kaos dregad
Line 6: Line 6:
 email      : guillaume.turri@gmail.com email      : guillaume.turri@gmail.com
 type       : Syntax type       : Syntax
-lastupdate : 2018-05-20 +lastupdate : 2024-01-04 
-compatible : 2017-02-19, 2016-06-26a, 2009-12-25, Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky, ponder stibbons, HrunDetritusGreebo+compatible : IgorJack JackrumKaos+
 depends    :  depends    : 
 conflicts  conflicts 
Line 19: Line 19:
 ---- ----
  
-===== Description =====+//**If your Dokuwiki instance is older than the release "Igor - 2022-07-31" you should use the version available [[https://github.com/gturri/nspages/zipball/last_before_igor|here]] (and NOT update it afterward), because subsequent versions of the plugin won't be compatible)**// 
 This plugin nicely displays a table of content of the pages -and optionally the subnamespaces- of a given (sub)namespace. This plugin nicely displays a table of content of the pages -and optionally the subnamespaces- of a given (sub)namespace.
 +
 +If you're discovering this plugin and want to have a glimpse at what you can do with it, the first section, which shows some common usages, is made for you
 +
 +If you're interested in understanding all the options, in order to use it to best fit your needs, you may want to jump directly to the 2nd section.
 +
 +=====Some examples and common usages=====
 +
 +====The very first steps====
  
 Using this plugin is easy: just write Using this plugin is easy: just write
   <nspages>   <nspages>
-and see the result. (You may also use the button {{http://img190.imageshack.us/img190/6845/tbnspages.png?nolinking}} from the toolbar.)+(You may also use the button {{http://img190.imageshack.us/img190/6845/tbnspages.png?nolinking}} from the toolbar.) 
 + 
 +You will get a list of your pages displayed in columns, like this: {{https://turri.fr/nspages_img/nspages_standard.png?nolinking&500}} 
 + 
 +If you're interested in the list of the namespaces instead of the list of pages, try this: 
 +  <nspages -subns -nopages> 
 + 
 +====Pictures!==== 
 + 
 +Now let's do something more colorful: if you have pictures in your pages you can do this: 
 +  <nspages -usePictures> 
 +it will represent each page using their first picture, like this: 
 + 
 +{{https://turri.fr/nspages_img/nspages_pictures.png?nolinking&300}} 
 + 
 +====Tree==== 
 + 
 +One last example: instead of displaying the content of a single namespace, let's display a hierarchy of pages as a tree. For the hype, let's use a whole bunch of options together (you can look at the next section in order to understand what each of those option does): 
 +  <nspages -tree -r -exclude -subns -pagesInNs -h1 -textNs="All my content as a tree!"> 
 +Bam, you get a tree like this: 
 + 
 +{{https://turri.fr/nspages_img/nspages_tree.png?nolinking&250}} 
 + 
 +This was just to get you started. This plugin is highly configurable and has a lot more features we haven't mentioned yet (other ways to display pages, to filter out some pages, to display pages with another order, ...). The next section gives all the details 
 + 
 +=====Manual=====
  
 The general syntax is The general syntax is
Line 35: Line 69:
 |  <code>-subns</code>  |displays the subnamespaces of the selected namespace (and provide links to their main page) | |  <code>-subns</code>  |displays the subnamespaces of the selected namespace (and provide links to their main page) |
 |  <code>-nopages</code>  |do not list the pages of the selected namespace (of course this option is useful only if you use ''-subns'') | |  <code>-nopages</code>  |do not list the pages of the selected namespace (of course this option is useful only if you use ''-subns'') |
-|  <code>-exclude:nameOfPage</code>  |won't include the page nameOfPage. This option may be use several times in order to exclude several pages |+|  <code>-exclude:nameOfPage</code>  |won't include the page nameOfPage. This option may be used several times in order to exclude several pages |
 |  <code>-exclude:subNs:</code>  |won't include the subnamespace subNs. This option may also be used more than once | |  <code>-exclude:subNs:</code>  |won't include the subnamespace subNs. This option may also be used more than once |
 |  <code>-exclude</code>  |won't include the current page | |  <code>-exclude</code>  |won't include the current page |
 |  <code>-h1</code>  |will display the first h1 title found. If a page doesn't contain such a title, the name of the page  is used instead | |  <code>-h1</code>  |will display the first h1 title found. If a page doesn't contain such a title, the name of the page  is used instead |
-|  <code>-textPages="some text"</code>  |//some text// will be displayed instead of the default text, to introduce the pages list |+|  <code>-textPages="some text"</code>  |//some text// will be displayed instead of the default text, to introduce the pages list. i.e. changes the "Pages in this namespace" text. Set to ''%%=""%%'' to remove. |
 |  <code>-textNS="some text"</code>  |//some text// will be displayed instead of the default text, to introduce the namespaces list | |  <code>-textNS="some text"</code>  |//some text// will be displayed instead of the default text, to introduce the namespaces list |
 |  <code>-title</code>  | alias of ''-h1'' | |  <code>-title</code>  | alias of ''-h1'' |
Line 46: Line 80:
 |  <code>-simpleLine</code>  | display the list on a single line (incompatible with ''-simpleList'') | |  <code>-simpleLine</code>  | display the list on a single line (incompatible with ''-simpleList'') |
 |  <code>-simpleLineBreak</code>  | display the list on a single column, separated only by line breaks (incompatible with the previous flags) | |  <code>-simpleLineBreak</code>  | display the list on a single column, separated only by line breaks (incompatible with the previous flags) |
-|  <code>-usePictures</code>  | display the first image of each page  |+|  <code>-usePictures</code>  | display the first image of each page. (Note that you can include a 1x1 pixel size image as the 1<sup>st</sup> picture on a page if you want this page to be represented by this image in a nspages TOC.)  | 
 +|  <code>-tree</code>  |  group the items per namespaces. To be used with the ''-r'' flag. Eg: <code><nspages -r -subns -nopages -tree></code>  |
 |  <code>-nbCol=3</code>  | Change the number of columns to use (default is ''3'' | |  <code>-nbCol=3</code>  | Change the number of columns to use (default is ''3'' |
 |  <code>-sortId</code>  | Sort the pages according to their id, even if ''-title'' is used | |  <code>-sortId</code>  | Sort the pages according to their id, even if ''-title'' is used |
Line 54: Line 89:
 |  <code>-naturalOrder</code>  | Sort the pages in [[http://stackoverflow.com/q/5167928/1796345|natural order]] | |  <code>-naturalOrder</code>  | Sort the pages in [[http://stackoverflow.com/q/5167928/1796345|natural order]] |
 |  <code>-sortByDate</code>  | Sort the pages by date of last modification | |  <code>-sortByDate</code>  | Sort the pages by date of last modification |
 +|  <code>-displayModificationDates</code>  | Prefix the pages by the date of their last modification |
 |  <code>-sortByCreationDate</code>  | Sort the pages by date of creation |  |  <code>-sortByCreationDate</code>  | Sort the pages by date of creation | 
 |  <code>-pagesInNs</code>  | The pages will appear among the namespaces | |  <code>-pagesInNs</code>  | The pages will appear among the namespaces |
-|  <code>-r</code>  | recurse : display elements of the subnamespaces. You may use just ''-r'' to check every subnamespace, or e.g. ''-r=3'' to have a depth limit to 3 levels  |+|  <code>-r</code>  | recurse : display the pages of the subnamespaces (if used with "-subns" it will display the sub-subnamespaces). You may use just ''-r'' to check every subnamespace, or e.g. ''-r=3'' to have a depth limit to 3 levels  |
 |  <code>-exclude:[page1 subNs: page2]</code>  |an easier syntax to exclude several pages/subnamespaces| |  <code>-exclude:[page1 subNs: page2]</code>  |an easier syntax to exclude several pages/subnamespaces|
 |  <code>-pregPagesOn |  <code>-pregPagesOn
Line 75: Line 111:
 |  <code>-defaultPicture</code>  |Specify the picture to display when -usePictures is used and a page doesn't contain any picture. Can be used to point at either a local file (<code>-defaultPicture="{{:my:picture.png}}"</code>) or remote one (<code>-defaultPicture="https://some/picture.png"</code>)| |  <code>-defaultPicture</code>  |Specify the picture to display when -usePictures is used and a page doesn't contain any picture. Can be used to point at either a local file (<code>-defaultPicture="{{:my:picture.png}}"</code>) or remote one (<code>-defaultPicture="https://some/picture.png"</code>)|
 |  <code>-showhidden</code>  |Include pages that are normally excluded from search with the [[config:hidepages|hidepages]] config parameter.  Useful for creating table of contents for hidden namespaces.| |  <code>-showhidden</code>  |Include pages that are normally excluded from search with the [[config:hidepages|hidepages]] config parameter.  Useful for creating table of contents for hidden namespaces.|
 +|  <code>-dictionaryOrder="<locale>"</code>  |Sort according to the locale specified (see the [[http://php.net/manual/en/function.strcoll.php|doc]]). Example of usage: <code>-dictionaryOrder="sk_SK"</code>|
 +|  <code>-customTitle="[{date.created}] {title} by {user}"</code>  |Use a custom format to display the title, replacing {xxx} with the associated metadata. See [[#option_-customtitle|below]] for more explanations|
 +|  <code>-includeItemsInTOC</code>  |Also displays the pages in the table of contents generated by Dokuwiki (the one which appears on the top right of each page with the default template)|
 +|  <code>-sortByMetadata="date.created"</code>  |Sort the pages using the given metadata. (it can be used along with option -reverse)|
 +|  <code>-sidebar</code>  |You should use this if you use nspages to display a dynamic list of items in a sidebar. See [[#option_-sidebar|below]] for more information|
  
 ex: ''<nspages path_to_a_namespace -exclude>'' or ''<nspages -subns -nopages>'' will work. ex: ''<nspages path_to_a_namespace -exclude>'' or ''<nspages -subns -nopages>'' will work.
Line 81: Line 122:
  
 Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually. Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
 +
 +=====Option -customTitle=====
 +
 +//(Because the array above is too concise to give all the details about this option)//
 +
 +This option accepts a string as an argument. The name of the pages will be displayed using this format. The {xxx} part are replaced by the metadata of the page.
 +
 +For instance
 +
 +  <nspages :my-namespace -customTitle="[{date.created}] {title} by {user}">
 +
 +could display:
 +
 +  * [1613513556] <Title of page 1> by Stancu
 +  * [1624663245] <Title of page 2> by Guillaume
 +
 +Some important details about this option:
 +  * Nspages will render by default only the metadata //title//, //user//, and //date.created//. Admins can configure it to accept more metadata. The reason to not allow everything by default is to ensure this feature won't leak private information (for instance allowing to display the IP of the editors would be a bad idea on a public wiki)
 +  * The list of metadata available by default in Dokuwiki is available in the [[https://www.dokuwiki.org/devel:metadata|documentation]]
 +  * It can be use along with other plugins that adds support for custom metadatas (like the [[https://www.dokuwiki.org/plugin:meta|meta plugin]]). (Don't forget to add those other metadata in the accept-list of nspages)
 +
 +===== Option -sidebar =====
 +
 +DokuWiki supports [[faq:sidebar|sidebars]] out of the box.
 +
 +Here is an example of sidebar generated with nspages:
 +
 +{{https://turri.fr/nspages_img/nspages_sidebar.png?nolinking&300&recache}}
 +
 +To get this sidebar I just put
 +  <nspages -simpleList -h1 -sidebar>
 +on the page '':sidebar'' of my instance of DokuWiki.
 +
 +The tricky part is that since I do not specify a namespace then I expect nspages to consider the namespace of the current page. But by default nspages will consider that the current page is '':sidebar'' (because it is where it is defined), whereas want makes sense to me is that the current page is interpreted as the page that I'm currently browsing.
 +
 +That's the point of the ''-sidebar'' option. In practice it:
 +  * tells nspages that the "current page" should be interpreted as the page currently browsed
 +  * does not cache the resolution of the resolution of the namespace (because it may change at every page that I browse)
 +(a consequence is that it makes no sense to both specify a namespace and have the ''-sidebar'' option, so that case will just display an error)
 +
 +**To put it in a nutshell**: it you use nspages to generate a sidebar, then you should add the ''-sidebar'' option
  
 ===== Some (important) points ===== ===== Some (important) points =====
-  * With version older than 2014-08-10, you should put %%~~NOCACHE~~%% in the pages where you use this plugin, to make sure that if you create or remove a page in the namespace, it will be taken into account. Now, nspages automatically deactivate the cache on the pages where it is used (you can deactivate this behaviour on the admin panel). + 
-  * The CSS sheet should be taken into account in order for this plugin to work correctly; but because of the cache system it may not be the case the first time you use this plugin (even if %%~~NOCACHE~~%% is specified). The easier way to resolve this is to make sure your cache is invalidated by touching ''conf/local.php'' (eg. by resaving your configuration) +  * With version older than 2014-08-10, you should put ''%%~~NOCACHE~~%%'' in the pages where you use this plugin, to make sure that if you create or remove a page in the namespace, it will be taken into account. Now, nspages automatically deactivate the cache on the pages where it is used (you can deactivate this behaviour on the admin panel). 
-  * Currently, you may not use a '>' in the ''-textPages'' and ''-textNS'' options, since it is understood as the end of the <nspages> tag+  * The CSS sheet should be taken into account in order for this plugin to work correctly; but because of the cache system it may not be the case the first time you use this plugin (even if ''%%~~NOCACHE~~%%'' is specified). The easier way to resolve this is to make sure your cache is invalidated by touching ''conf/local.php'' (eg. by resaving your configuration) 
 +  * Currently, you may not use a ''>'' in the ''-textPages'' and ''-textNS'' options, since it is understood as the end of the <nspages> tag
   * When you change the default markup inserted by the toolbar button (throught the admin dashboard), you may need to purge your caches to have this change taken into effect (see also the [[https://github.com/gturri/nspages/issues/23|bug report]]):   * When you change the default markup inserted by the toolbar button (throught the admin dashboard), you may need to purge your caches to have this change taken into effect (see also the [[https://github.com/gturri/nspages/issues/23|bug report]]):
     * [[:caching#purging_the_cache|Clean the cache]] of you DokuWiki      * [[:caching#purging_the_cache|Clean the cache]] of you DokuWiki 
     * Force your browser to reload it's cache, typically by pressing Ctrl+F5, or Shift+F5     * Force your browser to reload it's cache, typically by pressing Ctrl+F5, or Shift+F5
  
-=====Charityware=====+===== Charityware ===== 
 nspages is a personal open source project started in 2008. I have put hundreds of hours to maintain and enhance it. nspages is a personal open source project started in 2008. I have put hundreds of hours to maintain and enhance it.
  
-It is provided as a [[https://en.wikipedia.org/wiki/Charityware|charityware]]. It can be downloaded and installed at no charge. If you found it useful and would like to support its development, you may make a donation to a non-profit charitable organization.+It is provided as a [[wp>Charityware|charityware]]. It can be downloaded and installed at no charge. If you found it useful and would like to support its development, you may make a donation to a non-profit charitable organization.
  
-====To who==== +==== To who ==== 
-The preference goes to the [[https://support.worldwildlife.org/site/SPageServer?pagename=main_onetime|World Wildlife Fund]] (WWF) because the are both protecting biodiversity and fighting climate change effectively.+Any NGO acting for the environment.
  
-If it isn't possible, any association acting for the environment would do the trick.+==== How ====
  
-====How==== 
 Forwarding me (address available at the top of the page) the confirmation email you send or receive will ensure your kind gesture will motivate me to continue developing this software. Forwarding me (address available at the top of the page) the confirmation email you send or receive will ensure your kind gesture will motivate me to continue developing this software.
  
  
-====I can't give money====+==== I can't give money ==== 
 Making sure you have a positive impact would already be awesome: Making sure you have a positive impact would already be awesome:
   * Volunteer to an NGO near you. Give some of your time   * Volunteer to an NGO near you. Give some of your time
-  * Ride you bike instead of taking your car +  * Reduce your meat and plane consumption 
-  * Buy local organic food+  * Ride your bike instead of taking your car
   * Use a reusable bag and stop using plastic straws   * Use a reusable bag and stop using plastic straws
   * Plant trees   * Plant trees
   * Take only what you need, not what you can   * Take only what you need, not what you can
  
plugin/nspages.1527529897.txt.gz · Last modified: 2018-05-28 19:51 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki