|
Profiles /
SubhrajitSubhrajit BhattacharyaMy website: http://fling.seas.upenn.edu/~subhrabh/ My PmWiki contributionsRecipes/modules I maintain:
Recipes/modules I have contributed to:
Contents From my personal websiteIn my personal web-site I use several customized markups, templates, etc. While many of those may not be even relevant to other people, you may find a few concepts useful for your site. So in this section I will share with you the customizations I use in my site. [NOTE: Some of the contents below are adopted from or inspired by ideas discussed by other users in PmWiki. They deserve the full credit for the ideas. No violation of intellectual property rights intended. The sole purpose of the discussions below is to help other users of PmWiki.] In config.php:
<?php if (!defined('PmWiki')) exit ();
// Constants
// HTML markups - by Hagan Fox
Markup(
'html',
'fulltext',
'/\\(:html:\\)(.*?)\\(:htmlend:\\)/esi',
"'<:block>'.Keep(str_replace(array('>', '<', '&'),
array('>', '<', '&'), PSS('$1')))");
// [[*PathToFile]] - to create links to files on file server http://www.subhrajit.net/
Markup('ExtLinks', 'fulltext', "/\\[\\[\\*\\s*(.*?)\\s*\\]\\]/esi", "Keep('<a href=\"http://www.subhrajit.net/files/'.PSS('$1').'\">'.basename(PSS('$1')).'</a>')");
// [[*PathToFile|Link Text]]
Markup('ExtLinksWithText', '<ExtLinks', "/\\[\\[\\*\\s*([^|\\]]*?)\\s*\\|\\s*(.*?)\\s*\\]\\]/esi", "Keep('<a href=\"http://www.subhrajit.net/files/'.PSS('$1').'\">'.PSS('$2').'</a>')");
// [% ... %] comment
Markup('blockcomment','_begin','/\\[%(.*?)%\\]/esi',"Keep('')");
// (:preg_include [include_options] regex=/.../ies delimiter=... [pindex=0]:)
Markup('preginclude', '>include',
'/\\(:preg_include\\s+(\\S.*?)\\s+regex\\s*=\\s*(.*?)\\s+delimiter\\s*=\\s*"(.*?)"\\s*:\\)/ei',
"PRR(preg_IncludeText(\$pagename, PSS('$1'), PSS('$2'), PSS('$3')))");
Markup('pregincludeindex', '<preginclude',
'/\\(:preg_include\\s+(\\S.*?)\\s+regex\\s*=\\s*(.*?)\\s+delimiter\\s*=\\s*"(.*?)"\\s+pindex\\s*=\\s*(\d+)\\s*:\\)/ei',
"PRR(preg_IncludeText(\$pagename, PSS('$1'), PSS('$2'), PSS('$3'), PSS('$4')))");
function preg_IncludeText($pagename, $inclspec, $regex, $delimiter="", $pindex=0) {
$theText = IncludeText($pagename, $inclspec);
preg_match_all($regex, $theText, $theMatches, PREG_PATTERN_ORDER);
$delimiter = str_replace(
array("\\n", "\\r", "\\t"),
array("\n", "\r", "\\t"),
$delimiter );
return(implode($delimiter, $theMatches[$pindex]));
}
?>
Custom Page variables: cookbook/mypagevariables.php In config.php:
<?php
$FmtPV['$MaxUploadSize'] = 'min(intval(ini_get("upload_max_filesize")), intval('.$UploadMaxSize/(1024*1024).')) . " M"';
$FmtPV['$PageCreationDate'] = 'strftime("%b %d, %Y", $page["ctime"])';
$thispagename = @$_REQUEST['n'];
$thispage = ReadPage($thispagename);
$FmtPV['$RawTitle'] = '"'.$thispage['title'].'"';
?>
Custom Markup Expressions: cookbook/mymarkupexpressions.php In config.php:
<?php
$MarkupExpr['md5'] = 'md5($args[0])';
$MarkupExpr['_GET'] = '$_GET["$args[0]"]';
// {(GETrequest "http://www.theurl.com/index.php" "arg1=value1" "arg2=value2" ... )}
$MarkupExpr['GETrequest'] = 'GETrequest($args)';
function GETrequest($theArgs) {
$theURL = $theArgs[0].'?';
for ($a=1; $a<sizeof($theArgs); $a++) {
$argParts = explode('=', $theArgs[$a], 2);
$theURL = $theURL.$argParts[0].'='.urlencode($argParts[1]).'&';
}
return file_get_contents($theURL);
}
?>
Custom Conditions: cookbook/myconditions.php In config.php:
<?php
$Conditions['doesPagenameContainDash'] = "preg_match('/-/',FmtPageName('\$Name',\$pagename))";
$Conditions['action'] = '\$GLOBALS["action"]==\$condparm';
$Conditions['StringEquals'] = 'parseStringEqual($condparm)';
function parseStringEqual($condstatement) {
$strParts = explode('==', $condstatement);
return (trim($strParts[0])==trim($strParts[1]));
}
?>
Local Templates: Site.LocalTemplates
====================================================================
Template for displaying snippets of blog items:
[[#blogcontent]]
(:if auth edit:)
(:if:)
!!![[{=$FullName}| [+{=$Title}+] ]] [[#{(reg_replace '/(\w+)-(\w+)/i' '$2' {=$Name})}]]
(:include {=$FullName}# lines=10 self=0:)
[[{=$FullName} | [-[Read More...]-] ]]
----
(:if equal {>$Group}:)
(:title {$Title}:)(:if:)
[[#blogcontentend]]
====================================================================
Template for listing blog items:
[[#bloglist]]
>>class=littleoutdent<<'''+ '''[[#{(reg_replace '/(\w+)-(\w+)/i' '$2' {=$Name})} | {=$Title} ]]
>><<
(:if equal {>$Group}:)
(:title {$Title}:)(:if:)
[[#bloglistend]]
====================================================================
Template for listing pages that link to their edit page:
[[#edit]]
* [[{=$FullName}?action=edit | [+{=$Name}+]]]
[[#editend]]
====================================================================
Display format for TODO list:
[[#todolist]]
[[{=$FullName}|{=$Title}]]:[[<<]]
(:preg_include {=$FullName} regex=/'''(.*?)TODO(.*?)'''(\S?)\s*(.*?)[\n\)\]]/i delimiter="[[<<]]" pindex=4 :)[[<<]][[<<]]
[[#todolistend]]
Includes.BlogTemplateA Use:
(:comment - To create a new blog just include this template in a new page :)
>>rframe width=200px<<
'''Contents:'''
(:PageList group={$Group} name={(reg_replace '/(\w+)-(\w+)/i' '${1}' {$Name})}-* fmt=#bloglist list=normal order=-ctime :)
>><<
(:PageList group={$Group} name={(reg_replace '/(\w+)-(\w+)/i' '${1}' {$Name})}-* fmt=#blogcontent list=normal order=-ctime class="":)
(:html:)
<div style="float:right;">
<input type="text" class="txt" id="NewBlogName" name="NewBlogName" />
<input type="button" class="btn" onclick="window.location='?n={$FullName}-' + document.getElementById('NewBlogName').value.replace(/-|&|\?/g,' ') + '&action=edit'" value="Create Entry" />
</div>
<br/>
(:htmlend:)
Includes.CreateNewPageBox Use:
(:html:)
<div style="float:right;">
<input type="text" class="txt" id="NewBlogName" name="NewBlogName" />
<input type="button" class="btn" onclick="window.location='?n={$Group}.' + document.getElementById('NewBlogName').value.replace(/-|&|\?/g,' ') + '&action=edit'" value="Create New" />
</div>
<br/>
(:htmlend:)
Includes.ListPagesInGroup Use:
(:title A list of pages in this Group:)
(:pagelist group={(_GET param)}:)
|