Skip to content

Commit

Permalink
Issue #6: added Build project feature. Build system is set in project…
Browse files Browse the repository at this point in the history
… settings
  • Loading branch information
Volodymyr Sergeyev committed Feb 1, 2013
1 parent 7143766 commit 287ee50
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
51 changes: 43 additions & 8 deletions ide/controllers/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,46 @@ def project_settings():

project_settings = dict(request.POST)

#try:
fo = open(item.abs_path() + "/.liveideproject", "r+")
fo.truncate(0)
fo.write(json.dumps(project_settings))
#finally:
fo.close()

return json.dumps(project_settings)
try:
fo = open(item.abs_path() + "/.liveideproject", "r+")
fo.truncate(0)
fo.write(json.dumps(project_settings))
finally:
fo.close()

return json.dumps(project_settings)


@login_required
@get("/project_build/")
def project_build():
'''
Execute project `build` command from Settings and return output to UI
'''

user_id = User().id
item = models.Project.find_one({"id": request.GET.get("id")})
res = ""

if user_id != item.user_id:
return "User ID not match with project ID!"

settings = item.get_settings()
if not "build" in settings:
return "Specify build system in Settings first!"

p = subprocess.Popen(
(settings["build"]),
cwd=item.abs_path(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)

output, errors = p.communicate()

res += output + "\n"
res += errors + "\n"

res += 'process ended with return code %i' % p.returncode

return res
18 changes: 15 additions & 3 deletions ide/static/js/liveide-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@
/* Settings of project */
settings: function (project) {
var s = $.extend({
build: "python",
build: "",
description: ""
}, project.settings),
form = $("<form></form>");
form.append("<label>Build system:</label> <input type=text name='build' value='" + s.build + "' />");
form.append("<label>Description:</label> <textarea name='description'>" + s.description + "</textarea>");
form.append("<label>Build system:</label> <input type=text class='span6' name='build' value='" + s.build + "' />");
form.append("<label>Description:</label> <textarea name='description' class='span6'>" + s.description + "</textarea>");

bootbox.form("Project settings", form, function($form) {
if (!$form) return;
Expand Down Expand Up @@ -332,6 +332,18 @@
}
});
});
},

/* Build project */
build: function (project) {
if (!project.settings.build)
return that.flash("Specify build system in Settings first!", true);

$.get("/project_build/", {"id": project.id}, function (data) {
that.dom.console.append("<pre>" + data + "</pre>");
that.dom.console.find("pre:last")[0].scrollIntoView(true);
that.flash("Build complete");
});
}
}

Expand Down
8 changes: 8 additions & 0 deletions ide/static/js/liveide.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
rename: $(".liveide-project-rename"),
copy: $(".liveide-project-copy"),
open: $(".liveide-project-open"),
build: $(".liveide-project-build"),
close: $(".liveide-project-close"),
remove: $(".liveide-project-remove"),
settings: $(".liveide-project-settings"),
Expand Down Expand Up @@ -519,6 +520,13 @@
that.project.copy(that.active.project);
});

/* Project -> Build project... */
this.dom.project.build.on("click", function (e) {
e.preventDefault();
if (that.active.project)
that.project.build(that.active.project);
});

/* Project -> Close */
this.dom.project.close.on("click", function (e) {
var project = that.active.project;
Expand Down
6 changes: 6 additions & 0 deletions ide/views/layout.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@
<li class="divider"></li>
<li><a tabindex="-1" href="#" class="liveide-folder-new">New Folder</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#" class="liveide-project-build">Build</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#" class="liveide-project-close">Close Project</a></li>
<!--
<li class="divider"></li>
<li><a tabindex="-1" href="#" class="liveide-project-remove">Delete Project</a></li>
-->
<li class="divider"></li>
<li><a tabindex="-1" href="#" class="liveide-project-download">Download Project</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#" class="liveide-project-settings">Settings</a></li>
</ul>

<ul id="liveide-folder-menu" class="dropdown-menu context-menu liveide-dropdownmenu" role="menu">
Expand Down Expand Up @@ -170,6 +174,8 @@
<li><a href="#" class="liveide-project-rename">Rename...</a></li>
<li><a href="#" class="liveide-project-copy">Copy Project...</a></li>
<li class="divider"></li>
<li><a href="#" class="liveide-project-build">Build</a></li>
<li class="divider"></li>
<li><a href="#" class="liveide-project-close">Close Project</a></li>
<!--
<li class="divider"></li>
Expand Down

0 comments on commit 287ee50

Please sign in to comment.