Compare commits
8 Commits
v1.3
...
feature.wi
Author | SHA1 | Date | |
---|---|---|---|
|
9a6a6c21f5 | ||
|
69d0384ec3 | ||
|
af956d01dd | ||
|
0002e9bd21 | ||
|
6c62fbd19f | ||
|
7abcc29e60 | ||
|
2e1369184b | ||
|
bd94d5bf68 |
@@ -31,8 +31,11 @@
|
|||||||
*/
|
*/
|
||||||
class IDF_Form_Admin_ProjectCreate extends Pluf_Form
|
class IDF_Form_Admin_ProjectCreate extends Pluf_Form
|
||||||
{
|
{
|
||||||
|
public $user = null;
|
||||||
|
|
||||||
public function initFields($extra=array())
|
public function initFields($extra=array())
|
||||||
{
|
{
|
||||||
|
$this->user = $extra['user'];
|
||||||
$choices = array();
|
$choices = array();
|
||||||
$options = array(
|
$options = array(
|
||||||
'git' => __('git'),
|
'git' => __('git'),
|
||||||
@@ -336,7 +339,6 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form
|
|||||||
$conf->setVal($prop, $tmplconf->getVal($prop, $def));
|
$conf->setVal($prop, $tmplconf->getVal($prop, $def));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$project->created();
|
|
||||||
|
|
||||||
if ($this->cleaned_data['template'] == '--') {
|
if ($this->cleaned_data['template'] == '--') {
|
||||||
IDF_Form_MembersConf::updateMemberships($project,
|
IDF_Form_MembersConf::updateMemberships($project,
|
||||||
@@ -347,6 +349,8 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form
|
|||||||
$tmpl->getMembershipData('string'));
|
$tmpl->getMembershipData('string'));
|
||||||
}
|
}
|
||||||
$project->membershipsUpdated();
|
$project->membershipsUpdated();
|
||||||
|
$project->created();
|
||||||
|
|
||||||
return $project;
|
return $project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@ Phase:Support = Plans for user support and advocacy
|
|||||||
Deprecated = Most users should NOT reference this';
|
Deprecated = Most users should NOT reference this';
|
||||||
|
|
||||||
const init_one_max = '';
|
const init_one_max = '';
|
||||||
|
const wiki_default_page = '';
|
||||||
|
|
||||||
public function initFields($extra=array())
|
public function initFields($extra=array())
|
||||||
{
|
{
|
||||||
@@ -59,8 +60,30 @@ Deprecated = Most users should NOT reference this';
|
|||||||
'initial' => self::init_one_max,
|
'initial' => self::init_one_max,
|
||||||
'widget_attrs' => array('size' => 60),
|
'widget_attrs' => array('size' => 60),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$this->fields['wiki_default_page'] = new Pluf_Form_Field_Varchar(
|
||||||
|
array('required' => false,
|
||||||
|
'label' => __('Set a default wiki page instead of the page listing'),
|
||||||
|
'initial' => self::wiki_default_page,
|
||||||
|
'widget_attrs' => array('size' => 60),
|
||||||
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clean_wiki_default_page()
|
||||||
|
{
|
||||||
|
$pageName = trim($this->cleaned_data['wiki_default_page']);
|
||||||
|
if (empty($pageName)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$sql = new Pluf_SQL('project=%s AND title=%s', array($this->data['projectId'], $pageName));
|
||||||
|
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
|
||||||
|
|
||||||
|
if ($pages->count() != 1) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return $pageName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -418,8 +418,17 @@ class IDF_Views_Project
|
|||||||
$title = sprintf(__('%s Documentation Configuration'), (string) $prj);
|
$title = sprintf(__('%s Documentation Configuration'), (string) $prj);
|
||||||
$conf = new IDF_Conf();
|
$conf = new IDF_Conf();
|
||||||
$conf->setProject($prj);
|
$conf->setProject($prj);
|
||||||
|
|
||||||
|
// Get the Wiki list pages
|
||||||
|
$sql = new Pluf_SQL('project=%s', array($prj->id));
|
||||||
|
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
|
||||||
|
$auto_wiki_page_name = "";
|
||||||
|
foreach ($pages as $p) {
|
||||||
|
$auto_wiki_page_name .= '{ name: "' . $p->summary . '", to: "' . $p->title . '" }, ';
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->method == 'POST') {
|
if ($request->method == 'POST') {
|
||||||
$form = new IDF_Form_WikiConf($request->POST);
|
$form = new IDF_Form_WikiConf(array_merge($request->POST, array('projectId' => $prj->id)));
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
foreach ($form->cleaned_data as $key=>$val) {
|
foreach ($form->cleaned_data as $key=>$val) {
|
||||||
$conf->setVal($key, $val);
|
$conf->setVal($key, $val);
|
||||||
@@ -431,7 +440,7 @@ class IDF_Views_Project
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$params = array();
|
$params = array();
|
||||||
$keys = array('labels_wiki_predefined', 'labels_wiki_one_max');
|
$keys = array('labels_wiki_predefined', 'labels_wiki_one_max', 'wiki_default_page');
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$_val = $conf->getVal($key, false);
|
$_val = $conf->getVal($key, false);
|
||||||
if ($_val !== false) {
|
if ($_val !== false) {
|
||||||
@@ -447,6 +456,7 @@ class IDF_Views_Project
|
|||||||
array(
|
array(
|
||||||
'page_title' => $title,
|
'page_title' => $title,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
|
'auto_wiki_page_name' => $auto_wiki_page_name,
|
||||||
),
|
),
|
||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,43 @@ class IDF_Views_Wiki
|
|||||||
* View list of issues for a given project.
|
* View list of issues for a given project.
|
||||||
*/
|
*/
|
||||||
public $index_precond = array('IDF_Precondition::accessWiki');
|
public $index_precond = array('IDF_Precondition::accessWiki');
|
||||||
public function index($request, $match, $api=false)
|
public function index($request, $match)
|
||||||
|
{
|
||||||
|
$project = $request->project;
|
||||||
|
|
||||||
|
// Search for the default page
|
||||||
|
$conf = new IDF_Conf();
|
||||||
|
$conf->setProject($project);
|
||||||
|
$page = $conf->getVal('wiki_default_page', null);
|
||||||
|
if ($page === null) {
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::listing',
|
||||||
|
array($project->shortname));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the page
|
||||||
|
$sql = new Pluf_SQL('project=%s AND title=%s',
|
||||||
|
array($project->id, $page));
|
||||||
|
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
|
||||||
|
if ($pages->count() != 1) {
|
||||||
|
// The default page have been delete
|
||||||
|
$conf->setVal('wiki_default_page', null);
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::listing',
|
||||||
|
array($project->shortname));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
$page = $pages[0];
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
|
array($project->shortname, $page->title));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View list of issues for a given project.
|
||||||
|
*/
|
||||||
|
public $listing_precond = array('IDF_Precondition::accessWiki');
|
||||||
|
public function listing($request, $match, $api=false)
|
||||||
{
|
{
|
||||||
$prj = $request->project;
|
$prj = $request->project;
|
||||||
$title = sprintf(__('%s Documentation'), (string) $prj);
|
$title = sprintf(__('%s Documentation'), (string) $prj);
|
||||||
@@ -82,7 +118,7 @@ class IDF_Views_Wiki
|
|||||||
{
|
{
|
||||||
$prj = $request->project;
|
$prj = $request->project;
|
||||||
if (!isset($request->REQUEST['q']) or trim($request->REQUEST['q']) == '') {
|
if (!isset($request->REQUEST['q']) or trim($request->REQUEST['q']) == '') {
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::index',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::listing',
|
||||||
array($prj->shortname));
|
array($prj->shortname));
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
@@ -182,7 +218,7 @@ class IDF_Views_Wiki
|
|||||||
$urlpage = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
$urlpage = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
array($prj->shortname, $page->title));
|
array($prj->shortname, $page->title));
|
||||||
$request->user->setMessage(sprintf(__('The page <a href="%s">%s</a> has been created.'), $urlpage, Pluf_esc($page->title)));
|
$request->user->setMessage(sprintf(__('The page <a href="%s">%s</a> has been created.'), $urlpage, Pluf_esc($page->title)));
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::index',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::listing',
|
||||||
array($prj->shortname));
|
array($prj->shortname));
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
} elseif (isset($request->POST['preview'])) {
|
} elseif (isset($request->POST['preview'])) {
|
||||||
@@ -226,7 +262,13 @@ class IDF_Views_Wiki
|
|||||||
if (isset($request->GET['rev']) and preg_match('/^[0-9]+$/', $request->GET['rev'])) {
|
if (isset($request->GET['rev']) and preg_match('/^[0-9]+$/', $request->GET['rev'])) {
|
||||||
$oldrev = Pluf_Shortcuts_GetObjectOr404('IDF_WikiRevision',
|
$oldrev = Pluf_Shortcuts_GetObjectOr404('IDF_WikiRevision',
|
||||||
$request->GET['rev']);
|
$request->GET['rev']);
|
||||||
if ($oldrev->wikipage != $page->id or $oldrev->is_head == true) {
|
if ($oldrev->is_head == true) {
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
|
array($prj->shortname, $page->title));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($oldrev->wikipage != $page->id) {
|
||||||
return new Pluf_HTTP_Response_NotFound($request);
|
return new Pluf_HTTP_Response_NotFound($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,6 +294,39 @@ class IDF_Views_Wiki
|
|||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See the revision list of a documentation page.
|
||||||
|
*/
|
||||||
|
public $history_precond = array('IDF_Precondition::accessWiki');
|
||||||
|
public function history($request, $match)
|
||||||
|
{
|
||||||
|
$prj = $request->project;
|
||||||
|
// Find the page
|
||||||
|
$sql = new Pluf_SQL('project=%s AND title=%s',
|
||||||
|
array($prj->id, $match[2]));
|
||||||
|
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
|
||||||
|
if ($pages->count() != 1) {
|
||||||
|
return new Pluf_HTTP_Response_NotFound($request);
|
||||||
|
}
|
||||||
|
$page = $pages[0];
|
||||||
|
$ptags = self::getWikiTags($prj);
|
||||||
|
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
|
||||||
|
$tags = $page->get_tags_list();
|
||||||
|
$dep = Pluf_Model_InArray($dtag, $tags);
|
||||||
|
$title = sprintf(__('History of the wiki page %s'), $page->title);
|
||||||
|
$revision = $page->get_current_revision();
|
||||||
|
$revs = $page->get_revisions_list(array('order' => 'creation_dtime DESC'));
|
||||||
|
return Pluf_Shortcuts_RenderToResponse('idf/wiki/history.html',
|
||||||
|
array(
|
||||||
|
'page' => $page,
|
||||||
|
'page_title' => $title,
|
||||||
|
'rev' => $revision,
|
||||||
|
'revs' => $revs,
|
||||||
|
'tags' => $tags,
|
||||||
|
),
|
||||||
|
$request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a revision of a page.
|
* Remove a revision of a page.
|
||||||
*/
|
*/
|
||||||
@@ -291,6 +366,57 @@ class IDF_Views_Wiki
|
|||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public $restoreRev_precond = array('IDF_Precondition::accessWiki',
|
||||||
|
'IDF_Precondition::projectMemberOrOwner');
|
||||||
|
public function restoreRev($request, $match)
|
||||||
|
{
|
||||||
|
$prj = $request->project;
|
||||||
|
$oldrev = Pluf_Shortcuts_GetObjectOr404('IDF_WikiRevision', $match[2]);
|
||||||
|
$page = $oldrev->get_wikipage();
|
||||||
|
$prj->inOr404($page);
|
||||||
|
|
||||||
|
// Prevent restore the current version
|
||||||
|
if ($oldrev->is_head == true) {
|
||||||
|
$request->user->setMessage(__('This revision is already the current revision.'));
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
|
array($prj->shortname, $page->title));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'project' => $prj,
|
||||||
|
'user' => $request->user,
|
||||||
|
'page' => $page,
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'title' => $page->title,
|
||||||
|
'summary' => $page->summary,
|
||||||
|
'content' => $oldrev->content,
|
||||||
|
'comment' => sprintf(__('Restore old revision (%s)'), $oldrev->id),
|
||||||
|
);
|
||||||
|
|
||||||
|
$tags = $page->get_tags_list();
|
||||||
|
for ($i=1;$i<4;$i++) {
|
||||||
|
if (isset($tags[$i-1])) {
|
||||||
|
if ($tags[$i-1]->class != 'Other') {
|
||||||
|
$data['label'.$i] = (string) $tags[$i-1];
|
||||||
|
} else {
|
||||||
|
$data['label'.$i] = $tags[$i-1]->name;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['label'.$i] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = new IDF_Form_WikiUpdate($data, $params);
|
||||||
|
$page = $form->save();
|
||||||
|
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
|
array($prj->shortname, $page->title));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View a documentation page.
|
* View a documentation page.
|
||||||
*/
|
*/
|
||||||
@@ -320,7 +446,7 @@ class IDF_Views_Wiki
|
|||||||
$urlpage = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
$urlpage = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
array($prj->shortname, $page->title));
|
array($prj->shortname, $page->title));
|
||||||
$request->user->setMessage(sprintf(__('The page <a href="%s">%s</a> has been updated.'), $urlpage, Pluf_esc($page->title)));
|
$request->user->setMessage(sprintf(__('The page <a href="%s">%s</a> has been updated.'), $urlpage, Pluf_esc($page->title)));
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::index',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::listing',
|
||||||
array($prj->shortname));
|
array($prj->shortname));
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
} elseif (isset($request->POST['preview'])) {
|
} elseif (isset($request->POST['preview'])) {
|
||||||
@@ -358,7 +484,7 @@ class IDF_Views_Wiki
|
|||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$form->save();
|
$form->save();
|
||||||
$request->user->setMessage(__('The documentation page has been deleted.'));
|
$request->user->setMessage(__('The documentation page has been deleted.'));
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::index',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::listing',
|
||||||
array($prj->shortname));
|
array($prj->shortname));
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
|
@@ -221,4 +221,51 @@ class IDF_WikiPage extends Pluf_Model
|
|||||||
$tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
|
$tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
|
||||||
return $tmpl->render($context);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -262,6 +262,11 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/$#',
|
|||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
'method' => 'index');
|
'method' => 'index');
|
||||||
|
|
||||||
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/list/$#',
|
||||||
|
'base' => $base,
|
||||||
|
'model' => 'IDF_Views_Wiki',
|
||||||
|
'method' => 'listing');
|
||||||
|
|
||||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/create/$#',
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/create/$#',
|
||||||
'base' => $base,
|
'base' => $base,
|
||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
@@ -287,11 +292,21 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/delrev/(\d+)/$#',
|
|||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
'method' => 'deleteRev');
|
'method' => 'deleteRev');
|
||||||
|
|
||||||
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/resrev/(\d+)/$#',
|
||||||
|
'base' => $base,
|
||||||
|
'model' => 'IDF_Views_Wiki',
|
||||||
|
'method' => 'restoreRev');
|
||||||
|
|
||||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/delete/(\d+)/$#',
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/delete/(\d+)/$#',
|
||||||
'base' => $base,
|
'base' => $base,
|
||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
'method' => 'delete');
|
'method' => 'delete');
|
||||||
|
|
||||||
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/history/(.*)/$#',
|
||||||
|
'base' => $base,
|
||||||
|
'model' => 'IDF_Views_Wiki',
|
||||||
|
'method' => 'history');
|
||||||
|
|
||||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/page/(.*)/$#',
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/page/(.*)/$#',
|
||||||
'base' => $base,
|
'base' => $base,
|
||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
|
@@ -115,4 +115,10 @@ Pluf_Signal::connect('queuecron.php::run',
|
|||||||
Pluf_Signal::connect('IDF_Queue::processItem',
|
Pluf_Signal::connect('IDF_Queue::processItem',
|
||||||
Pluf::f('idf_hook_process_item',
|
Pluf::f('idf_hook_process_item',
|
||||||
array('IDF_Webhook', 'process')));
|
array('IDF_Webhook', 'process')));
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wiki init
|
||||||
|
Pluf_Signal::connect('IDF_Project::created',
|
||||||
|
array('IDF_WikiPage', 'projectCreated'));
|
||||||
|
|
||||||
return $m;
|
return $m;
|
||||||
|
@@ -16,6 +16,34 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td colspan="2">{$form.f.wiki_default_page.labelTag}:<br />
|
||||||
|
{if $form.f.wiki_default_page.errors}{$form.f.wiki_default_page.fieldErrors}{/if}
|
||||||
|
{$form.f.wiki_default_page|unsafe}
|
||||||
|
</td>
|
||||||
|
<script type="text/javascript" src="{media '/idf/js/jquery.bgiframe.min.js'}"></script>
|
||||||
|
<script type="text/javascript" src="{media '/idf/js/jquery.autocomplete.min.js'}"></script>
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
{literal}
|
||||||
|
$(document).ready(function(){
|
||||||
|
var auto_wiki_page_name = [{/literal}{$auto_wiki_page_name|safe}{literal}];
|
||||||
|
$("#id_wiki_default_page").autocomplete(auto_wiki_page_name, {
|
||||||
|
minChars: 0,
|
||||||
|
width: 310,
|
||||||
|
matchContains: true,
|
||||||
|
max: 50,
|
||||||
|
highlightItem: false,
|
||||||
|
formatItem: function(row, i, max, term) {
|
||||||
|
return row.to.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row.name + "</span>";
|
||||||
|
},
|
||||||
|
formatResult: function(row) {
|
||||||
|
return row.to;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
{/literal}
|
||||||
|
</script>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<input type="submit" value="{trans 'Save Changes'}" name="submit" />
|
<input type="submit" value="{trans 'Save Changes'}" name="submit" />
|
||||||
</td>
|
</td>
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
{block tabwiki} class="active"{/block}
|
{block tabwiki} class="active"{/block}
|
||||||
{block subtabs}
|
{block subtabs}
|
||||||
<div id="sub-tabs">
|
<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()} | <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}
|
{if !$user.isAnonymous() and $inView} | <a href="{url 'IDF_Views_Wiki::update', array($project.shortname, $page.title)}">{trans 'Update This Page'}</a> {/if}
|
||||||
|
|
|
|
||||||
|
38
src/IDF/templates/idf/wiki/history.html
Normal file
38
src/IDF/templates/idf/wiki/history.html
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{extends "idf/wiki/base.html"}
|
||||||
|
|
||||||
|
{block extraheader}
|
||||||
|
<meta name="ROBOTS" content="NOINDEX" />
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
{block docclass}yui-t3{assign $inView=true}{/block}
|
||||||
|
|
||||||
|
{block body}
|
||||||
|
<table class="recent-issues">
|
||||||
|
<tr><th>Id</th><th>Who</th><th>When</th><th>Summary</th><th>Actions</th></tr>
|
||||||
|
{foreach $revs as $r}
|
||||||
|
{ashowuser 'submitter', $rev.get_submitter(), $request}
|
||||||
|
{aurl 'view_url', 'IDF_Views_Wiki::view', array($project.shortname, $page.title), array('rev' => $r->id)}
|
||||||
|
{aurl 'delete_url', 'IDF_Views_Wiki::deleteRev', array($project.shortname, $r->id)}
|
||||||
|
{aurl 'restore_url', 'IDF_Views_Wiki::restoreRev', array($project.shortname, $r->id)}
|
||||||
|
<tr><td><a href="{$view_url}">{$r->id}</a></td><td>{$submitter}</td><td class="a-c">{$r->creation_dtime|dateago}</td><td>{$r->summary}</td><td>{if $r->is_head == false}<a href="{$view_url}">View</a> - <a href="{$delete_url}">Delete</a> - <a href="{$restore_url}">Restore</a>{/if}</td></tr>
|
||||||
|
{/foreach}
|
||||||
|
</table>
|
||||||
|
{aurl 'add_rev', 'IDF_Views_Wiki::update', array($project.shortname, $page.title)}
|
||||||
|
<p><a href="{$add_rev}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/add.png'}" alt="+" align="bottom"></a> <a href="{$add_rev}">{trans 'Update This Page'}</a></p>
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
|
||||||
|
{block context}
|
||||||
|
{ashowuser 'submitter', $page.get_submitter(), $request}
|
||||||
|
<p><strong>{trans 'Created:'}</strong> <span class="nobrk">{$page.creation_dtime|dateago}</span><br /><span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>
|
||||||
|
{if $rev.creation_dtime != $page.creation_dtime}<p>{ashowuser 'submitter', $rev.get_submitter(), $request}
|
||||||
|
<strong>{trans 'Updated:'}</strong> <span class="nobrk">{$rev.creation_dtime|dateago}</span><br /><span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>{/if}
|
||||||
|
{if $tags.count()}
|
||||||
|
<p>
|
||||||
|
<strong>{trans 'Labels:'}</strong><br />
|
||||||
|
{foreach $tags as $tag}
|
||||||
|
<span class="label"><strong>{$tag.class}:</strong>{$tag.name}</span><br />
|
||||||
|
{/foreach}
|
||||||
|
</p>{/if}
|
||||||
|
<p class="helptext"><a href="{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title)}">{trans 'See current revision'}</a></p>
|
||||||
|
{/block}
|
@@ -52,9 +52,6 @@ by {$submitter}.{/blocktrans}</p>
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</p>{/if}
|
</p>{/if}
|
||||||
{if $revs.count() > 0}
|
{if $revs.count() > 0}
|
||||||
<p><strong>{trans 'Old Revisions'}</strong></p>
|
<p class="helptext"><a href="{url 'IDF_Views_Wiki::history', array($project.shortname, $page.title)}">{trans 'See older revision'}</a></p>
|
||||||
<ul>{foreach $revs as $old}
|
|
||||||
<li><a href="{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title), array('rev'=>$old.id)}">{$old.summary}</a></li>
|
|
||||||
{/foreach}</ul>
|
|
||||||
{/if}
|
{/if}
|
||||||
{/block}
|
{/block}
|
||||||
|
17
src/IDF/templates/idf/wiki/wiki-default-page.mdtext
Normal file
17
src/IDF/templates/idf/wiki/wiki-default-page.mdtext
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{aurl 'syntax_url', 'IDF_Views_Wiki::view', array($project.shortname, 'IndeferoMarkdownHelp')}
|
||||||
|
{aurl 'wiki_add', 'IDF_Views_Wiki::create', array($project.shortname)}
|
||||||
|
{aurl 'wiki_update', 'IDF_Views_Wiki::update', array($project.shortname, 'IndeferoSummaryDefault')}
|
||||||
|
{aurl 'wiki_history', 'IDF_Views_Wiki::history', array($project.shortname, 'IndeferoSummaryDefault')}
|
||||||
|
{aurl 'wiki_admin', 'IDF_Views_Project::adminWiki', array($project.shortname)}
|
||||||
|
{blocktrans}
|
||||||
|
Welcome on the documentation section of the project {$project->name}.
|
||||||
|
All documentation page use the markdown syntax, you can find help about this syntax on this [page]({$syntax_url}).
|
||||||
|
|
||||||
|
- You can another Wiki page [here]({$wiki_add}).
|
||||||
|
- You can update this page [here]({$wiki_update}).
|
||||||
|
- You can select an other default wiki page [here]({$wiki_admin}). You need to be admin.
|
||||||
|
|
||||||
|
|
||||||
|
All modification on a wiki page are saved, and you can see this history for each pages.
|
||||||
|
The history of the current page can be see [here]({$wiki_history}).
|
||||||
|
{/blocktrans}
|
569
src/IDF/templates/idf/wiki/wiki-markdown-help.mdtext
Normal file
569
src/IDF/templates/idf/wiki/wiki-markdown-help.mdtext
Normal file
@@ -0,0 +1,569 @@
|
|||||||
|
Block Elements
|
||||||
|
==============
|
||||||
|
|
||||||
|
|
||||||
|
Paragraphs and Line Breaks
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
A paragraph is simply one or more consecutive lines of text, separated
|
||||||
|
by one or more blank lines. (A blank line is any line that looks like a
|
||||||
|
blank line -- a line containing nothing but spaces or tabs is considered
|
||||||
|
blank.) Normal paragraphs should not be indented with spaces or tabs.
|
||||||
|
|
||||||
|
The implication of the "one or more consecutive lines of text" rule is
|
||||||
|
that Markdown supports "hard-wrapped" text paragraphs. This differs
|
||||||
|
significantly from most other text-to-HTML formatters (including Movable
|
||||||
|
Type's "Convert Line Breaks" option) which translate every line break
|
||||||
|
character in a paragraph into a `<br />` tag.
|
||||||
|
|
||||||
|
When you *do* want to insert a `<br />` break tag using Markdown, you
|
||||||
|
end a line with two or more spaces, then type return.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Headers
|
||||||
|
-------
|
||||||
|
|
||||||
|
Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
|
||||||
|
|
||||||
|
Setext-style headers are "underlined" using equal signs (for first-level
|
||||||
|
headers) and dashes (for second-level headers). For example:
|
||||||
|
|
||||||
|
This is an H1
|
||||||
|
=============
|
||||||
|
|
||||||
|
This is an H2
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Any number of underlining `=`'s or `-`'s will work.
|
||||||
|
|
||||||
|
Atx-style headers use 1-6 hash characters at the start of the line,
|
||||||
|
corresponding to header levels 1-6. For example:
|
||||||
|
|
||||||
|
# This is an H1
|
||||||
|
|
||||||
|
## This is an H2
|
||||||
|
|
||||||
|
###### This is an H6
|
||||||
|
|
||||||
|
Optionally, you may "close" atx-style headers. This is purely
|
||||||
|
cosmetic -- you can use this if you think it looks better. The
|
||||||
|
closing hashes don't even need to match the number of hashes
|
||||||
|
used to open the header. (The number of opening hashes
|
||||||
|
determines the header level.) :
|
||||||
|
|
||||||
|
# This is an H1 #
|
||||||
|
|
||||||
|
## This is an H2 ##
|
||||||
|
|
||||||
|
### This is an H3 ######
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Blockquotes
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Markdown uses email-style `>` characters for blockquoting. If you're
|
||||||
|
familiar with quoting passages of text in an email message, then you
|
||||||
|
know how to create a blockquote in Markdown. It looks best if you hard
|
||||||
|
wrap the text and put a `>` before every line:
|
||||||
|
|
||||||
|
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
||||||
|
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
||||||
|
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
||||||
|
>
|
||||||
|
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
||||||
|
> id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
Markdown allows you to be lazy and only put the `>` before the first
|
||||||
|
line of a hard-wrapped paragraph:
|
||||||
|
|
||||||
|
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
||||||
|
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
||||||
|
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
||||||
|
|
||||||
|
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
||||||
|
id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
|
||||||
|
adding additional levels of `>`:
|
||||||
|
|
||||||
|
> This is the first level of quoting.
|
||||||
|
>
|
||||||
|
> > This is nested blockquote.
|
||||||
|
>
|
||||||
|
> Back to the first level.
|
||||||
|
|
||||||
|
Blockquotes can contain other Markdown elements, including headers, lists,
|
||||||
|
and code blocks:
|
||||||
|
|
||||||
|
> ## This is a header.
|
||||||
|
>
|
||||||
|
> 1. This is the first list item.
|
||||||
|
> 2. This is the second list item.
|
||||||
|
>
|
||||||
|
> Here's some example code:
|
||||||
|
>
|
||||||
|
> return shell_exec("echo $input | $markdown_script");
|
||||||
|
|
||||||
|
Any decent text editor should make email-style quoting easy. For
|
||||||
|
example, with BBEdit, you can make a selection and choose Increase
|
||||||
|
Quote Level from the Text menu.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Lists
|
||||||
|
-----
|
||||||
|
|
||||||
|
Markdown supports ordered (numbered) and unordered (bulleted) lists.
|
||||||
|
|
||||||
|
Unordered lists use asterisks, pluses, and hyphens -- interchangably
|
||||||
|
-- as list markers:
|
||||||
|
|
||||||
|
* Red
|
||||||
|
* Green
|
||||||
|
* Blue
|
||||||
|
|
||||||
|
is equivalent to:
|
||||||
|
|
||||||
|
+ Red
|
||||||
|
+ Green
|
||||||
|
+ Blue
|
||||||
|
|
||||||
|
and:
|
||||||
|
|
||||||
|
- Red
|
||||||
|
- Green
|
||||||
|
- Blue
|
||||||
|
|
||||||
|
Ordered lists use numbers followed by periods:
|
||||||
|
|
||||||
|
1. Bird
|
||||||
|
2. McHale
|
||||||
|
3. Parish
|
||||||
|
|
||||||
|
It's important to note that the actual numbers you use to mark the
|
||||||
|
list have no effect on the HTML output Markdown produces. The HTML
|
||||||
|
Markdown produces from the above list is:
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<li>Bird</li>
|
||||||
|
<li>McHale</li>
|
||||||
|
<li>Parish</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
If you instead wrote the list in Markdown like this:
|
||||||
|
|
||||||
|
1. Bird
|
||||||
|
1. McHale
|
||||||
|
1. Parish
|
||||||
|
|
||||||
|
or even:
|
||||||
|
|
||||||
|
3. Bird
|
||||||
|
1. McHale
|
||||||
|
8. Parish
|
||||||
|
|
||||||
|
you'd get the exact same HTML output. The point is, if you want to,
|
||||||
|
you can use ordinal numbers in your ordered Markdown lists, so that
|
||||||
|
the numbers in your source match the numbers in your published HTML.
|
||||||
|
But if you want to be lazy, you don't have to.
|
||||||
|
|
||||||
|
If you do use lazy list numbering, however, you should still start the
|
||||||
|
list with the number 1. At some point in the future, Markdown may support
|
||||||
|
starting ordered lists at an arbitrary number.
|
||||||
|
|
||||||
|
List markers typically start at the left margin, but may be indented by
|
||||||
|
up to three spaces. List markers must be followed by one or more spaces
|
||||||
|
or a tab.
|
||||||
|
|
||||||
|
To make lists look nice, you can wrap items with hanging indents:
|
||||||
|
|
||||||
|
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
||||||
|
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
||||||
|
viverra nec, fringilla in, laoreet vitae, risus.
|
||||||
|
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
||||||
|
Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
But if you want to be lazy, you don't have to:
|
||||||
|
|
||||||
|
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
||||||
|
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
||||||
|
viverra nec, fringilla in, laoreet vitae, risus.
|
||||||
|
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
||||||
|
Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
If list items are separated by blank lines, Markdown will wrap the
|
||||||
|
items in `<p>` tags in the HTML output. For example, this input:
|
||||||
|
|
||||||
|
* Bird
|
||||||
|
* Magic
|
||||||
|
|
||||||
|
will turn into:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Bird</li>
|
||||||
|
<li>Magic</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
But this:
|
||||||
|
|
||||||
|
* Bird
|
||||||
|
|
||||||
|
* Magic
|
||||||
|
|
||||||
|
will turn into:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><p>Bird</p></li>
|
||||||
|
<li><p>Magic</p></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
List items may consist of multiple paragraphs. Each subsequent
|
||||||
|
paragraph in a list item must be indented by either 4 spaces
|
||||||
|
or one tab:
|
||||||
|
|
||||||
|
1. This is a list item with two paragraphs. Lorem ipsum dolor
|
||||||
|
sit amet, consectetuer adipiscing elit. Aliquam hendrerit
|
||||||
|
mi posuere lectus.
|
||||||
|
|
||||||
|
Vestibulum enim wisi, viverra nec, fringilla in, laoreet
|
||||||
|
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
|
||||||
|
sit amet velit.
|
||||||
|
|
||||||
|
2. Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
It looks nice if you indent every line of the subsequent
|
||||||
|
paragraphs, but here again, Markdown will allow you to be
|
||||||
|
lazy:
|
||||||
|
|
||||||
|
* This is a list item with two paragraphs.
|
||||||
|
|
||||||
|
This is the second paragraph in the list item. You're
|
||||||
|
only required to indent the first line. Lorem ipsum dolor
|
||||||
|
sit amet, consectetuer adipiscing elit.
|
||||||
|
|
||||||
|
* Another item in the same list.
|
||||||
|
|
||||||
|
To put a blockquote within a list item, the blockquote's `>`
|
||||||
|
delimiters need to be indented:
|
||||||
|
|
||||||
|
* A list item with a blockquote:
|
||||||
|
|
||||||
|
> This is a blockquote
|
||||||
|
> inside a list item.
|
||||||
|
|
||||||
|
To put a code block within a list item, the code block needs
|
||||||
|
to be indented *twice* -- 8 spaces or two tabs:
|
||||||
|
|
||||||
|
* A list item with a code block:
|
||||||
|
|
||||||
|
<code goes here>
|
||||||
|
|
||||||
|
|
||||||
|
It's worth noting that it's possible to trigger an ordered list by
|
||||||
|
accident, by writing something like this:
|
||||||
|
|
||||||
|
1986. What a great season.
|
||||||
|
|
||||||
|
In other words, a *number-period-space* sequence at the beginning of a
|
||||||
|
line. To avoid this, you can backslash-escape the period:
|
||||||
|
|
||||||
|
1986\. What a great season.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Code Blocks
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Pre-formatted code blocks are used for writing about programming or
|
||||||
|
markup source code. Rather than forming normal paragraphs, the lines
|
||||||
|
of a code block are interpreted literally. Markdown wraps a code block
|
||||||
|
in both `<pre>` and `<code>` tags.
|
||||||
|
|
||||||
|
To produce a code block in Markdown, simply indent every line of the
|
||||||
|
block by at least 4 spaces or 1 tab. For example, given this input:
|
||||||
|
|
||||||
|
This is a normal paragraph:
|
||||||
|
|
||||||
|
This is a code block.
|
||||||
|
|
||||||
|
Markdown will generate:
|
||||||
|
|
||||||
|
<p>This is a normal paragraph:</p>
|
||||||
|
|
||||||
|
<pre><code>This is a code block.
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
One level of indentation -- 4 spaces or 1 tab -- is removed from each
|
||||||
|
line of the code block. For example, this:
|
||||||
|
|
||||||
|
Here is an example of AppleScript:
|
||||||
|
|
||||||
|
tell application "Foo"
|
||||||
|
beep
|
||||||
|
end tell
|
||||||
|
|
||||||
|
will turn into:
|
||||||
|
|
||||||
|
<p>Here is an example of AppleScript:</p>
|
||||||
|
|
||||||
|
<pre><code>tell application "Foo"
|
||||||
|
beep
|
||||||
|
end tell
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
A code block continues until it reaches a line that is not indented
|
||||||
|
(or the end of the article).
|
||||||
|
|
||||||
|
Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
|
||||||
|
are automatically converted into HTML entities. This makes it very
|
||||||
|
easy to include example HTML source code using Markdown -- just paste
|
||||||
|
it and indent it, and Markdown will handle the hassle of encoding the
|
||||||
|
ampersands and angle brackets. For example, this:
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
© 2004 Foo Corporation
|
||||||
|
</div>
|
||||||
|
|
||||||
|
will turn into:
|
||||||
|
|
||||||
|
<pre><code><div class="footer">
|
||||||
|
&copy; 2004 Foo Corporation
|
||||||
|
</div>
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
Regular Markdown syntax is not processed within code blocks. E.g.,
|
||||||
|
asterisks are just literal asterisks within a code block. This means
|
||||||
|
it's also easy to use Markdown to write about Markdown's own syntax.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Span Elements
|
||||||
|
=============
|
||||||
|
|
||||||
|
|
||||||
|
Links
|
||||||
|
-----
|
||||||
|
|
||||||
|
Markdown supports two style of links: *inline* and *reference*.
|
||||||
|
|
||||||
|
In both styles, the link text is delimited by [square brackets].
|
||||||
|
|
||||||
|
To create an inline link, use a set of regular parentheses immediately
|
||||||
|
after the link text's closing square bracket. Inside the parentheses,
|
||||||
|
put the URL where you want the link to point, along with an *optional*
|
||||||
|
title for the link, surrounded in quotes. For example:
|
||||||
|
|
||||||
|
This is [an example](http://example.com/ "Title") inline link.
|
||||||
|
|
||||||
|
[This link](http://example.net/) has no title attribute.
|
||||||
|
|
||||||
|
Will produce:
|
||||||
|
|
||||||
|
<p>This is <a href="http://example.com/" title="Title">
|
||||||
|
an example</a> inline link.</p>
|
||||||
|
|
||||||
|
<p><a href="http://example.net/">This link</a> has no
|
||||||
|
title attribute.</p>
|
||||||
|
|
||||||
|
If you're referring to a local resource on the same server, you can
|
||||||
|
use relative paths:
|
||||||
|
|
||||||
|
See my [About](/about/) page for details.
|
||||||
|
|
||||||
|
Reference-style links use a second set of square brackets, inside
|
||||||
|
which you place a label of your choosing to identify the link:
|
||||||
|
|
||||||
|
This is [an example][id] reference-style link.
|
||||||
|
|
||||||
|
You can optionally use a space to separate the sets of brackets:
|
||||||
|
|
||||||
|
This is [an example] [id] reference-style link.
|
||||||
|
|
||||||
|
Then, anywhere in the document, you define your link label like this,
|
||||||
|
on a line by itself:
|
||||||
|
|
||||||
|
[id]: http://example.com/ "Optional Title Here"
|
||||||
|
|
||||||
|
That is:
|
||||||
|
|
||||||
|
* Square brackets containing the link identifier (optionally
|
||||||
|
indented from the left margin using up to three spaces);
|
||||||
|
* followed by a colon;
|
||||||
|
* followed by one or more spaces (or tabs);
|
||||||
|
* followed by the URL for the link;
|
||||||
|
* optionally followed by a title attribute for the link, enclosed
|
||||||
|
in double or single quotes, or enclosed in parentheses.
|
||||||
|
|
||||||
|
The following three link definitions are equivalent:
|
||||||
|
|
||||||
|
[foo]: http://example.com/ "Optional Title Here"
|
||||||
|
[foo]: http://example.com/ 'Optional Title Here'
|
||||||
|
[foo]: http://example.com/ (Optional Title Here)
|
||||||
|
|
||||||
|
**Note:** There is a known bug in Markdown.pl 1.0.1 which prevents
|
||||||
|
single quotes from being used to delimit link titles.
|
||||||
|
|
||||||
|
The link URL may, optionally, be surrounded by angle brackets:
|
||||||
|
|
||||||
|
[id]: <http://example.com/> "Optional Title Here"
|
||||||
|
|
||||||
|
You can put the title attribute on the next line and use extra spaces
|
||||||
|
or tabs for padding, which tends to look better with longer URLs:
|
||||||
|
|
||||||
|
[id]: http://example.com/longish/path/to/resource/here
|
||||||
|
"Optional Title Here"
|
||||||
|
|
||||||
|
Link definitions are only used for creating links during Markdown
|
||||||
|
processing, and are stripped from your document in the HTML output.
|
||||||
|
|
||||||
|
Link definition names may consist of letters, numbers, spaces, and
|
||||||
|
punctuation -- but they are *not* case sensitive. E.g. these two
|
||||||
|
links:
|
||||||
|
|
||||||
|
[link text][a]
|
||||||
|
[link text][A]
|
||||||
|
|
||||||
|
are equivalent.
|
||||||
|
|
||||||
|
The *implicit link name* shortcut allows you to omit the name of the
|
||||||
|
link, in which case the link text itself is used as the name.
|
||||||
|
Just use an empty set of square brackets -- e.g., to link the word
|
||||||
|
"Google" to the google.com web site, you could simply write:
|
||||||
|
|
||||||
|
[Google][]
|
||||||
|
|
||||||
|
And then define the link:
|
||||||
|
|
||||||
|
[Google]: http://google.com/
|
||||||
|
|
||||||
|
Because link names may contain spaces, this shortcut even works for
|
||||||
|
multiple words in the link text:
|
||||||
|
|
||||||
|
Visit [Daring Fireball][] for more information.
|
||||||
|
|
||||||
|
And then define the link:
|
||||||
|
|
||||||
|
[Daring Fireball]: http://daringfireball.net/
|
||||||
|
|
||||||
|
Link definitions can be placed anywhere in your Markdown document. I
|
||||||
|
tend to put them immediately after each paragraph in which they're
|
||||||
|
used, but if you want, you can put them all at the end of your
|
||||||
|
document, sort of like footnotes.
|
||||||
|
|
||||||
|
Here's an example of reference links in action:
|
||||||
|
|
||||||
|
I get 10 times more traffic from [Google] [1] than from
|
||||||
|
[Yahoo] [2] or [MSN] [3].
|
||||||
|
|
||||||
|
[1]: http://google.com/ "Google"
|
||||||
|
[2]: http://search.yahoo.com/ "Yahoo Search"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Emphasis
|
||||||
|
--------
|
||||||
|
|
||||||
|
Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
|
||||||
|
emphasis. Text wrapped with one `*` or `_` will be wrapped with an
|
||||||
|
HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
|
||||||
|
`<strong>` tag. E.g., this input:
|
||||||
|
|
||||||
|
*single asterisks*
|
||||||
|
|
||||||
|
_single underscores_
|
||||||
|
|
||||||
|
**double asterisks**
|
||||||
|
|
||||||
|
__double underscores__
|
||||||
|
|
||||||
|
will produce:
|
||||||
|
|
||||||
|
<em>single asterisks</em>
|
||||||
|
|
||||||
|
<em>single underscores</em>
|
||||||
|
|
||||||
|
<strong>double asterisks</strong>
|
||||||
|
|
||||||
|
<strong>double underscores</strong>
|
||||||
|
|
||||||
|
You can use whichever style you prefer; the lone restriction is that
|
||||||
|
the same character must be used to open and close an emphasis span.
|
||||||
|
|
||||||
|
Emphasis can be used in the middle of a word:
|
||||||
|
|
||||||
|
un*frigging*believable
|
||||||
|
|
||||||
|
But if you surround an `*` or `_` with spaces, it'll be treated as a
|
||||||
|
literal asterisk or underscore.
|
||||||
|
|
||||||
|
To produce a literal asterisk or underscore at a position where it
|
||||||
|
would otherwise be used as an emphasis delimiter, you can backslash
|
||||||
|
escape it:
|
||||||
|
|
||||||
|
\*this text is surrounded by literal asterisks\*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Code
|
||||||
|
----
|
||||||
|
|
||||||
|
To indicate a span of code, wrap it with backtick quotes (`` ` ``).
|
||||||
|
Unlike a pre-formatted code block, a code span indicates code within a
|
||||||
|
normal paragraph. For example:
|
||||||
|
|
||||||
|
Use the `printf()` function.
|
||||||
|
|
||||||
|
will produce:
|
||||||
|
|
||||||
|
<p>Use the <code>printf()</code> function.</p>
|
||||||
|
|
||||||
|
To include a literal backtick character within a code span, you can use
|
||||||
|
multiple backticks as the opening and closing delimiters:
|
||||||
|
|
||||||
|
``There is a literal backtick (`) here.``
|
||||||
|
|
||||||
|
which will produce this:
|
||||||
|
|
||||||
|
<p><code>There is a literal backtick (`) here.</code></p>
|
||||||
|
|
||||||
|
The backtick delimiters surrounding a code span may include spaces --
|
||||||
|
one after the opening, one before the closing. This allows you to place
|
||||||
|
literal backtick characters at the beginning or end of a code span:
|
||||||
|
|
||||||
|
A single backtick in a code span: `` ` ``
|
||||||
|
|
||||||
|
A backtick-delimited string in a code span: `` `foo` ``
|
||||||
|
|
||||||
|
will produce:
|
||||||
|
|
||||||
|
<p>A single backtick in a code span: <code>`</code></p>
|
||||||
|
|
||||||
|
<p>A backtick-delimited string in a code span: <code>`foo`</code></p>
|
||||||
|
|
||||||
|
With a code span, ampersands and angle brackets are encoded as HTML
|
||||||
|
entities automatically, which makes it easy to include example HTML
|
||||||
|
tags. Markdown will turn this:
|
||||||
|
|
||||||
|
Please don't use any `<blink>` tags.
|
||||||
|
|
||||||
|
into:
|
||||||
|
|
||||||
|
<p>Please don't use any <code><blink></code> tags.</p>
|
||||||
|
|
||||||
|
You can write this:
|
||||||
|
|
||||||
|
`—` is the decimal-encoded equivalent of `—`.
|
||||||
|
|
||||||
|
to produce:
|
||||||
|
|
||||||
|
<p><code>&#8212;</code> is the decimal-encoded
|
||||||
|
equivalent of <code>&mdash;</code>.</p>
|
||||||
|
|
Reference in New Issue
Block a user