Subhrajit

Subhrajit Bhattacharya

My website: http://subhrajit.net/wiki/
Comments, suggestions, questions, requests? Please drop a line in the talk page.

My PmWiki contributions

Recipes/modules I maintain:

  1. TrueLatex - an utility that uses server-side LaTeX and ImageMagik tools to interpret and render "true" LaTeX code
  2. YAG - "Yet Another Gallery tool" - a simple tool that creates and caches thumbnails of images, and can display them in gallery over multiple pages with links to original images.
  3. Live Edit - Edit blocks of wikitext right from the wiki page inside pop-up forms.
  4. GooGlURL - Provides PHP variable and Page Variable that contains the goo.gl shortened URL for the current page.
  5. EditForm Custom Fields - Add "Title", "Creation Time" and other input fields to the EditForm

Recipes/modules I have contributed to:

  1. Guestbook - Made a couple of important security fixes to the "Guestbook" module. (see comments section)
  2. AttachDelete - Rename attachments by appending a ".del-[timestamp]" extension instead of deleting them + bug fixes. (see comments section)


From my personal website

In 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.]


@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@# @#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#



Custom Markups: cookbook/mymarkup.php

In config.php: include_once('cookbook/mymarkup.php');

<?php if (!defined('PmWiki')) exit ();

// Constants

// HTML markups - by Hagan Fox
Markup(
  'html',
  'fulltext',
  '/\\(:html:\\)(.*?)\\(:htmlend:\\)/esi',
  "'<:block>'.Keep(str_replace(array('&gt;', '&lt;', '&amp;'),
  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: include_once('cookbook/mypagevariables.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: include_once('cookbook/mymarkupexpressions.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: include_once('cookbook/myconditions.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<<'''+&nbsp;&nbsp;'''[[#{(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]]


@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@# @#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#

Templates for include:

Includes.BlogTemplateA

Use: (:include Includes.BlogTemplateA:)


(: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/> &nbsp;
(:htmlend:)

Includes.CreateNewPageBox

Use: (:include Includes.CreateNewPageBox:)


(: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/> &nbsp;
(:htmlend:)

Includes.ListPagesInGroup

Use: .../index.php?n=Includes.ListPagesInGroup&param=GroupName


(:title A list of pages in this Group:)

(:pagelist group={(_GET param)}:)