From b881ad1c8fbbc0c86ab343c99ab660f2cd41840c Mon Sep 17 00:00:00 2001
From: Nicolas Lassalle
Date: Fri, 12 Sep 2008 12:32:27 +0200
Subject: [PATCH] [PATCH] Restructured the "source views" file hierarchy.
Svn specifics Views are now in a Source subfolder.
---
src/IDF/Views/Source.php | 63 -----------------
src/IDF/Views/Source/Svn.php | 93 +++++++++++++++++++++++++
src/IDF/conf/views.php | 4 +-
src/IDF/templates/source/changelog.html | 2 +-
src/IDF/templates/source/svn/tree.html | 2 +-
5 files changed, 97 insertions(+), 67 deletions(-)
create mode 100644 src/IDF/Views/Source/Svn.php
diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php
index bfdbf9e..173010a 100644
--- a/src/IDF/Views/Source.php
+++ b/src/IDF/Views/Source.php
@@ -234,69 +234,6 @@ class IDF_Views_Source
return $rep;
}
- /**
- * Display tree of a specific SVN revision
- *
- */
- public function treeRev($request, $match)
- {
- $prj = $request->project;
-
- // Redirect to tree base if not svn
- if ($request->conf->getVal('scm', 'git') != 'svn') {
- $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
- array($prj->shortname, $prj->getScmRoot()));
-
- return new Pluf_HTTP_Response_Redirect($url);
- }
-
- // Get revision value
- if (!isset($request->REQUEST['rev']) or trim($request->REQUEST['rev']) == '') {
- $scmRoot = $prj->getScmRoot();
- }
- else {
- $scmRoot = $request->REQUEST['rev'];
- }
-
- // Get source if not /
- if (isset($request->REQUEST['sourcefile']) and trim($request->REQUEST['sourcefile']) != '') {
- $scmRoot .= '/'.$request->REQUEST['sourcefile'];
- }
-
- // Redirect
- $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
- array($prj->shortname, $scmRoot));
- return new Pluf_HTTP_Response_Redirect($url);
- }
-
- /**
- * Display SVN changelog from specific revision
- *
- */
- public function changelogRev($request, $match)
- {
- $prj = $request->project;
-
- // Redirect to tree base if not svn
- if ($request->conf->getVal('scm', 'git') != 'svn') {
- $scmRoot = $prj->getScmRoot();
- }
- // Get revision value if svn
- else {
- if (!isset($request->REQUEST['rev']) or trim($request->REQUEST['rev']) == '') {
- $scmRoot = $prj->getScmRoot();
- }
- else {
- $scmRoot = $request->REQUEST['rev'];
- }
- }
-
- // Redirect
- $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::changeLog',
- array($prj->shortname, $scmRoot));
- return new Pluf_HTTP_Response_Redirect($url);
- }
-
/**
* Find the mime type of a file.
*
diff --git a/src/IDF/Views/Source/Svn.php b/src/IDF/Views/Source/Svn.php
new file mode 100644
index 0000000..74ef8f4
--- /dev/null
+++ b/src/IDF/Views/Source/Svn.php
@@ -0,0 +1,93 @@
+project;
+
+ // Redirect to tree base if not svn
+ if ($request->conf->getVal('scm', 'git') != 'svn') {
+ $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
+ array($prj->shortname, $prj->getScmRoot()));
+
+ return new Pluf_HTTP_Response_Redirect($url);
+ }
+
+ // Get revision value
+ if (!isset($request->REQUEST['rev']) or trim($request->REQUEST['rev']) == '') {
+ $scmRoot = $prj->getScmRoot();
+ }
+ else {
+ $scmRoot = $request->REQUEST['rev'];
+ }
+
+ // Get source if not /
+ if (isset($request->REQUEST['sourcefile']) and trim($request->REQUEST['sourcefile']) != '') {
+ $scmRoot .= '/'.$request->REQUEST['sourcefile'];
+ }
+
+ // Redirect
+ $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
+ array($prj->shortname, $scmRoot));
+ return new Pluf_HTTP_Response_Redirect($url);
+ }
+
+ /**
+ * Display SVN changelog from specific revision
+ *
+ */
+ public function changelogRev($request, $match)
+ {
+ $prj = $request->project;
+
+ // Redirect to tree base if not svn
+ if ($request->conf->getVal('scm', 'git') != 'svn') {
+ $scmRoot = $prj->getScmRoot();
+ }
+ // Get revision value if svn
+ else {
+ if (!isset($request->REQUEST['rev']) or trim($request->REQUEST['rev']) == '') {
+ $scmRoot = $prj->getScmRoot();
+ }
+ else {
+ $scmRoot = $request->REQUEST['rev'];
+ }
+ }
+
+ // Redirect
+ $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::changeLog',
+ array($prj->shortname, $scmRoot));
+ return new Pluf_HTTP_Response_Redirect($url);
+ }
+}
\ No newline at end of file
diff --git a/src/IDF/conf/views.php b/src/IDF/conf/views.php
index 2c62968..4a65b97 100644
--- a/src/IDF/conf/views.php
+++ b/src/IDF/conf/views.php
@@ -168,13 +168,13 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/source/download/(\w+)/$#',
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/treerev/$#',
'base' => $base,
'priority' => 4,
- 'model' => 'IDF_Views_Source',
+ 'model' => 'IDF_Views_Source_Svn',
'method' => 'treeRev');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/changesrev/$#',
'base' => $base,
'priority' => 4,
- 'model' => 'IDF_Views_Source',
+ 'model' => 'IDF_Views_Source_Svn',
'method' => 'changelogRev');
// ---------- Downloads ------------------------------------
diff --git a/src/IDF/templates/source/changelog.html b/src/IDF/templates/source/changelog.html
index 904fc54..fb57bd8 100644
--- a/src/IDF/templates/source/changelog.html
+++ b/src/IDF/templates/source/changelog.html
@@ -37,7 +37,7 @@
{/if}
{if $scm == 'svn'}
-