Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: masamitsu-murase/browse_subversion_in_browser
base: 87212c2ba1
...
head fork: masamitsu-murase/browse_subversion_in_browser
compare: 9669f1de09
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
49 extension/dav_svn.js
@@ -16,6 +16,25 @@ var gDavSvn = (function(){
};
};
+ var findFirstChildNodeValue = function(item, name){
+ var elem = item.getElementsByTagName(name);
+ if (!elem){
+ return null;
+ }
+
+ var first = elem[0];
+ if (!first){
+ return null;
+ }
+
+ var first_child = first.firstChild;
+ if (!first_child){
+ return null;
+ }
+
+ return first_child.nodeValue;
+ };
+
var doXmlHttpRequest = function(method, url, header, body, callback){
var url = url.replace(/\/$/, "");
@@ -226,11 +245,12 @@ var gDavSvn = (function(){
var tags = doc.getElementsByTagName("log-item");
for (var i=0; i<tags.length; i++){
var log = tags[i];
+ var rev = findFirstChildNodeValue(log, "version-name");
logs.push({
- revision: parseInt(log.getElementsByTagName("version-name")[0].firstChild.nodeValue),
- comment: log.getElementsByTagName("comment")[0].firstChild.nodeValue,
- author: log.getElementsByTagName("creator-displayname")[0].firstChild.nodeValue,
- date: log.getElementsByTagName("date")[0].firstChild.nodeValue
+ revision: ((rev || rev !== null) ? parseInt(rev) : null),
+ comment: findFirstChildNodeValue(log, "comment"),
+ author: findFirstChildNodeValue(log, "creator-displayname"),
+ date: findFirstChildNodeValue(log, "date")
});
}
}catch(e){
@@ -243,7 +263,13 @@ var gDavSvn = (function(){
var davSvnGetResources = function(bc_url, callback){
var body = '<?xml version="1.0" encoding="utf-8"?>'
- + '<propfind xmlns="DAV:"><prop><resourcetype xmlns="DAV:"/></prop></propfind>';
+ + '<propfind xmlns="DAV:"><prop>'
+ + '<creator-displayname xmlns="DAV:"/>'
+ + '<creationdate xmlns="DAV:"/>'
+ + '<version-name xmlns="DAV:"/>'
+ + '<getcontentlength xmlns="DAV:"/>'
+ + '<resourcetype xmlns="DAV:"/>'
+ + '</prop></propfind>';
davSvnPropfind(bc_url, { "Depth": 1 }, body, function(res){
var array = [];
try{
@@ -258,9 +284,14 @@ var gDavSvn = (function(){
var type = (item.getElementsByTagName("resourcetype")[0]
.getElementsByTagName("collection").length == 1) ? "directory" : "file";
+ var rev = findFirstChildNodeValue(item, "version-name");
array.push({
href: href,
- type: type
+ type: type,
+ author: findFirstChildNodeValue(item, "creator-displayname"),
+ date: findFirstChildNodeValue(item, "creationdate"),
+ revision: ((rev || rev !== null) ? parseInt(rev) : null),
+ size: findFirstChildNodeValue(item, "getcontentlength")
});
}
}catch(e){
@@ -436,7 +467,11 @@ var gDavSvn = (function(){
file_list: file_list.map(function(item){
return {
path: item.href.substr(bc.bc.length).replace(/\/$/, ""),
- type: item.type
+ type: item.type,
+ revision: item.revision,
+ author: item.author,
+ date: item.date,
+ size: item.size
};
}),
revision: rev
View
37 extension/repository_view/dav_svn_model.js
@@ -114,6 +114,17 @@ DavSvnResource.prototype = {
isLoaded: function(){
return this.m_state == DavSvnResource.STATE_LOADED;
},
+ isLoading: function(){
+ return this.m_state == DavSvnResource.STATE_LOADING;
+ },
+
+ info: function(attr){
+ if (attr){
+ return this.m_info[attr];
+ }else{
+ return this.m_info;
+ }
+ },
debugInfo: function(level){
level = (level || 0);
@@ -205,13 +216,27 @@ DavSvnModel.prototype = {
// add files
var target_info = obj.file_list.shift();
+ var info = {
+ author: target_info.author,
+ revision: target_info.revision,
+ date: target_info.date,
+ size: target_info.size
+ };
var target_resource = new DavSvnResource(target_info.path.split("/").pop(),
(target_info.type == "file" ? DavSvnResource.TYPE_FILE
- : DavSvnResource.TYPE_DIRECTORY));
+ : DavSvnResource.TYPE_DIRECTORY),
+ info);
obj.file_list.forEach(function(file){
+ var info = {
+ author: file.author,
+ revision: file.revision,
+ date: file.date,
+ size: file.size
+ };
var child = new DavSvnResource(file.path.split("/").pop(),
(file.type == "file" ? DavSvnResource.TYPE_FILE
- : DavSvnResource.TYPE_DIRECTORY));
+ : DavSvnResource.TYPE_DIRECTORY),
+ info);
target_resource.addChild(child);
});
target_resource.markLoaded();
@@ -230,6 +255,14 @@ DavSvnModel.prototype = {
});
},
changePath: function(path){
+ var changed = (this.m_current_path != path);
+ this.m_current_path = path;
+ if (changed){
+ this.notify();
+ }
+ },
+ path: function(){
+ return this.m_current_path;
},
// Directory operation
View
BIN  extension/repository_view/images/icon_reload.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
38 extension/repository_view/repository_view.css
@@ -1,5 +1,8 @@
/* DirectoryView */
+#output{
+ overflow: auto;
+}
div.svn_root{
}
dt.svn_resource_title > span{
@@ -34,12 +37,45 @@ dd.svn_children_root{
dd.svn_children_root > ul{
list-style: none;
+ margin: 5px 0px;
+ padding-left: 1em;
+}
+
+dd.svn_children_root > ul > li > dl{
+ margin: 5px 0px;
+}
+
+/* file list */
+#file_list{
+ float: right;
+ width: 50%;
+ overflow: auto;
+}
+table.file_list_view{
+ border-collapse: collapse;
+}
+table.file_list_view th, table.file_list_view td{
+ /* border: 1px solid black; */
+}
+table.file_list_view tbody tr:nth-child(odd){
+ background-color: #DDD;
+}
+table.file_list_view tbody td.loading{
+ padding-left: 2em;
+ background-image: url("./images/ajax_loader.gif") !important;
+ background-size: 1em;
+ background-position: left center;
+ background-repeat: no-repeat;
}
/* LogView */
-dl.log_view{
+#log{
float: right;
width: 20em;
+ max-width: 25%;
+ overflow: auto;
+}
+dl.log_view{
}
dl.log_view > dt{
word-wrap: break-word;
View
6 extension/repository_view/repository_view.html
@@ -17,8 +17,10 @@
<input type="text" value="1000000" id="revision" />
<button id="change_revision">Change Revision</button>
</p>
- <p id="log"></p>
- <p id="output" style="white-space: pre;"></p>
+ <div id="basic_info"></div>
+ <div id="log"></div>
+ <div id="file_list"></div>
+ <div id="output" style="white-space: pre;"></div>
<hr style="clear: both;" />
<div id="tree"></div>
</body>
View
161 extension/repository_view/repository_view.js
@@ -5,8 +5,6 @@
this.m_root_div = this.createRootDiv();
this.m_view_elem.appendChild(this.m_root_div);
this.m_model = model;
-
- this.m_log_view = null;
};
DirectoryView.prototype = {
update: function(){
@@ -17,9 +15,8 @@
var root_div = this.m_root_div;
// remove current children
- var children = root_div.childNodes;
- for (var i=0; i<children.length; i++){
- root_div.removeChild(children[i]);
+ while(root_div.firstChild){
+ root_div.removeChild(root_div.firstChild);
}
// append new child
@@ -27,10 +24,6 @@
root_div.appendChild(this.createResourceNode(dir));
},
- setLogView: function(log_view){
- this.m_log_view = log_view;
- },
-
createRootDiv: function(){
var elem = document.createElement("div");
elem.className = DirectoryView.CLASS_ROOT_DIV;
@@ -69,24 +62,26 @@
var path = rsc.path();
var self = this;
path_elem.addEventListener("click", function(){
- if (self.m_log_view){
- self.m_log_view.updateLog(path);
- }
-
self.m_model.changePath(path);
if (rsc.isLoaded()){
+ self.m_model.changePath(path);
self.m_model.toggleDirectory(path)
}else{
+ self.m_model.changePath(path);
self.m_model.reloadPath(path);
self.m_model.openDirectory(path);
}
});
+ // TODO
+ // Modify icon.
var reload_elem = document.createElement("img");
title.appendChild(reload_elem);
- reload_elem.src = "images/icon_folder_opened.png";
+ reload_elem.src = "images/icon_reload.gif";
+ reload_elem.style.height = "1em";
reload_elem.alt = "Reload";
reload_elem.addEventListener("click", function(e){
+ self.m_model.changePath(path);
self.m_model.reloadPath(path);
});
}
@@ -114,7 +109,7 @@
var ul_children = document.createElement("ul");
children_root.appendChild(ul_children);
- rsc.childDirs().concat(rsc.childFiles()).forEach(function(child){
+ rsc.childDirs().forEach(function(child){
var li = document.createElement("li");
ul_children.appendChild(li);
li.appendChild(this.createResourceNode(child));
@@ -131,11 +126,92 @@
DirectoryView.CLASS_TYPE_FILE = "type_file";
+ var FileListView = function(elem, model){
+ // construct file list table.
+ var table = document.createElement("table");
+ elem.appendChild(table);
+ table.className = FileListView.CLASS_ROOT_TABLE;
+
+ var attrs = [ "author", "revision", "date", "size" ];
+
+ // header
+ var thead = document.createElement("thead");
+ table.appendChild(thead);
+ var tr = document.createElement("tr");
+ thead.appendChild(tr);
+ var th = document.createElement("th");
+ tr.appendChild(th);
+ th.appendChild(document.createTextNode("Name"));
+ attrs.forEach(function(attr){
+ th = document.createElement("th");
+ tr.appendChild(th);
+ th.appendChild(document.createTextNode(attr));
+ });
+
+ // tbody
+ var tbody = document.createElement("tbody");
+ table.appendChild(tbody);
+
+ this.m_model = model;
+ this.m_tbody = tbody;
+ };
+ FileListView.prototype = {
+ update: function(){
+ var current_path = this.m_model.path();
+
+ // remove
+ while(this.m_tbody.firstChild){
+ this.m_tbody.removeChild(this.m_tbody.firstChild);
+ }
+
+ // add
+ var rsc = this.m_model.resource(current_path);
+ if (rsc.isLoading()){
+ var tr = document.createElement("tr");
+ this.m_tbody.appendChild(tr);
+
+ var td = document.createElement("td");
+ tr.appendChild(td);
+ td.setAttribute("colspan", 5);
+ td.className = FileListView.CLASS_LOADING;
+ td.appendChild(document.createTextNode("Loading"));
+ }else{
+ var self = this;
+ rsc.childDirs().concat(rsc.childFiles()).forEach(function(child){
+ var tr = document.createElement("tr");
+ self.m_tbody.appendChild(tr);
+
+ var td = document.createElement("td");
+ tr.appendChild(td);
+ td.appendChild(document.createTextNode(child.name()));
+
+ [ "author", "revision", "date", "size" ].forEach(function(attr){
+ td = document.createElement("td");
+ tr.appendChild(td);
+ td.appendChild(document.createTextNode(child.info(attr)));
+ });
+ });
+ }
+ }
+ };
+ FileListView.CLASS_ROOT_TABLE = "file_list_view";
+ FileListView.CLASS_LOADING = "loading";
+
+
var LogView = function(elem, model){
this.m_view_elem = elem;
this.m_model = model;
+ this.m_path = null;
};
LogView.prototype = {
+ update: function(){
+ var path = this.m_model.path();
+ if (this.m_path !== path){
+ this.m_path = path;
+ this.updateLog(path);
+ }
+ },
+
updateLog: function(path){
var url = this.m_model.repositoryInfo().root_url + path;
var self = this;
@@ -149,9 +225,8 @@
},
updateLogHelper: function(url, logs){
- var children = this.m_view_elem.childNodes;
- for (var i=0; i<children.length; i++){
- this.m_view_elem.removeChild(children[i]);
+ while(this.m_view_elem.firstChild){
+ this.m_view_elem.removeChild(this.m_view_elem.firstChild);
}
var elem = document.createElement("dl");
@@ -182,6 +257,44 @@
LogView.CLASS_LOG_VIEW = "log_view";
+ var BasicInfoView = function(elem, model){
+ this.m_model = model;
+
+ while(elem.firstChild){
+ elem.removeChild(elem.firstChild);
+ }
+
+ var dl = document.createElement("dl");
+ elem.appendChild(dl);
+ var dt = document.createElement("dt");
+ dl.appendChild(dt);
+ dt.appendChild(document.createTextNode("Path"));
+ var dd = document.createElement("dd");
+ dl.appendChild(dd);
+ this.m_path_elem = dd;
+
+ dt = document.createElement("dt");
+ dl.appendChild(dt);
+ dt.appendChild(document.createTextNode("Revision"));
+ dd = document.createElement("dd");
+ dl.appendChild(dd);
+ this.m_revision_elem = dd;
+ };
+ BasicInfoView.prototype = {
+ update: function(){
+ if (this.m_path_elem.firstChild){
+ this.m_path_elem.removeChild(this.m_path_elem.firstChild);
+ }
+ this.m_path_elem.appendChild(document.createTextNode(this.m_model.repositoryInfo().root_url + this.m_model.path()));
+
+ if (this.m_revision_elem.firstChild){
+ this.m_revision_elem.removeChild(this.m_revision_elem.firstChild);
+ }
+ this.m_revision_elem.appendChild(document.createTextNode(this.m_model.operationRevision()));
+ }
+ };
+
+
var load = function(){
// for test
var elem = document.getElementById("test");
@@ -195,8 +308,16 @@
var dv = new DirectoryView(elem, model);
model.addListener(dv);
- var log_elem = document.getElementById("log");
- dv.setLogView(new LogView(log_elem, model));
+ var log_view = new LogView(document.getElementById("log"), model);
+ model.addListener(log_view);
+
+ // file list
+ var file_list_view = new FileListView(document.getElementById("file_list"), model);
+ model.addListener(file_list_view);
+
+ // basic info
+ var basic_info_view = new BasicInfoView(document.getElementById("basic_info"), model);
+ model.addListener(basic_info_view);
/// test
document.getElementById("change_revision").addEventListener("click", function(){

No commit comments for this range

Something went wrong with that request. Please try again.