forked from jdorfman/commando
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-recipe.php
90 lines (81 loc) · 3.75 KB
/
add-recipe.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
# Copyright 2012 NodeSocket, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
($_SERVER['SCRIPT_NAME'] !== "/controller.php") ? require_once(__DIR__ . "/classes/Requires.php") : Links::$pretty = true;
//Get settings
$settings = null;
$result = MySQLQueries::get_settings();
$row = MySQLConnection::fetch_object($result);
if(isset($row->data)) {
$row->data = json_decode($row->data);
}
$settings = $row;
$interpreters = array("shell", "bash", "perl", "python", "node.js");
Header::set_title("Commando.io - Add Recipe");
Header::render(array("chosen", "codemirror"));
Navigation::render("recipes");
?>
<div class="container">
<h1 class="header">Add Recipe</h1>
<div class="row">
<div class="span12 well">
<form id="form-add-recipe" class="well form-horizontal" method="post" action="/actions/add_recipe.php">
<fieldset>
<div class="control-group">
<label class="control-label" for="recipe-name">Name</label>
<div class="controls">
<input type="text" class="input-large" id="recipe-name" name="name" placeholder="RECIPE NAME" maxlength="30" />
<p class="help-block">The recipe name. Must be unique.</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="recipe-interpreter">Interpreter</label>
<div class="controls">
<select name="interpreter" id="recipe-interpreter" class="span2" data-placeholder="">
<?php foreach($interpreters as $interpreter): ?>
<option value="<?php echo $interpreter ?>" <?php if(isset($settings->data->default_interpreter) && $interpreter === $settings->data->default_interpreter): ?>selected="selected" <?php endif; ?>><?php echo ucfirst($interpreter) ?></option>
<?php endforeach; ?>
</select>
<p class="help-block">The interpreter to execute the recipe with. If you wish to write scripts with control structures and functions select an interpreter other than shell.</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="recipe-notes">Notes</label>
<div class="controls">
<textarea id="recipe-notes" name="notes"></textarea>
<p class="help-block" style="clear: both;">Optional notes and comments you wish to attach to the recipe. <a href="http://daringfireball.net/projects/markdown/">Markdown</a> is supported.</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="recipe-editor">Recipe</label>
<div class="controls">
<textarea id="recipe-editor" name="content"></textarea>
<p class="help-block" style="clear: both;"></p>
</div>
</div>
<div class="control-group">
<div class="controls">
<a class="btn btn-primary" id="add-recipe-submit" onclick="validate_add_recipe();"><i class="icon-ok-sign icon-white"></i> Add Recipe</a>
<a class="btn" href="<?php echo Links::render("recipes") ?>">Cancel</a>
</div>
</div>
</fieldset>
</form>
</div>
</div>
<?php
Footer::render(array("chosen", "codemirror", "autosize", "add-recipe"));
?>