Wiki / Pages Addon

Project:ProjectPier
Version:0.8.5.0-Beta1
Component:Code
Category:feature request
Priority:normal
Assigned:Alex.
Status:patch - code needs review
Description

Hi,
I'm currently developing a wiki / pages addon for Projectpier, which will allow you to create pages for projects.

It's currently a little basic, but usable - you can add, edit and delete pages(Though only admins can delete pages). Each modification of a page creates a new revision.

Revisions can't be restored yet, but you can view the history for a page by clicking on the 'Page History' link.

To view a specific revision for a page, click the revision number in the page's history.

You can also create a default wiki index page, and sidebar page.

I'm not going to create a patch for it until I'm satisfied that it works ok, and that the code is up to scratch(ish).

If you want to test the code, then you can try out the demo:
http://projectpier.sigswitch.com

User / Password:
Test/test
Test2/test2

I update the demo once or twice a day, so it's pretty much always up to date.

If you could test it out and give me feedback on it then I'd be much appreciated :)

Alex

How do I get the list of the existing pages? Not implemented yet I suppose. It makes the demo a little disconcerting for now :) (nevermind, see below)

I noticed a little bug here:
http://projectpier.sigswitch.com/index.php?c=wiki&a=history&id=8&active_...
One could tell you copied your stuff from the messages pages by looking at the tabs.

You should add the Textile handling too.

I don't think I like the fact that "Add page" is as the same level as "Edit page" and "View page history". One is general to the Wiki module while the others are for the current page. It's not that it doesn't make sense and that I get confused (thanks for asking :)), just that I think they should be in different places. Maybe the add page could be in the sidebar (with the list of current pages?).

Can you explain the reasons behind allowing a page to be the sidebar?

below: Oh ok, nevermind, I just removed the wikipage as the sidebar and saw the list of pages created...


How do I get the list of the existing pages? Not implemented yet I suppose. It makes the demo a little disconcerting for now :) (nevermind, see below)

:)

I noticed a little bug here:
http://projectpier.sigswitch.com/index.php?c=wiki&a=history&id=8&active_...
One could tell you copied your stuff from the messages pages by looking at the tabs.

You have sharp eyes!
I was using the messages page as a template for the pagination ;)

You should add the Textile handling too.

In time, though my priority is to give it some more wiki functionality before the aesthetic stuff.

I don’t think I like the fact that “Add page” is as the same level as “Edit page” and “View page history”. One is general to the Wiki module while the others are for the current page.

Yeah good point. At the moment it's like that because that's the action bar, it's not a priority, but if you have a suggestion as to where it could go, I'd be more than happy to move it.

It’s not that it doesn’t make sense and that I get confused (thanks for asking :))

:p


Just that I think they should be in different places. Maybe the add page could be in the sidebar (with the list of current pages?).

Possibly, though as you can modify the sidebar, you could easily add an 'add page link'


Can you explain the reasons behind allowing a page to be the sidebar?

I wasn't sure that most companies would want a link to every single page in their sidebar (I imagine it could get quite long!), so I chose to give people the option of creating their own customised sidebar, and to keep it simple I merely made a page specifically for the sidebar.
As you've noticed, the default sidebar has a page list, and the language entries can be customised so as to make the sidebar more specific to the company.

Maybe in the future you will be able to customise the content and have an automatically generated list of pages too.


below: Oh ok, nevermind, I just removed the wikipage as the sidebar and saw the list of pages created…

:)

Ok, textile is now in there and you can now revert to revisions :)

Comparison of revisions in a diff style is now possible, though I'm having trouble getting the form on the page history page to redirect to the diff page :-/

If you want to try it out, then visit:

index.php?c=wiki&a=diff&active_project=1&id={PAGE_ID}&rev1={FIRST_REV}&rev2={SEC_REV}

Filling in the place holders with the page id etc.

Also, there is now a confirmation page to delete wiki pages

Title:Wiki / Pages Addon» Wiki / Pages Addon - Patch now released!
Status:open - assigned» patch - code needs review

