[dokuwiki] Submitting three darcs patches...
- From: "Ricky J. Sethi" <rickys@xxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Wed, 27 Feb 2008 16:00:29 -0800
Hello,
We've made some changes (patches attached) to the Dokuwiki src to allow:
* changing the default page for a namespace in an index
* customizing style.ini for each template
* parsing of .html (and .ihtml, .xhtml, etc.) files directly in addition
to .txt files
One of the main reasons we needed these solutions is for our use of
dokuwiki on http://www.madsci.org (I'm one of the principals of Madsci
trying to convert it to a Dokuwiki format). I'd like to maintain some
of the backend logic programs we have (that allow scientists and
moderators to pick and choose answers) and just change the presentation
logic to Dokuwiki (in fact, if anyone wants to volunteer to help with
our back-end programming efforts on madsci.org, please do let me know! :).
All the best,
Rick.
--
When one tugs at a single thing in nature, he finds it attached to the
rest of the world.
-- John Muir, naturalist, explorer, and writer (1838-1914)
-------------------------------------------------
[change_default_page_for_namespace
Ricky J. Sethi <rickys@xxxxxxxxx>**20071219082232
Change the default page for a namespace in an index; e.g., when you
click the index, it currently displays a
''http://family.sethi.org/community/index?idx=user_pages''. After the
change, it'll instead display:
''http://family.sethi.org/community/user_pages/'' (works on all our dokuwiki
farms)
] {
hunk ./inc/html.php 638
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./inc/html.php 641
- global $ID;
+ global $ID, $conf;
hunk ./inc/html.php 645
+
hunk ./inc/html.php 647
- $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'"
class="idx_dir"><strong>';
- $ret .= $base;
+ $ret .= '<a href="'. wl($item['id'].":") .'" class="idx_dir"><strong>';
// Shows URL correctly
+ $ret .= ucwords(str_replace("_"," ",$base));
hunk ./inc/html.php 653
+
hunk ./inc/html.php 699
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./inc/html.php 702
+ global $conf;
+
hunk ./inc/html.php 710
+ if( ($conf['start'] != '' &&
+ preg_match('/\/'.$conf['start'].'$/',$item['id']) && // Changed
to check if it ends in "/notes" instead of ending in just "notes"
+ $item['level'] != 1
+ )
+ ) {
+ continue;
+ }
+
hunk ./inc/pageutils.php 20
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./inc/pageutils.php 27
+ if ( substr($_REQUEST['id'], -1) == "/" ) {
+ $id .= $conf['start'];
+ }
+
}
[customized_style.ini
Ricky J. Sethi <rickys@xxxxxxxxx>**20071206104407
Customized style.ini for each template
] {
hunk ./lib/exe/css.php 29
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./lib/exe/css.php 48
+ // Check default template_style_ini: added the following new
configuration parameter to ''local.php'': $conf['template_style_ini'] =
'style.ini_investments';
+ // Also replaced all style.ini with $conf['template_style_ini']
+ if( !isset($conf['template_style_ini']) ||
!@file_exists(DOKU_TPLINC.$conf['template_style_ini']) ) {
+ $conf['template_style_ini'] = 'style.ini';
+ }
+
hunk ./lib/exe/css.php 56
- if(@file_exists(DOKU_TPLINC.'style.ini')){
- $ini = parse_ini_file(DOKU_TPLINC.'style.ini',true);
+ if(@file_exists(DOKU_TPLINC.$conf['template_style_ini'])){
+ $ini = parse_ini_file(DOKU_TPLINC.$conf['template_style_ini'],true);
hunk ./lib/exe/css.php 134
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./lib/exe/css.php 145
- $files[] = DOKU_TPLINC.'style.ini';
+ $files[] = DOKU_TPLINC.$conf['template_style_ini'];
hunk ./lib/exe/css.php 162
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./lib/exe/css.php 165
- if(@file_exists(DOKU_TPLINC.'style.ini')){
- $ini = parse_ini_file(DOKU_TPLINC.'style.ini',true);
+ // Added for template_style_ini:
+ global $conf;
+
+ if(@file_exists(DOKU_TPLINC.$conf['template_style_ini'])){
+ $ini = parse_ini_file(DOKU_TPLINC.$conf['template_style_ini'],true);
}
[parse_html_directly
Ricky J. Sethi <rickys@xxxxxxxxx>**20071219075416
Directly parse .html in addition to .txt files (this is instead of
making files like foo.html.txt); useful for both legacy systems and
dokuwiki farms setup using standard HTML authoring tools.
] {
hunk ./inc/pageutils.php 212
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./inc/pageutils.php 228
- if(empty($rev)){
- $fn = $conf['datadir'].'/'.utf8_encodeFN($id).'.txt';
- }else{
- $fn = $conf['olddir'].'/'.utf8_encodeFN($id).'.'.$rev.'.txt';
- if($conf['compression']){
- //test for extensions here, we want to read both compressions
- if (@file_exists($fn . '.gz')){
- $fn .= '.gz';
- }else if(@file_exists($fn . '.bz2')){
- $fn .= '.bz2';
- }else{
- //file doesnt exist yet, so we take the configured extension
- $fn .= '.' . $conf['compression'];
- }
- }
- }
+
+ $fn = checkFN($id, $rev);
hunk ./inc/pageutils.php 235
+
+
+
+/**
+ * returns the full path to the datafile specified by ID and optional revision
(if it doesn't exist, returns a default FN)
+ *
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
+ */
+function checkFN($clean_id, $rev) {
+ global $conf;
+
+ $defaultExtension = "txt";
+
+ if ( empty($rev) ) {
+ $defaultFN = $conf['datadir'] .'/'. utf8_encodeFN($clean_id) .'.'.
$defaultExtension;
+ $baseFN = $conf['datadir'] .'/'. utf8_encodeFN($clean_id);
+ } else {
+ $defaultFN = $conf['olddir'] .'/'. utf8_encodeFN($clean_id) .'.'. $rev
.'.'. $defaultExtension .'.'. $conf['compression'];
+ $baseFN = $conf['olddir'] .'/'. utf8_encodeFN($clean_id) .'.'. $rev;
+ }
+
+ $validExtensionsArray = array("txt", "html", "ihtml");
+ $validCompressionsArray = array("gz", "bz2");
+ reset($validExtensionsArray);
+ reset($validCompressionsArray);
+
+ $fn = "";
+
+ foreach ($validExtensionsArray as $ext) {
+ $fn = $baseFN .'.'. $ext;
+
+ if ( @file_exists( $fn ) ) {
+ // Return found $fn asap
+ return $fn;
+ }
+
+ if ($conf['compression']) {
+ $compBaseFN = $fn;
+
+ foreach ($validCompressionsArray as $compExt) {
+ //test for extensions here, we want to read all allowed compressions
+ $fn = $compBaseFN .'.'. $compExt;
+ if ( @file_exists($fn) ) {
+ // Return found $fn asap
+ return $fn;
+ }
+ }
+ }
+
+ }
+
+ // If filename doesn't exist already, return the defaultFN so it can create
it
+ return $defaultFN;
+}
hunk ./inc/search.php 144
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./inc/search.php 155
- }elseif($type == 'f' && ($opts['nofiles'] || substr($file,-4) != '.txt')){
+ }elseif( $type == 'f' && ( $opts['nofiles'] || !(
preg_match('#\.txt$#',$file) || preg_match('#\.html$#',$file) ||
preg_match('#\.ihtml$#',$file) ) ) ) {
hunk ./inc/search.php 507
+ * @author Ricky J. Sethi <rickys@xxxxxxxxx>
hunk ./inc/search.php 513
- if(!$keeptxt) $id = preg_replace('#\.txt$#','',$id);
+ if(!$keeptxt) {
+ $id = preg_replace('#\.txt$#','',$id);
+ $id = preg_replace('#\.html$#','',$id);
+ $id = preg_replace('#\.ihtml$#','',$id);
+ }
}
- Follow-Ups:
- [dokuwiki] Re: Submitting three darcs patches...
- From: Guy Brand
Other related posts:
- » [dokuwiki] Submitting three darcs patches...
- » [dokuwiki] Re: Submitting three darcs patches...
- » [dokuwiki] Re: Submitting three darcs patches...
- » [dokuwiki] Re: Submitting three darcs patches...
- » [dokuwiki] Re: Submitting three darcs patches...
- [dokuwiki] Re: Submitting three darcs patches...
- From: Guy Brand