From 0d6eace7ec69c0b9363b97437d2d3f793c8587c7 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 1 Sep 2005 00:46:38 +0000 Subject: [PATCH] Extracted HTML from files and into templates --- blame.php | 36 ++++++------- browse.php | 45 +++++++++------- diff.php | 88 ++++++++++++------------------- includes/init.php | 5 ++ index.php | 13 +++-- log.php | 64 ++++++++++------------ templates/default/blame.tpl | 18 +++++++ templates/default/blame_line.tpl | 5 ++ templates/default/browse.tpl | 18 +++++++ templates/default/browse_node.tpl | 9 ++++ templates/default/diff.tpl | 28 ++++++++++ templates/default/diff_file.tpl | 5 ++ templates/default/diff_hunk.tpl | 3 ++ templates/default/diff_line.tpl | 13 +++++ templates/default/index.tpl | 5 ++ templates/default/index_node.tpl | 1 + templates/default/log.tpl | 7 +++ templates/default/log_node.tpl | 10 ++++ templates/default/log_prop.tpl | 1 + templates/default/view.tpl | 24 +++++++++ view.php | 35 ++++++------ 21 files changed, 285 insertions(+), 148 deletions(-) create mode 100644 templates/default/blame.tpl create mode 100644 templates/default/blame_line.tpl create mode 100644 templates/default/browse.tpl create mode 100644 templates/default/browse_node.tpl create mode 100644 templates/default/diff.tpl create mode 100644 templates/default/diff_file.tpl create mode 100644 templates/default/diff_hunk.tpl create mode 100644 templates/default/diff_line.tpl create mode 100644 templates/default/index.tpl create mode 100644 templates/default/index_node.tpl create mode 100644 templates/default/log.tpl create mode 100644 templates/default/log_node.tpl create mode 100644 templates/default/log_prop.tpl create mode 100644 templates/default/view.tpl diff --git a/blame.php b/blame.php index 53d5645..f05e6f7 100644 --- a/blame.php +++ b/blame.php @@ -12,40 +12,40 @@ require_once('./global.php'); -echo $viewsvn->paths->construct_breadcrumb($path, false); +$navbar = $viewsvn->paths->construct_breadcrumb($path, false); -echo '
'; +// ################################################################### -echo 'View Log'; +$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path); -if ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD') +$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); +if ($show['head']) { - echo ' - Go to HEAD'; - echo ' - Diff to HEAD'; + $link['gohead'] = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path); + $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path); } -$prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num()); -if ($prev != -1) +$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); +if ($show['prev']) { - echo ' - Diff to PREV'; + $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path); } +// ################################################################### + $blame = new SVNBlame($repos, $relpath, $viewsvn->paths->fetch_rev_num()); -echo ''; +$lines = ''; foreach ($blame->fetch() AS $entry) { - echo ' - - - - - '; + $entry['line_clean'] = $viewsvn->svn->format($entry['line']); + eval('$lines .= "' . $template->fetch('blame_line') . '";'); } -echo ' -
' . $entry['rev'] . '' . $entry['author'] . '' . str_replace(array(' ', "\t"), array(' ', '     '), htmlspecialchars($entry['line'])) . '
'; +// ################################################################### + +eval('$template->flush("' . $template->fetch('blame') . '");'); /*=====================================================================*\ || ################################################################### diff --git a/browse.php b/browse.php index c7c00ee..ebb5ed6 100644 --- a/browse.php +++ b/browse.php @@ -12,49 +12,56 @@ require_once('./global.php'); -echo $viewsvn->paths->construct_breadcrumb($path); +$navbar = $viewsvn->paths->construct_breadcrumb($path); -echo '
'; +// ################################################################### -$prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num()); +$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path); -if ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD') +$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); +if ($show['head']) { - echo 'Go to HEAD' . - ' - Diff to HEAD'; + $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path); + $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path); } -echo ($prev != -1 ? ' - Diff to PREV' : '') . -' - View Log'; +$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); +if ($show['prev']) +{ + $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path); +} +// ################################################################### + +// #*# finish extracting this tpl echo '
' . print_r($viewsvn->svn->common->fetch_log($path, $viewsvn->paths->fetch_rev_num()), true) . '
'; $listing = $viewsvn->svn->ls($repos, $relpath, @$viewsvn->in['rev']); -echo ''; +// ################################################################### + +eval('$template->flush("' . $template->fetch('browse') . '");'); /*=====================================================================*\ || ################################################################### diff --git a/diff.php b/diff.php index ad46255..1e14247 100644 --- a/diff.php +++ b/diff.php @@ -12,7 +12,13 @@ require_once('./global.php'); -echo $viewsvn->paths->construct_breadcrumb($path, false); +$navbar = $viewsvn->paths->construct_breadcrumb($path, false); + +// ################################################################### + +$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path); + +// ################################################################### $revs = $viewsvn->paths->fetch_rev_num(true); $high = $revs['high']; @@ -32,79 +38,55 @@ $diff = new SVNDiff($repos, $relpath, $low, $high); $isdir = (bool)$viewsvn->svn->common->isdir($path); -echo << - - -HTML; +$changes = ''; foreach ($diff->fetch() AS $filename => $file) { - echo '

