Commit a367e377 authored by Andrew Manning's avatar Andrew Manning

The need for gitwiki has passed. It has served its purpose.

parent 0efef4b3
This diff is collapsed.
#ace-editor {
position: relative;
width: 100%;
height: 500px;
border: 1px solid #ccc;
border-top: 0px;
}
#editor {
width: 100%;
height: 500px;
border: 1px solid #ccc;
border-top: 0px;
display: inherit;
}
#id_commitMsg_wrapper {
margin-top: 3px;
}
.fade.in {
-webkit-transition: opacity 0.5s 0.5s ease;
-moz-transition: opacity 0.5s 0.5s ease;
-o-transition: opacity 0.5s 0.5s ease;
transition: opacity 0.5s 0.5s ease;
}
#new-wiki-form-wrapper {
display: none;
}
#wikis-index {
width: 100%;
}
#wikis-index th:nth-child(1),
#wikis-index td:nth-child(1){
padding: 7px 3px 7px 10px;
}
#wikis-index th:nth-child(4),
#wikis-index td:nth-child(4){
padding: 7px 10px 7px 7px;
}
#wikis-index th:nth-child(5),
#wikis-index td:nth-child(5){
padding: 7px 10px 7px 7px;
}
.wikis-index-tool {
padding: 7px 10px;
}
<?php
/**
* Name: Git Wiki
* Description: Git based Wiki
* Version: 1.0
* Author: Andrew Manning
* Maintainer: none
*/
function gitwiki_load() {
Zotlabs\Extend\Hook::register('module_loaded', 'addon/gitwiki/gitwiki.php', '\\Gitwiki::module_loaded');
Zotlabs\Extend\Hook::register('load_pdl', 'addon/gitwiki/gitwiki.php', '\\Gitwiki::load_pdl');
}
function gitwiki_unload() {
Zotlabs\Extend\Hook::unregister_by_file('addon/gitwiki/gitwiki.php');
}
class Gitwiki {
static public function load_pdl(&$x) {
if($x['module'] === 'gitwiki')
$x['layout'] = '[region=aside][widget=vcard][/widget][widget=gitwiki_pages][/widget][/region]';
}
static public function module_loaded(&$b) {
if($b['module'] === 'gitwiki') {
require_once('addon/gitwiki/Mod_Gitwiki.php');
$b['controller'] = new \Zotlabs\Module\Gitwiki();
$b['installed'] = true;
}
}
}
function widget_gitwiki_pages($arr) {
$channelname = ((array_key_exists('channel',$arr)) ? $arr['channel'] : '');
$c = channelx_by_nick($channelname);
$wikiname = '';
if (array_key_exists('refresh', $arr)) {
$not_refresh = (($arr['refresh']=== true) ? false : true);
} else {
$not_refresh = true;
}
$pages = array();
if (! array_key_exists('resource_id', $arr)) {
$hide = true;
} else {
$p = wiki_page_list($arr['resource_id']);
if($p['pages']) {
$pages = $p['pages'];
$w = $p['wiki'];
// Wiki item record is $w['wiki']
$wikiname = $w['urlName'];
if (!$wikiname) {
$wikiname = '';
}
}
}
$can_create = perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'write_pages');
return replace_macros(get_markup_template('gitwiki_page_list.tpl','addon/gitwiki'), array(
'$hide' => $hide,
'$resource_id' => $arr['resource_id'],
'$not_refresh' => $not_refresh,
'$header' => t('Wiki Pages'),
'$channel' => $channelname,
'$wikiname' => $wikiname,
'$pages' => $pages,
'$canadd' => $can_create,
'$addnew' => t('Add new page'),
'$pageName' => array('pageName', t('Page name')),
));
}
function widget_gitwiki_list($arr) {
$channel = channelx_by_n(App::$profile_uid);
$wikis = wiki_list($channel, get_observer_hash());
if($wikis) {
return replace_macros(get_markup_template('gitwikilist_widget.tpl','addon/gitwiki'), array(
'$header' => t('Wiki List'),
'$channel' => $channel['channel_address'],
'$wikis' => $wikis['wikis']
));
}
return '';
}
function widget_gitwiki_page_history($arr) {
$pageUrlName = ((array_key_exists('pageUrlName', $arr)) ? $arr['pageUrlName'] : '');
$resource_id = ((array_key_exists('resource_id', $arr)) ? $arr['resource_id'] : '');
$pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
return replace_macros(get_markup_template('gitwiki_page_history.tpl','addon/gitwiki'), array(
'$pageHistory' => $pageHistory['history'],
'$permsWrite' => $arr['permsWrite']
));
}
This diff is collapsed.
This diff is collapsed.
<style>
.diff {
width:100%;
word-break: break-all;
}
.diff td{
padding:0 0.667em;
vertical-align:top;
white-space:pre;
white-space:pre-wrap;
font-family:Consolas,'Courier New',Courier,monospace;
font-size:1.0em;
line-height:1.333;
}
.diff span{
display:block;
min-height:1.333em;
margin-top:-1px;
padding:0 3px;
}
* html .diff span{
height:1.333em;
}
.diff span:first-child{
margin-top:0;
}
.diffDeleted span{
border:1px solid rgb(255,192,192);
background:rgb(255,224,224);
}
.diffInserted span{
border:1px solid rgb(192,255,192);
background:rgb(224,255,224);
}
</style>
<table class="table-striped table-responsive table-hover" style="width: 100%;">
{{foreach $pageHistory as $commit}}
<tr><td>
<table id="rev-{{$commit.hash}}" onclick="$('#details-{{$commit.hash}}').show()" width="100%">
<tr><td width="10%">Date</td><td width="70%">{{$commit.date}}</td>
<td rowspan="3" width="20%" align="right">
{{if $permsWrite}}
<button id="revert-{{$commit.hash}}" class="btn btn-danger btn-xs" onclick="wiki_revert_page('{{$commit.hash}}')">Revert</button>
<br><br>
{{/if}}
<button id="compare-{{$commit.hash}}" class="btn btn-warning btn-xs" onclick="wiki_compare_page('{{$commit.hash}}')">Compare</button>
</td></tr>
<tr><td>Name</td><td>{{$commit.name}} &lt;{{$commit.email}}&gt;</td></tr>
<tr><td>Message</td><td>{{$commit.title}}</td></tr>
</table>
</td></tr>
{{/foreach}}
</table>
{{if $not_refresh}}<div id="wiki_page_list_container" {{if $hide}} style="display: none;" {{/if}}>{{/if}}
<div id="wiki_page_list" class="widget" >
<h3>{{$header}}</h3>
<ul class="nav nav-pills nav-stacked">
{{if $pages}}
{{foreach $pages as $page}}
<li id="{{$page.link_id}}">
{{if $page.resource_id && $canadd}}
<i class="widget-nav-pills-icons fa fa-trash-o drop-icons" onclick="wiki_delete_page('{{$page.title}}', '{{$page.url}}', '{{$page.resource_id}}', '{{$page.link_id}}')"></i>
{{/if}}
<a href="/gitwiki/{{$channel}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a>
</li>
{{/foreach}}
{{/if}}
{{if $canadd}}
<li><a href="#" onclick="wiki_show_new_page_form(); return false;"><i class="fa fa-plus-circle"></i>&nbsp;{{$addnew}}</a></li>
{{/if}}
</ul>
{{if $canadd}}
<div id="new-page-form-wrapper" class="sub-menu" style="display:none;">
<form id="new-page-form" action="gitwiki/{{$channel}}/create/page" method="post" >
<input type="hidden" name="resource_id" value="{{$resource_id}}">
{{include file="field_input.tpl" field=$pageName}}
<button id="new-page-submit" class="btn btn-primary" type="submit" name="submit" >Submit</button>
</form>
</div>
{{/if}}
</div>
{{if $not_refresh}}</div>{{/if}}
<script>
$('#new-page-submit').click(function (ev) {
$.post("gitwiki/{{$channel}}/create/page", {pageName: $('#id_pageName').val(), resource_id: window.wiki_resource_id},
function(data) {
if(data.success) {
window.location = data.url;
} else {
window.console.log('Error creating page.');
}
}, 'json');
ev.preventDefault();
});
function wiki_delete_page(wiki_page_name, wiki_page_url, wiki_resource_id, wiki_link_id) {
if(!confirm('Are you sure you want to delete the page: ' + wiki_page_name)) {
return;
}
$.post("gitwiki/{{$channel}}/delete/page", {name: wiki_page_url, resource_id: wiki_resource_id},
function (data) {
if (data.success) {
window.console.log('Page deleted successfully.');
if(wiki_page_url == window.wiki_page_name) {
var url = window.location.href;
if(url.substr(-1) == '/')
url = url.substr(0, url.length - 2);
url = url.split('/');
url.pop();
window.location = url.join('/');
}
else {
$('#' + wiki_link_id).remove();
}
} else {
alert('Error deleting page.'); // TODO: Replace alerts with auto-timeout popups
window.console.log('Error deleting page.');
}
}, 'json');
return false;
}
function wiki_show_new_page_form() {
$('#new-page-form-wrapper').toggle();
$('#id_pageName').focus();
return false;
}
</script>
<div class="generic-content-wrapper">
<div class="section-title-wrapper">
{{if $owner}}
<button type="button" class="btn btn-success btn-xs pull-right acl-form-trigger" onclick="openClose('new-wiki-form-wrapper');" data-form_id="new-wiki-form"><i class="fa fa-plus-circle"></i>&nbsp;{{$create}}</button>
{{/if}}
<h2>{{$header}}</h2>
</div>
{{if $owner}}
<div id="new-wiki-form-wrapper" class="section-content-tools-wrapper">
<form id="new-wiki-form" action="gitwiki/{{$channel}}/create/wiki" method="post" class="acl-form" data-form_id="new-wiki-form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'>
{{include file="field_input.tpl" field=$wikiName}}
{{include file="field_select.tpl" field=$mimeType}}
{{include file="field_checkbox.tpl" field=$notify}}
<div>
<div class="btn-group pull-right">
<button id="dbtn-acl" class="btn btn-default btn-sm" data-toggle="modal" data-target="#aclModal" title="Permission settings" onclick="return false;">
<i id="jot-perms-icon" class="fa fa-{{$lockstate}} jot-icons"></i>
</button>
<button id="new-wiki-submit" class="btn btn-primary btn-sm" type="submit" name="submit" >{{$submit}}</button>
</div>
</div>
</form>
{{$acl}}
<div class="clear"></div>
</div>
{{/if}}
<div class="section-content-wrapper-np">
<table id="wikis-index">
<tr>
<th width="96%">{{$name}}</th>
<th width="1%">{{$type}}</th>
<th width="1%" class="wikis-index-tool"></th>
<th width="1%" class="wikis-index-tool"></th>
{{if $owner}}
<th width="1%"></th>
{{/if}}
</tr>
{{foreach $wikis as $wiki}}
<tr class="wikis-index-row">
<td><a href="/gitwiki/{{$channel}}/{{$wiki.urlName}}/Home" title="{{$view}}"{{if $wiki.active}} class="active"{{/if}}>{{$wiki.title}}</a></td>
<td>{{$wiki.mimeType}}</td>
<td class="wiki-index-tool dropdown">
{{if $wiki.lock}}
<i class="fa fa-lock dropdown-toggle lockview" data-toggle="dropdown" onclick="lockview('item',{{$wiki.id}});"></i></button>
<ul id="panel-{{$wiki.id}}" class="lockview-panel dropdown-menu dropdown-menu-right"></ul>
{{/if}}
</td>
<td class="wiki-index-tool"><i class="fa fa-download fakelink" onclick="wiki_download_wiki('{{$wiki.resource_id}}'); return false;"></i></td>
{{if $owner}}
<td><i class="fa fa-trash-o drop-icons" onclick="wiki_delete_wiki('{{$wiki.title}}', '{{$wiki.resource_id}}'); return false;"></i></td>
{{/if}}
</tr>
{{/foreach}}
</table>
</div>
</div>
<script>
{{if $owner}}
function wiki_delete_wiki(wikiHtmlName, resource_id) {
if(!confirm('Are you sure you want to delete the entire wiki: ' + JSON.stringify(wikiHtmlName))) {
return;
}
$.post("gitwiki/{{$channel}}/delete/wiki", {resource_id: resource_id}, function (data) {
if (data.success) {
window.console.log('Wiki deleted');
// Refresh list and redirect page as necessary
window.location = 'wiki/{{$channel}}';
} else {
alert('Error deleting wiki!');
window.console.log('Error deleting wiki.');
}
}, 'json');
}
{{/if}}
function wiki_download_wiki(resource_id) {
window.location = "gitwiki/{{$channel}}/download/wiki/" + resource_id;
}
</script>
<div id="wiki_list" class="widget">
<h3>{{$header}}</h3>
<ul class="nav nav-pills nav-stacked">
{{foreach $wikis as $wiki}}
<li><a href="/wiki/{{$channel}}/{{$wiki.urlName}}/Home" title="{{$view}}">{{$wiki.title}}</a></li>
{{/foreach}}
</ul>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment