Skip to content

Commit 3260fbe

Browse files
committed
Successfully open file in browser
1 parent 5e82964 commit 3260fbe

File tree

9 files changed

+72
-9
lines changed

9 files changed

+72
-9
lines changed

app/assets/javascripts/repository/tab.js.erb

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ function addTab(link) {
1515
var path = $(link).attr("rel");
1616
var modelist = ace.require("ace/ext/modelist");
1717
var mode = modelist.getModeForPath(path).mode;
18+
$(".current").attr('mode',mode);
1819
console.log(mode);
1920
editor.session.setMode(mode);
21+
if (mode=="ace/mode/html")
22+
{
23+
assign($(link).attr('rel'));
24+
}
25+
else{
26+
$(".actions").show();
27+
$(".compile").hide();
28+
}
2029
editor.setTheme('ace/theme/twilight');
2130
console.log(path);
2231
console.log(url);
@@ -34,11 +43,7 @@ function addTab(link) {
3443
console.log(error);
3544
}
3645
});
37-
console.log($(link).attr('rel'));
38-
var a="<%=Dir.pwd%>";
39-
a= a.replace("home/sifat/directory/public/system/repositories/","")
40-
console.log("a="+a);
41-
$(".compile").attr('href',a+"/"+$(link).attr('rel'));
46+
4247
$(function() {
4348
$('#res-tab').on('change', function() {
4449
var current = $(this).find(':selected').text();
@@ -53,6 +58,13 @@ function addTab(link) {
5358
$('#tabs-editor li').each(function() {
5459
if ($(this).attr('id') == current) {
5560
$(this).addClass("current");
61+
if($(this).attr('mode')=='ace/mode/html'){
62+
assign(current);
63+
}
64+
else{
65+
$(".actions").show();
66+
$(".compile").hide();
67+
}
5668
}
5769
});
5870
console.log(current);
@@ -68,6 +80,14 @@ function addTab(link) {
6880
console.log($(this).attr('id'));
6981
if ($(this).attr('id') == $(current).attr('id')) {
7082
$(this).addClass("current");
83+
if($(this).attr('mode')=='ace/mode/html'){
84+
assign($(current).attr('id'));
85+
86+
}
87+
else{
88+
$(".actions").show();
89+
$(".compile").hide();
90+
}
7191
}
7292
});
7393
});
@@ -95,3 +115,12 @@ function addTab(link) {
95115
});
96116
});
97117
}
118+
function assign(current){
119+
console.log("current="+current);
120+
$(".actions").show();
121+
$(".compile").show();
122+
var a=$(".root-list").attr('datapath');
123+
a= a.replace("home/sifat/directory/public/system/repositories/","")
124+
console.log("a="+a);
125+
$(".compile").attr('href',a+"/"+current);
126+
}

app/assets/stylesheets/base/_atom.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,13 @@ a.link {
9696
height:5%;
9797
color:$silver;
9898
}
99+
100+
.actions{
101+
background-color:$bg-actions;
102+
display:none;
103+
text-align: right;
104+
}
105+
.compile{
106+
text-decoration: none;
107+
color: $silver;
108+
}

app/assets/stylesheets/base/_molecule.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@import "variable.scss";
2-
32
.traversal {
43
ul {
54
a,
@@ -39,9 +38,16 @@
3938
}
4039
}
4140
}
41+
.editor-wrapper{
42+
height:95%;
43+
width:100%;
44+
.actions{
45+
height:5%;
46+
}
47+
}
4248

4349
ul#tabs-editor {
44-
height: 95%;
50+
height:inherit;
4551
width: 100%;
4652
list-style: none;
4753
display: flex;

app/assets/stylesheets/base/_variable.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ $search: #171717;
1414
$tab-border: #7e6800;
1515
$inactive-color: #0b2833;
1616
$hover-color: #131313;
17+
$bg-actions:#1a1c1d;

app/controllers/gitrepos_controller.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ def show
1717
@file = Dir.glob('**/*')
1818
end
1919

20+
def moveto
21+
goto = {}
22+
request.path_parameters.each do |key, value|
23+
goto[key] = value
24+
end
25+
path = "/system/repositories/github/#{goto[:id]}/#{goto[:url]}#{goto[:all]}"
26+
redirect_to(path)
27+
end
28+
2029
private
2130

2231
def gitrepo_params

app/controllers/repositories_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ def new
66
end
77

88
def index
9+
Dir.chdir(Rails.root)
10+
puts "present directory=#{Dir.pwd}"
911
@repository = Repository.all
1012
@gitrepo = Gitrepo.all
1113
end
@@ -72,6 +74,7 @@ def show_repo
7274
path = "public/system/repositories/uploads/extract/#{@repository.id}"
7375
@path = Rails.root.join(path, @folder)
7476
Dir.chdir(@path)
77+
puts "after click= #{Dir.pwd}"
7578
@file = Dir.glob('**/*')
7679
end
7780

app/helpers/repositories_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def traversal
5858
end
5959
end
6060
puts @final_tree
61-
@html << '<ul>'
61+
@html << "<ul class=root-list datapath=#{Dir.pwd}>"
6262
if @final_tree.is_a?(Hash)
6363
mainlist = callHash(@final_tree)
6464
puts "mainlist----#{mainlist}"

app/views/repositories/_traversal.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
<div class="search-result"> </div>
66
<%=raw traversal%>
77
</div>
8-
<a class=compile target="_blank">compile</a>
98
<div class=pannels>
109
<select id = 'res-tab'> </select>
1110
<ul id="tabs"></ul>
11+
<div class=editor-wrapper>
12+
<div class=actions>
13+
<a class=compile target=_blank>Open</a>
14+
</div>
1215
<ul id="tabs-editor"></ul>
16+
</div>
1317
</div>
1418
</div>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
post 'gitrepos/newrepo'
44
get 'gitrepos/:id', to: 'gitrepos#show', as: 'gitrepo'
55
post 'gitrepos', to: 'gitrepos#create'
6+
get 'github/:id/:url(*all)', to: 'gitrepos#moveto'
67
devise_for :users, controllers: { registrations: 'registrations' }
78
get 'repositories/new'
89
get 'repositories/:id', to: 'repositories#show', as: 'repository'

0 commit comments

Comments
 (0)