Ok, I am now going to release a patch for this PP hack.
I am not entirely happy with all of the code (mainly the wiki page url generation / wiki views), but I feel that it is sufficent for community testing.
Some parts of the files may not respect all of PP's coding guidelines (The code indentation *should* be the only problem - I have tried to use a tab size of two where possible, but there may be the odd outlier) but are good enough to use. I have also used a code beautifier on the diff files so they *should* be ok, but as we all know, beautifiers don't always do what they're supposed to do :p .
Doc comments have been added to pretty much every function, though they might need a little bit of modification

Credits:

  • phpBB / PEAR - The diff library is taken from phpBB, who borrowed it from PEAR (GNU / LGPL)

Features:

  • Can add pages
  • Can edit pages
  • Can delete pages
  • Creates a revision for each page edit
  • Can view the revision history of a page
  • Can set a page as the wiki index
  • Can create a 'sidebar' wiki page, or use the default which lists all the pages in your wiki
  • Can view individual revisions of a page
  • Can compare different revisions of a page using inline diff
  • Formats wiki pages using Textile formatting
  • Can dynamically link to pages by using the tag: [wiki:{PAGE_ID}] which will automatically be converted to a Textile link with the wiki page's name for the title
  • Project logs entries are created for editing, adding and deleting pages
  • Confirmation required to delete a page
  • Allows for revision log messages
  • The page's name should appear in the breadcrumb when you are either viewing it, its revision history, editing it or comparing two of its revisions

Permissions:

  • Project users can view pages
  • Members of owner company can edit pages
  • Admins can delete pages

Roadmap(Priority Descending):

  • Allow admins to 'lock' pages to prevent editing / changing status of wiki index / sidebar
  • Create a dynamic index of pages
  • Require password confirmation to delete a page
  • Allow wiki pages to be tagged (This functionallity is already there, but has not been tested)
  • Add hooks for the plugin system
  • Allow page titles to be used as page identifiers

As always, I appreciate ANY feedback / issues you have :)

I've uploaded this patch to the demo server, so you can try it there if you don't want to install the patch:

http://projectpier.sigswitch.com
Username / Password:
Test / test
Test2 / test2

Alex

AttachmentSize
wikipatch_r154.patch109.66 KB

This new patch fixes a few major problems with the old patch (which didn't have the Revision model or wiki helper included)

I have briefly installed & tested this patch, so it should work fine.

Feedback & issues appreciated!

Alex

AttachmentSize
wiki_200804081720_r154.patch112.24 KB

I really like your patch.

- About the sidebar page :
When adding a new page, I find the "Set as project sidebar?" option not useful as there will only be one sidebar page. When someone wants to change it, he'll just directly click on the "edit" button.

- About linking pages :
I tried to follow the syntax in your source code for Wiki-style links but it doesn't work. Is it implemented yet ? This is a pretty important feature for a Wiki.

Thanks for your work !!

Thanks for trying it out :)
- About the sidebar page :
When adding a new page, I find the "Set as project sidebar?" option not useful as there will only be one sidebar page. When someone wants to change it, he'll just directly click on the "edit" button.

