gitlabhq/doc/code/classes/TreeController.html

264 lines
9 KiB
HTML
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>TreeController</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="banner">
<h1>
<span class="type">Class</span>
TreeController
<span class="parent">&lt;
<a href="ProjectResourceController.html">ProjectResourceController</a>
</span>
</h1>
<ul class="files">
<li><a href="../files/app/controllers/tree_controller_rb.html">app/controllers/tree_controller.rb</a></li>
</ul>
</div>
<div id="bodyContent">
<div id="content">
<div class="description">
<p>Controller for viewing a repositorys file structure</p>
</div>
<!-- Method ref -->
<div class="sectiontitle">Methods</div>
<dl class="methods">
<dt>E</dt>
<dd>
<ul>
<li>
<a href="#method-i-edit">edit</a>
</li>
</ul>
</dd>
<dt>S</dt>
<dd>
<ul>
<li>
<a href="#method-i-show">show</a>
</li>
</ul>
</dd>
<dt>U</dt>
<dd>
<ul>
<li>
<a href="#method-i-update">update</a>
</li>
</ul>
</dd>
</dl>
<!-- Includes -->
<div class="sectiontitle">Included Modules</div>
<ul>
<li>
<a href="ExtractsPath.html">
ExtractsPath
</a>
</li>
</ul>
<!-- Methods -->
<div class="sectiontitle">Instance Public methods</div>
<div class="method">
<div class="title method-title" id="method-i-edit">
<b>edit</b>()
<a href="../classes/TreeController.html#method-i-edit" name="method-i-edit" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-edit_source')" id="l_method-i-edit_source">show</a>
</p>
<div id="method-i-edit_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/tree_controller.rb, line 24</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">edit</span>
<span class="ruby-ivar">@last_commit</span> = <span class="ruby-ivar">@project</span>.<span class="ruby-identifier">last_commit_for</span>(<span class="ruby-ivar">@ref</span>, <span class="ruby-ivar">@path</span>).<span class="ruby-identifier">sha</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-show">
<b>show</b>()
<a href="../classes/TreeController.html#method-i-show" name="method-i-show" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-show_source')" id="l_method-i-show_source">show</a>
</p>
<div id="method-i-show_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/tree_controller.rb, line 13</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">show</span>
<span class="ruby-ivar">@hex_path</span> = <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-ivar">@path</span>)
<span class="ruby-ivar">@logs_path</span> = <span class="ruby-identifier">logs_file_project_ref_path</span>(<span class="ruby-ivar">@project</span>, <span class="ruby-ivar">@ref</span>, <span class="ruby-ivar">@path</span>)
<span class="ruby-identifier">respond_to</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span>
<span class="ruby-comment"># Disable cache so browser history works</span>
<span class="ruby-identifier">format</span>.<span class="ruby-identifier">js</span> { <span class="ruby-identifier">no_cache_headers</span> }
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-update">
<b>update</b>()
<a href="../classes/TreeController.html#method-i-update" name="method-i-update" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-update_source')" id="l_method-i-update_source">show</a>
</p>
<div id="method-i-update_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/tree_controller.rb, line 28</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">update</span>
<span class="ruby-identifier">edit_file_action</span> = <span class="ruby-constant">Gitlab</span><span class="ruby-operator">::</span><span class="ruby-constant">Satellite</span><span class="ruby-operator">::</span><span class="ruby-constant">EditFileAction</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">current_user</span>, <span class="ruby-ivar">@project</span>, <span class="ruby-ivar">@ref</span>, <span class="ruby-ivar">@path</span>)
<span class="ruby-identifier">updated_successfully</span> = <span class="ruby-identifier">edit_file_action</span>.<span class="ruby-identifier">commit!</span>(
<span class="ruby-identifier">params</span>[<span class="ruby-value">:content</span>],
<span class="ruby-identifier">params</span>[<span class="ruby-value">:commit_message</span>],
<span class="ruby-identifier">params</span>[<span class="ruby-value">:last_commit</span>]
)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">updated_successfully</span>
<span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">project_tree_path</span>(<span class="ruby-ivar">@project</span>, <span class="ruby-ivar">@id</span>), <span class="ruby-identifier">notice</span><span class="ruby-operator">:</span> <span class="ruby-string">&quot;Your changes have been successfully commited&quot;</span>
<span class="ruby-keyword">else</span>
<span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-string">&quot;Your changes could not be commited, because the file has been changed&quot;</span>
<span class="ruby-identifier">render</span> <span class="ruby-value">:edit</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html>