Add the auto generated wiki page as default page

This commit is contained in:
William MARTIN 2011-12-05 09:52:26 +01:00
parent 0002e9bd21
commit af956d01dd
4 changed files with 56 additions and 43 deletions

View File

@ -339,7 +339,6 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form
$conf->setVal($prop, $tmplconf->getVal($prop, $def));
}
}
$project->created();
if ($this->cleaned_data['template'] == '--') {
IDF_Form_MembersConf::updateMemberships($project,
@ -350,46 +349,7 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form
$tmpl->getMembershipData('string'));
}
$project->membershipsUpdated();
// Insert default wiki page
$tmpl = new Pluf_Template('idf/wiki/wiki-default-page.mdtext');
$context = new Pluf_Template_Context(array('project' => $project));
$content = $tmpl->render($context);
$page = new IDF_WikiPage();
$page->project = $project;
$page->submitter = $this->user;
$page->summary = __('This is the default page for your project Wiki.');
$page->title = 'summary-default';
$page->create();
$rev = new IDF_WikiRevision();
$rev->wikipage = $page;
$rev->content = $content;
$rev->submitter = $this->user;
$rev->summary = __('Initial page creation');
$rev->create();
$rev->notify($project->getConf());
// Insert markdown help wiki page
$tmpl = new Pluf_Template('idf/wiki/wiki-markdown-help.mdtext');
$context = new Pluf_Template_Context(array('project' => $project));
$content = $tmpl->render($context);
$page = new IDF_WikiPage();
$page->project = $project;
$page->submitter = $this->user;
$page->summary = __('Help about Markdown syntax.');
$page->title = 'markdown-help';
$page->create();
$rev = new IDF_WikiRevision();
$rev->wikipage = $page;
$rev->content = $content;
$rev->submitter = $this->user;
$rev->summary = __('Initial page creation');
$rev->create();
$rev->notify($project->getConf());
// To review :
// $conf->setVal('wiki_default_page', 'summary-default');
$project->created();
return $project;
}

View File

@ -221,4 +221,51 @@ class IDF_WikiPage extends Pluf_Model
$tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
return $tmpl->render($context);
}
}
function projectCreated($signal, &$params)
{
$project = $params['project'];
$users = $project->getMembershipData();
$user = $users['owners'][0];
$conf = $project->getConf();
// Insert default wiki page
$tmpl = new Pluf_Template('idf/wiki/wiki-default-page.mdtext');
$context = new Pluf_Template_Context(array('project' => $project));
$content = $tmpl->render($context);
$page = new IDF_WikiPage();
$page->project = $project;
$page->submitter = $user;
$page->summary = __('Default page for your project Wiki.');
$page->title = 'IndeferoSummaryDefault';
$page->create();
$rev = new IDF_WikiRevision();
$rev->wikipage = $page;
$rev->content = $content;
$rev->submitter = $user;
$rev->summary = __('Initial page creation');
$rev->create();
$rev->notify($project->getConf());
// Insert markdown help wiki page
$tmpl = new Pluf_Template('idf/wiki/wiki-markdown-help.mdtext');
$context = new Pluf_Template_Context(array('project' => $project));
$content = $tmpl->render($context);
$page = new IDF_WikiPage();
$page->project = $project;
$page->submitter = $user;
$page->summary = __('Help about Markdown syntax.');
$page->title = 'IndeferoMarkdownHelp';
$page->create();
$rev = new IDF_WikiRevision();
$rev->wikipage = $page;
$rev->content = $content;
$rev->submitter = $user;
$rev->summary = __('Initial page creation');
$rev->create();
$rev->notify($project->getConf());
$conf->setVal('wiki_default_page', 'IndeferoSummaryDefault');
$conf->setVal('labels_wiki_predefined', IDF_Form_WikiConf::init_predefined);
}
}

View File

@ -115,4 +115,10 @@ Pluf_Signal::connect('queuecron.php::run',
Pluf_Signal::connect('IDF_Queue::processItem',
Pluf::f('idf_hook_process_item',
array('IDF_Webhook', 'process')));
#
# Wiki init
Pluf_Signal::connect('IDF_Project::created',
array('IDF_WikiPage', 'projectCreated'));
return $m;

View File

@ -2,7 +2,7 @@
{block tabwiki} class="active"{/block}
{block subtabs}
<div id="sub-tabs">
<a {if $inWiki}class="active" {/if}href="{url 'IDF_Views_Wiki::index', array($project.shortname)}">{trans 'List Pages'}</a>
<a {if $inWiki}class="active" {/if}href="{url 'IDF_Views_Wiki::listing', array($project.shortname)}">{trans 'List Pages'}</a>
{if !$user.isAnonymous()} | <a {if $inCreate}class="active" {/if}href="{url 'IDF_Views_Wiki::create', array($project.shortname)}">{trans 'New Page'}</a> {/if}
{if !$user.isAnonymous() and $inView} | <a href="{url 'IDF_Views_Wiki::update', array($project.shortname, $page.title)}">{trans 'Update This Page'}</a> {/if}
|