' . $filename . '

'; + $hunktpl = ''; foreach ($file AS $hunk) { - echo ''; - + $lines = ''; foreach ($hunk AS $key => $line) { + $show['hunk'] = false; if ($key == 'hunk' AND isset($line['old'])) { $filepath = ($isdir ? $path . $filename : $path); - echo ' - - - - - '; - continue; - } - - if ($line['act'] == '+') - { - $color = '#DDFFDD'; - } - else if ($line['act'] == '-') - { - $color = '#FFDDDD'; + $rlow = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $low), $filepath); + $rhigh = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $high), $filepath); + $show['hunk'] = true; } else { - $color = 'white'; + if ($line['act'] == '+') + { + $color = '#DDFFDD'; + } + else if ($line['act'] == '-') + { + $color = '#FFDDDD'; + } + else + { + $color = 'white'; + } + + $line['line_clean'] = $viewsvn->svn->format($line['line']); } - echo ' - - - - - '; + eval('$lines .= "' . $template->fetch('diff_line') . '";'); } - - echo ' -
r' . $low . 'r' . $high . ' 
' . $line['oldlineno'] . '' . $line['newlineno'] . '' . $viewsvn->svn->format($line['line']) . '
'; + eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";'); } - echo '
'; + eval('$changes .= "' . $template->fetch('diff_file') . '";'); } +// ################################################################### + +eval('$template->flush("' . $template->fetch('diff') . '");'); + /*=====================================================================*\ || ################################################################### || # $HeadURL$ diff --git a/includes/init.php b/includes/init.php index f1959a1..424e54e 100644 --- a/includes/init.php +++ b/includes/init.php @@ -41,6 +41,11 @@ $viewsvn->sourcepath = $viewsvn->fetch_sourcepath($issopath); $viewsvn->load('functions'); $viewsvn->exec_sanitize_data(); +// ################################################################### +// handle template system +$viewsvn->load('template_fs'); +$template->templatedir = $viewsvn->fetch_sourcepath('./templates/' . $templatedir); + // ################################################################### // imaginary reporter require_once('./includes/imaginary.php'); diff --git a/index.php b/index.php index 31e235a..50eb9ee 100644 --- a/index.php +++ b/index.php @@ -14,16 +14,19 @@ define('PATH_OVERRIDE', 1); require_once('./global.php'); -echo ''; +// ################################################################### + +eval('$template->flush("' . $template->fetch('index') . '");'); /*=====================================================================*\ || ################################################################### diff --git a/log.php b/log.php index a81313f..7423298 100644 --- a/log.php +++ b/log.php @@ -12,59 +12,53 @@ require_once('./global.php'); -echo $viewsvn->paths->construct_breadcrumb($path, false); +$navbar = $viewsvn->paths->construct_breadcrumb($path, false); -echo '
'; +// ################################################################### // this is NOT supposed to allow for revision ranges $logs = new SVNLog($repos, $relpath, 0, $viewsvn->paths->fetch_rev_num()); $isdir = $viewsvn->svn->common->isdir($path); -echo ''; +// ################################################################### + +eval('$template->flush("' . $template->fetch('log') . '");'); /*=====================================================================*\ || ################################################################### diff --git a/templates/default/blame.tpl b/templates/default/blame.tpl new file mode 100644 index 0000000..8b5e3e8 --- /dev/null +++ b/templates/default/blame.tpl @@ -0,0 +1,18 @@ +$navbar + +
+ +View Log + + + - Go to HEAD + - Diff to HEAD + + + + - Diff to PREV + + + +$lines +
\ No newline at end of file diff --git a/templates/default/blame_line.tpl b/templates/default/blame_line.tpl new file mode 100644 index 0000000..0400e1e --- /dev/null +++ b/templates/default/blame_line.tpl @@ -0,0 +1,5 @@ + + $entry[rev] + $entry[author] + $entry[line_clean] + diff --git a/templates/default/browse.tpl b/templates/default/browse.tpl new file mode 100644 index 0000000..4550fe4 --- /dev/null +++ b/templates/default/browse.tpl @@ -0,0 +1,18 @@ +$navbar + +
+ +View Log + + + - Go to HEAD + - Diff to HEAD + + + + - Diff to PREV + + + \ No newline at end of file diff --git a/templates/default/browse_node.tpl b/templates/default/browse_node.tpl new file mode 100644 index 0000000..b74ecaa --- /dev/null +++ b/templates/default/browse_node.tpl @@ -0,0 +1,9 @@ +
  • + + $item + + $item + - Blame + + - View Log +
  • diff --git a/templates/default/diff.tpl b/templates/default/diff.tpl new file mode 100644 index 0000000..b631ab4 --- /dev/null +++ b/templates/default/diff.tpl @@ -0,0 +1,28 @@ +$navbar + +
    + +View Log + + + +$changes \ No newline at end of file diff --git a/templates/default/diff_file.tpl b/templates/default/diff_file.tpl new file mode 100644 index 0000000..fdd371a --- /dev/null +++ b/templates/default/diff_file.tpl @@ -0,0 +1,5 @@ +

    $filename

    + +$hunktpl + +
    diff --git a/templates/default/diff_hunk.tpl b/templates/default/diff_hunk.tpl new file mode 100644 index 0000000..6fd47da --- /dev/null +++ b/templates/default/diff_hunk.tpl @@ -0,0 +1,3 @@ + +$lines +
    \ No newline at end of file diff --git a/templates/default/diff_line.tpl b/templates/default/diff_line.tpl new file mode 100644 index 0000000..523d796 --- /dev/null +++ b/templates/default/diff_line.tpl @@ -0,0 +1,13 @@ + + +
    r$low + r$high +   + + + + $line[oldlineno] + $line[newlineno] + $line[line_clean] + + \ No newline at end of file diff --git a/templates/default/index.tpl b/templates/default/index.tpl new file mode 100644 index 0000000..f26253f --- /dev/null +++ b/templates/default/index.tpl @@ -0,0 +1,5 @@ +Repositories: + + \ No newline at end of file diff --git a/templates/default/index_node.tpl b/templates/default/index_node.tpl new file mode 100644 index 0000000..126d632 --- /dev/null +++ b/templates/default/index_node.tpl @@ -0,0 +1 @@ +
  • $repos
  • diff --git a/templates/default/log.tpl b/templates/default/log.tpl new file mode 100644 index 0000000..07523cf --- /dev/null +++ b/templates/default/log.tpl @@ -0,0 +1,7 @@ +$navbar + +
    + + \ No newline at end of file diff --git a/templates/default/log_node.tpl b/templates/default/log_node.tpl new file mode 100644 index 0000000..a64dd55 --- /dev/null +++ b/templates/default/log_node.tpl @@ -0,0 +1,10 @@ +
  • + r$log[rev] + - View + - Blame + - Diff to HEAD + - Diff to PREV +
      +$props +
    +
  • diff --git a/templates/default/log_prop.tpl b/templates/default/log_prop.tpl new file mode 100644 index 0000000..41e6e7b --- /dev/null +++ b/templates/default/log_prop.tpl @@ -0,0 +1 @@ +
  • $key : $val
  • \ No newline at end of file diff --git a/templates/default/view.tpl b/templates/default/view.tpl new file mode 100644 index 0000000..20be49b --- /dev/null +++ b/templates/default/view.tpl @@ -0,0 +1,24 @@ +$navbar + +
    + +View Log + + + - Go to HEAD + - Diff to HEAD + + + + - Diff to PREV + + +
    $logmsg
    + + + + + +
    +$catdata +
    \ No newline at end of file diff --git a/view.php b/view.php index 48fa1ca..a8c902d 100644 --- a/view.php +++ b/view.php @@ -12,38 +12,37 @@ require_once('./global.php'); -echo $viewsvn->paths->construct_breadcrumb($path, false); +$navbar = $viewsvn->paths->construct_breadcrumb($path); -echo '
    '; +// ################################################################### -echo 'View Log'; +$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path); -if ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD') +$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); +if ($show['head']) { - echo ' - Go to HEAD'; - echo ' - Diff to HEAD'; + $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path); + $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path); } -$prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num()); -if ($prev != -1) +$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); +if ($show['prev']) { - echo ' - Diff to PREV'; + $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path); } +// ################################################################### + $logmsg = $viewsvn->svn->common->fetch_log($path, $viewsvn->paths->fetch_rev_num()); unset($logmsg['files']); -echo '
    ' . print_r($logmsg, true) . '
    '; -echo ' - - - -
    '; +$logmsg = print_r($logmsg, true); + +$catdata = $viewsvn->svn->format(implode("\n", $viewsvn->svn->cat($repos, $relpath, @$viewsvn->in['rev']))); -echo $viewsvn->svn->format(implode("\n", $viewsvn->svn->cat($repos, $relpath, @$viewsvn->in['rev']))); +// ################################################################### -echo ' -
    '; +eval('$template->flush("' . $template->fetch('view') . '");'); /*=====================================================================*\ || ################################################################### -- 2.22.5