diff --git a/src/main/scala/app/RepositoryViewerController.scala b/src/main/scala/app/RepositoryViewerController.scala index 5b3b3e2..036e186 100644 --- a/src/main/scala/app/RepositoryViewerController.scala +++ b/src/main/scala/app/RepositoryViewerController.scala @@ -356,7 +356,7 @@ repo.html.files(revision, repository, if(path == ".") Nil else path.split("/").toList, // current path new JGitUtil.CommitInfo(revCommit), // latest commit - files, readme) + files, readme, hasWritePermission(repository.owner, repository.name, context.loginAccount)) } } getOrElse NotFound } @@ -379,7 +379,7 @@ val headTip = git.getRepository.resolve(s"refs/heads/${branch}") JGitUtil.processTree(git, headTip){ (path, tree) => - if(path != newPath && !oldPath.exists(_ == path)){ + if(!newPath.exists(_ == path) && !oldPath.exists(_ == path)){ builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId)) } } @@ -387,8 +387,8 @@ newPath.foreach { newPath => builder.add(JGitUtil.createDirCacheEntry(newPath, FileMode.REGULAR_FILE, inserter.insert(Constants.OBJ_BLOB, content.getBytes(charset)))) - builder.finish() } + builder.finish() val commitId = JGitUtil.createNewCommit(git, inserter, headTip, builder.getDirCache.writeTree(inserter), loginAccount.fullName, loginAccount.mailAddress, message) diff --git a/src/main/twirl/repo/editor.scala.html b/src/main/twirl/repo/editor.scala.html index 2be0590..77d1026 100644 --- a/src/main/twirl/repo/editor.scala.html +++ b/src/main/twirl/repo/editor.scala.html @@ -27,6 +27,21 @@ }
+ + + | +
---|
@@ -59,17 +74,34 @@
$('#editor').text($('#initial').val());
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
+ editor.getSession().setUseWrapMode(false);
+
@if(fileName.isDefined){
editor.getSession().setMode("ace/mode/@editorType(fileName.get)");
}
+
editor.on('change', function(){
$('#commit').attr('disabled', editor.getValue() == $('#initial').val());
});
+ @*
+ $('#wrap').change(function(){
+ console.log($('#wrap option:selected').val());
+ if($('#wrap option:selected').val() == 'true'){
+ editor.getSession().setUseWrapMode(true);
+ } else {
+ editor.getSession().setUseWrapMode(false);
+ }
+ });
+
+ $('#indent').change(function(){
+ console.log($('#indent option:selected').val());
+ editor.getSession().setUseWrapMode(parseInt($('#indent option:selected').val()));
+ });
+ *@
+
$('#commit').click(function(){
$('#content').val(editor.getValue());
});
-
-
})
diff --git a/src/main/twirl/repo/files.scala.html b/src/main/twirl/repo/files.scala.html
index 0077f8c..aef88a2 100644
--- a/src/main/twirl/repo/files.scala.html
+++ b/src/main/twirl/repo/files.scala.html
@@ -3,7 +3,8 @@
pathList: List[String],
latestCommit: util.JGitUtil.CommitInfo,
files: List[util.JGitUtil.FileInfo],
- readme: Option[(List[String], String)])(implicit context: app.Context)
+ readme: Option[(List[String], String)],
+ hasWritePermission: Boolean)(implicit context: app.Context)
@import context._
@import view.helpers._
@html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
@@ -19,8 +20,9 @@
@pathList.zipWithIndex.map { case (section, i) =>
@section /
}
-
- +
+ @if(hasWritePermission){
+ +
+ }
|