By default there isn't a wiki sidebar in the DB, so to make one you have to create a new page hence the option.
It also gives people the option of switching between different pages for the sidebar(Not quite sure why they'd want to do it though..)


- About linking pages :
I tried to follow the syntax in your source code for Wiki-style links but it doesn't work. Is it implemented yet ? This is a pretty important feature for a Wiki.

I was discussing this problem with some people in IRC the other day.
The actual making the link part works perfectly(afaik). It's just that the url is escaped twice (by escaped I mean, & => &) so instead of a url looking like this:

http://www.site.com/index.php?c=wiki&c=view&id=1

Like it is supposed to, it looks like this:

http://www.site.com/index.php?c=wiki&c=view&id=1

I'll put up a new patch when I get some time

Thanks for your work !!
Thanks, I'm glad I can give something back :)

Version:<none>» 0.8.5.0-Beta1

The patch has now been updated:

This release fixes the following issues

  • Wiki links do not work properly
  • When comparing two identical versions, all you see is a blank screen
  • Wiki allows you to compare two instances of the same version
  • Some parts of the edit page aren't localised
  • There are a few typo's in the edit view
  • Undefined index 'tags' when editing
  • New features in this update:

  • Wiki pages can now be locked to prevent editing
  • Wiki pages are now searchable
  • New Permissions in this update:

  • Administrators can (un)lock pages
  • AttachmentSize
    wiki_b200804271405_r154.patch119.64 KB
Title:Wiki / Pages Addon - Patch now released!» [Urgent] Wiki / Pages Addon - Security patch released

The patch has now been updated:
This patch fixes the following issues:

  • Users could view the wiki index page of projects they weren't assigned to
  • Calling none static method as static in add()
AttachmentSize
wiki_b200805031736_r154.patch119.91 KB

The latest patch needs to be generated with the --strip-trailing-cr option.

First - thank you! Great add-on. Couldn't do without it.

A few problems (using the latest patch with projectpier svn r159):

* If I create a page, add a link to it in another page (using [wiki:n]) and then change the name of the first page, the name shown in the link doesn't change.

* When creating a new page I always get an error. Hitting "Back" takes me to the edit view for the new page.

Warning: Missing argument 1 for ProjectDataObject::setTagsFromCSV(), called in .../projectpier/application/controllers/WikiController.class.php on line 260 and defined in .../projectpier/application/models/ProjectDataObject.class.php on line 305

Notice: Undefined variable: input in .../projectpier/application/models/ProjectDataObject.class.php on line 307

Warning: Cannot modify header information - headers already sent by (output started at .../projectpier/application/models/ProjectDataObject.class.php:305) in .../projectpier/environment/functions/general.php on line 323

* This may not be strictly a problem with the Wiki plugin, but anyway... The Textile renderer is broken. It fails to recognize many valid Textile tags. Using the same markup at http://textism.com/tools/textile/index.php results in a perfect rendering.

Correction to my last post...

The Textile renderer isn't at fault - the problem is that symbols in the text are quoted before the markup is processed, and this disables a lot of tags.

Is there anything that can be done about this?

The latest patch needs to be generated with the --strip-trailing-cr option.
I've tried to do this but I'm getting an error (can't remember it off the top of my head). Please can you give me an example of the syntax?

First - thank you! Great add-on. Couldn't do without it.
I'm glad you like it :)

* If I create a page, add a link to it in another page (using [wiki:n]) and then change the name of the first page, the name shown in the link doesn't change.
Thanks for reporting this, I'll fix it when I get home

* When creating a new page I always get an error. Hitting "Back" takes me to the edit view for the new page.
I thought I'd commented it out - I'll fix that when I get home too.

The Textile renderer isn't at fault - the problem is that symbols in the text are quoted before the markup is processed, and this disables a lot of tags.
I'm not sure why this is happening - I'm pretty sure textile works fine on my dev copy.

Please can you paste here / email me the page you are trying to post, as well as a screenshot of what the 'garbled' page looks like.

Alex

Title:[Urgent] Wiki / Pages Addon - Security patch released» Wiki / Pages Addon

This release fixes the following issues:

  • #15 Error while trying to create a page
  • #15 Wiki links do not reflect title changes

Sorry if I confused / annoyed some folks with the [Urgent] tag - it seemed pretty urgent at the time!

Alex

AttachmentSize
wiki_200805211941_159.patch120.24 KB

Great work Alex and thanks again for the contribution. It would be nice to get this into the core release soon.

FYI:
the base URL into your test site is presenting a db error, after login.
http://projectpier.sigswitch.com/

However, the direct links work ok, for example:
http://projectpier.sigswitch.com/index.php?c=wiki&a=view&active_project=1&id=1

-- Dan

Thanks for trying it out - it's always nice to get feedback :)
I have not got round to updating the demo, so it's still a few versions behind, and the db itself is a version or two behind the code.

I'll try and update it today if I get time

Just an image for wiki

Hi Alex. After upgrading to 0.8.0.3 wiki tab disappeared so i tried patching the new version and it got worse, now i cannot even see wiki pages. Is this tested with 0.8.0.3?

thank you!

mcongosto
It was done against the trunk which as far as I remember is >= 0.8.3, so it should work fine. Why can't you see wiki pages? Are there any errors?

There are only two core file edits - one is to the installer sql, and the other is to application/helpers/project_website.php , which makes the wiki tab show up
That edit is as follows:

===================================================================
--- application/helpers/project_website.php (revision 159)
+++ application/helpers/project_website.php (working copy)
@@ -28,6 +28,7 @@
   define('PROJECT_TAB_TAGS', 'tags');
   define('PROJECT_TAB_FORMS', 'forms');
   define('PROJECT_TAB_PEOPLE', 'people');
+  define('PROJECT_TAB_WIKI', 'wiki');

   /**
   * Prepare dashboard tabbed navigation
@@ -66,6 +67,11 @@
       lang('tags'),
       get_url('project', 'tags')
     ));
+    add_tabbed_navigation_item(new TabbedNavigationItem(
+      PROJECT_TAB_WIKI,
+      lang('wiki'),
+      get_url('wiki')
+    ));
     if (logged_user()->isAdministrator()) {
       add_tabbed_navigation_item(new TabbedNavigationItem(
         PROJECT_TAB_FORMS,

Try deleting all of the files created by the patch, and then repatching it

@andypost: thanks very much, I'll try and include it in my next patch :)

@Alex Have you seen http://www.projectpier.org/node/847

Wiki as plugin, so maybe go in this direction?

Yes I have seen it, however I'm reluctant to make this a plugin "officially" until the plugin system is part of the core. Otherwise people will have to install the plugin system just to use it

Version:0.8.5.0-Beta1» 0.8.0.3

Hi Alex, just wondering but Im already using projectpier. To install this would I have to start from scratch?? (Im working on a project for University so I dont really want to start over again..)

Thanks for the great addition, hope to hear from you soon..

Version:0.8.0.3» 0.8.5.0-Beta1

back to version 0.8.5.x

Sycren, we use 0.8.5.x-dev for all issues and features in development. The Wiki add-on is not part of the 0.8.0.3 release.

Thanks.

Thanks Tim,
Sycre - it is possible to use this without reinstalling pp, although to do it you will need to replace your files with those from the svn repo.

If you have made any modifications to the files I would make a note of them before you go any further.

  1. Backup ALL your files to a secure location (
    to make sure you don't accidentally delete them), in case something goes wrong with the upgrade.
  2. Delete all your files on the webserver
  3. Checkout a copy of the repo (https://projectpier.svn.sourceforge.net/svnroot/projectpier/ProjectPier/Trunk) into your pp folder (Take a look at this tutorial if you don't know how to do that)
  4. Setup config/config.php to mirror what your original config/config.php looked like
  5. Apply the patch (Refer to TortoiseSVN's help file if you don't know how to apply patches)
  6. Using PHPMyAdmin, execute the following sql:
    CREATE TABLE  `pp_wiki_pages` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `revision` int(10) unsigned default NULL,
      `project_id` int(10) unsigned default NULL,
      `project_sidebar` tinyint(1) unsigned default '0',
      `project_index` tinyint(1) unsigned default '0',
      `locked` tinyint(1) default '0',
      `locked_by_id` int(10) unsigned default NULL,
      `locked_on` datetime default '0000-00-00 00:00:00',
      PRIMARY KEY  (`id`)
    ) TYPE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    CREATE TABLE `pp_wiki_revisions` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `project_id` int(10) unsigned default NULL,
      `page_id` int(10) unsigned default NULL,
      `revision` tinyint(3) unsigned default NULL,
      `name` varchar(50) collate utf8_unicode_ci NOT NULL,
      `content` text NOT NULL,
      `created_on` datetime default NULL,
      `created_by_id` int(10) unsigned default NULL,
      `log_message` varchar(255) default NULL,
      PRIMARY KEY  (`id`)
    ) TYPE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    If you use a table prefix other than pp_ then you should do a search ('pp_') and replace ('') on the above sql

  7. Carry over any other changes that you'd made to your original installation

And then you should be ready to go!

Post here if you have any problems

Sorry, what I dont understand is that... must I back up all the messages and files by just copying the folders to another location? How would I be able to get what I have back? Just by copying them back again?

No, the messages and tasks are stored in the database. When I talked about copying the files, I was talking about copying files (.php files etc.) that you've modified. e.g. the config/config.php file (Which contains the information pp needs to connect to the database). Or if you've modified one of the templates slightly, that sort of thing.

I have added a link to all pages list (like default sidebar list), so you can get all pages list even with a custom sidebar.

Also I have added internal links using name instead of id. When there is no page with that name a ? is shown linking to add a page with that name. So name is not editable with this patch.

AttachmentSize
proyectos_wiki_links_by_name.patch4.86 KB
proyectos_wiki_all_pages.patch4.88 KB

Hey sergio,
Thanks for the contribution, just a couple of points on it though:

  • The patch has been done from outside of the pp root directory (the path to index.php should be application/controllers/WikiController.class.php, not proyectos/application/controllers/WikiController.class.php)
  • Your patch also edits some language files which aren't included in the main wiki patch
  • I like the idea of linking by title, but currently wiki titles are not unique so there could be a few problems with that.

Thanks for the contribution,

Alex

1. I was working on a downloaded projectpier, so I can't use svn diff. I copied projectpier directory before modify it, and I used 'diff -urN old_dir new_dir'. You can run 'patch -p1 < patch_file' to apply it.

2. I forgot to remove spanish language files. I attach fixed patches.

3. I forgot to force unique names for pages. I will fix it.

AttachmentSize
proyectos_wiki_links_by_name.patch4.41 KB
proyectos_wiki_all_pages.patch4.29 KB

Ok sorry about that.
Here's a patch that includes sergio's all_pages patch.

andy: I really wanted to include your image in this patch, but due to the way the svn repo works I'd have to create a separate branch against the default theme repo and then I'd need to create an issue in the default theme tracker, which seems kind of pointless when this isn't even part of the core *takes a deep breath* =/

AttachmentSize
pp_wiki_2008-11-21_17-56_162.patch122.8 KB

@Alex: Is wiki a separate addition to current version of PP or plugin-way?
Suppose if wiki a plugin so image should be included in plugin css|files
but if wiki a part of core so image and css style should stored in public/.../themes

So what are the way of wiki plugin?

As there's currently no 'official' plugin system I'm reluctant to package this exclusively as a plugin. If people want to convert it to a plugin then that's fine by me (it would require about 3 small file edits).

I agree that this patch *should* include the image, however because the default theme isn't in the trunk my patch can't include it. If this makes it to the core then I think it'd be much easier for Ryan to just manually add the image to the default theme.

I've got no ssh access to the webserver I'm working on right now, so it's difficult to apply a .patch file. I've got a brand new installation of ProjectPier - no users yet - so I'm not worried about screwing it up. Would it be possible for someone to simply post .zip or tar.gz file of the various php files after-patch, that I can upload and overwrite the current ProjectPier files with? As I said, there's nothing to screw up at this point, and it'd sure beat applying the changes by hand. I'd be heavily in your debt.

I'd recommend installing tortoisesvn locally(on your computer), checking out a copy of the trunk and applying the patch on it.

You can then upload the files to your website (though you'd need to change your ftp program so that it ignores .svn folders)

This is how I have winscp setup:

here

You'll also need to run the installer sql:

CREATE TABLE  `pp_wiki_pages` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `revision` int(10) unsigned default NULL,
  `project_id` int(10) unsigned default NULL,
  `project_sidebar` tinyint(1) unsigned default '0',
  `project_index` tinyint(1) unsigned default '0',
  `locked` tinyint(1) default '0',
  `locked_by_id` int(10) unsigned default NULL,
  `locked_on` datetime default '0000-00-00 00:00:00',
  PRIMARY KEY  (`id`)
) TYPE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `pp_wiki_revisions` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `project_id` int(10) unsigned default NULL,
  `page_id` int(10) unsigned default NULL,
  `revision` tinyint(3) unsigned default NULL,
  `name` varchar(50) collate utf8_unicode_ci NOT NULL,
  `content` text NOT NULL,
  `created_on` datetime default NULL,
  `created_by_id` int(10) unsigned default NULL,
  `log_message` varchar(255) default NULL,
  PRIMARY KEY  (`id`)
) TYPE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

And you should be good to go

Thanks a ton, Alex. Your suggestion was excellent - wouldn't have thought of doing it that way. Everything went smoothly, though, and the wiki's up and running. A sidenote - I use a Mac, so TortoiseSVN wasn't an option. The subclipse plugin for Eclipse IDE is a nice alternative for Mac users - in case anyone has the same issue in the future.

Category:feature request» support request

I'm sorry if this sounds ignorant, but I have no idea how I would install this. Do you have any documentation on how to do this?

Category:support request» feature request

Please don't change the category :)

First you should Follow this tutorial until it tells you to install the trunk

Then download the last patch I attached, right click on your copy of the pp trunk and go to tortoise svn -> apply patch

Browse to where you downloaded the patch file and click it.

Tortoise svn will then open a new window with two panes, and a list of files on the left hand side. Right click one of the files and select patch all files.

Now install pp

Title:Wiki / Pages Addon» Wiki / Pages Addon displaying blank Page

I have been following the wiki patch for awhile. Just got around to applying. Patch goes fine from Terminal, however when clicking on the wiki tab within a project I get a plain white page. Tested in Firefox, safari, and ie., same result. There are no errors, just blank page. I have limited code experience and as such couldn't troubleshoot on my own.

On a separate note, does anyone know whats going on with the development of pp? I've been between opengoo and pp and I am leaning towards pp, but opengoo has a far more active update/developer timeline.

Title:Wiki / Pages Addon displaying blank Page» Wiki / Pages Addon

Apologizes on changing the issue title. Had to add new comment to correct it....

oops.

Please can you enable debug in the config file and paste what comes up / appears in the log file

This is what I'm getting when I click the tab after updating debug.

Fatal error: Cannot redeclare class WikiController in /home/darkcor1/public_html/projectpier/application/controllers/WikiController.class.php on line 571

Here is more help i would assume...

If you're getting the first error then you've patched the files too many times.
The second error means you haven't executed the installer sql (see this post)

Alex

Thanks, Alex.

I am good to go. Appreciate it.

First of all: thanks for the great addon! It's exactly what I've been looking for!

What I'd like to add are permissions for clients to edit wiki pages. I'm not very familiar with ProjectPier's permission implementation, but are there any serious reasons why you didn't enable such a feature yet?

Thanks!

Christian

To enable wiki-edit-permissions for project users, including clients, I just changed /application/models/wiki/WikiPage.class.php on line 79 and 91 to look like

return $user->isAdministrator() || $user->isMemberOfOwnerCompany() || $user->isProjectUser($this->getProject());

Works so far for me.

Hey Christian, thanks for posting that.
As far as I remember I didn't allow client editing as I was thinking of the wiki as being used as Documentation, which clients shouldn't be able to edit.

Hi Alex,

thanks a million for the Wiki - just integrated it in my PP installation. Do you have any overview of the features that are realized in the wiki?
I'm also trying to add some new functionality in terms of wiki language support, adding it to the wiki.php in application/helpers. But obviously I don't want to duplicate functionality.
Once I have it I could post my changes here.

Just as a side-note: the page http://projectpier.sigswitch.com, that you're referring to above seems to be offline

Cheers from Germany,
Korbinian

P.S.: I've attached now my changed wiki.php - which represents some MediaWiki formatting. Textile.class.php is slightly altered to interpret '==' as headline.

AttachmentSize
Textile.class_.php_.txt33.36 KB
wiki.php_.txt7.87 KB