akester/storehouse

Fork Project

2afecbc9750c8f193767f0db1046e57ff215b5f5

Authored By: Andrew Kester Date: July 7, 2017 9:45 pm

Update http and svn path functions

src/StorehouseBundle/Entity/Project.php
565 565
     }
566 566
 
567 567
     /**
568
-     * Get the path of a project
569
-     *
570
-     * @return string
571
-     */
572
-    public function getSshPrefix()
573
-    {
574
-        $prefix = '';
575
-
576
-        switch ($this->type) {
577
-            case 'hg':
578
-                $prefix = 'ssh://';
579
-                break;
580
-            case 'svn':
581
-                $prefix = 'svn+ssh://';
582
-                break;
583
-        }
584
-
585
-        return $prefix;
586
-    }
587
-
588
-    /**
568 589
      * Get the URL of this project (primarily for testing)
569 590
      *
570 591
      * @return string
642 621
     {
643 622
         return $this->legacyName;
644 623
     }
645
+
646
+    /**
647
+     * Get the SSH path of the project.
648
+     *
649
+     * @return string
650
+     */
651
+    public function getSshPath()
652
+    {
653
+        $path = '';
654
+
655
+        switch ($this->type) {
656
+            case 'hg':
657
+                $path = 'ssh://';
658
+                break;
659
+            case 'svn':
660
+                $path = 'svn+ssh://';
661
+                break;
662
+        }
663
+
664
+        $path .= 'sthse@sthse.co:/code/' . $this->getPath();
665
+
666
+        return $path;
667
+    }
668
+
669
+    /**
670
+     * Get HTTP Path of the project
671
+     *
672
+     * @return string|mixed
673
+     */
674
+    public function getHttpPath()
675
+    {
676
+        $path = 'http://' . $this->type . '.sthse.co/';
677
+
678
+        if ($this->type == 'svn') {
679
+            $path .= str_replace('/', '_', $this->getPath());
680
+        } else {
681
+            $path .= $this->getPath();
682
+        }
683
+
684
+        return $path;
685
+    }
686 624
 }
src/StorehouseBundle/Resources/views/Project/_Partials/RightSidebar.html.twig
37 37
 	</div>
38 38
 
39 39
 	{% if app.user %}
40
-		<input class="input-group-field" value="{{ context.project.sshPrefix }}sthse@sthse.co:/code/{{ context.project.path }}" readonly="" type="text">
40
+		<input class="input-group-field" value="{{ context.project.sshPath }}" readonly="" type="text">
41 41
 	{% else %}
42
-		<input class="input-group-field" value="https://sthse.co/code/{{ context.project.path }}" readonly="" type="text">
42
+		<input class="input-group-field" value="{{ context.project.httpPath }}" readonly="" type="text">
43 43
 	{% endif %}
44 44
 </div>
45 45
 
src/StorehouseBundle/Tests/Entity/ProjectTest.php
156 156
         $this->assertEquals('test-project', $project->getUrl());
157 157
         $this->assertEquals('test-project.git', $project->getPath());
158 158
         $this->assertEquals('old.git', $project->getLegacyPath());
159
-        $this->assertEquals('', $project->getSshPrefix());
159
+        $this->assertEquals('sthse@sthse.co:/code/test-project.git', $project->getSshPath());
160
+        $this->assertEquals('http://git.sthse.co/test-project.git', $project->getHttpPath());
161 160
     }
162 161
 
163 162
     /**
173 174
         $this->assertEquals('test-project', $project->getUrl());
174 175
         $this->assertEquals('test-project', $project->getPath());
175 176
         $this->assertEquals('old', $project->getLegacyPath());
177
-        $this->assertEquals('ssh://', $project->getSshPrefix());
176
+        $this->assertEquals('ssh://sthse@sthse.co:/code/test-project', $project->getSshPath());
177
+        $this->assertEquals('http://hg.sthse.co/test-project', $project->getHttpPath());
178 178
     }
179 179
 
180 180
     /**
190 192
         $this->assertEquals('test-project', $project->getUrl());
191 193
         $this->assertEquals('test-project', $project->getPath());
192 194
         $this->assertEquals('old', $project->getLegacyPath());
195
-        $this->assertEquals('svn+ssh://', $project->getSshPrefix());
193
+        $this->assertEquals('svn+ssh://sthse@sthse.co:/code/test-project', $project->getSshPath());
194
+        $this->assertEquals('http://svn.sthse.co/test-project', $project->getHttpPath());
195 196
     }
196 197
 
197 198
     /**
198 199