sweeper/webif/plugin/sweeper/edit.jim

196 lines
5.1 KiB
Plaintext
Executable File

#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require system.class
set dir [cgi_get dir ""]
if {$dir eq ""} { set dir [system mediaroot] }
jscss {schema.js config.jim script.js} style.css
jqplugin confirmAction enadis
header
if {![file isdirectory $dir]} {
puts "<h3>No such directory, $dir</h3>"
exit
}
puts "
<h3>
<img src=img/icon22.png> Sweeper rules for
<span class=\"dir hidden\">$dir</span>
"
# Breadcrumb path
set stub ""
foreach part [split $dir /] {
if {$stub eq "/"} { set name $part } else { set name "/$part" }
append stub $name
puts "<a href=\"/browse?dir=[cgi_quote_url $stub]\">$name</a>
}
puts {
<span id=pendingnote class="blood hidden">
(changes pending, not yet saved.)
</span>
</h3>
<div id=ruleset></div>
<div id=buttons>
<button id=b_add>Add rule</button>
<button id=b_save>Save changes</button>
<button id=b_revert>Discard changes</button>
<button id=b_show>View configuration</button>
<button id=b_test>Test configuration</button>
<button id=b_raw>Toggle raw display</button>
</div>
<div id=output></div>
<div id=macros>
Add pre-defined ruleset:
<select id=macroselect>
<option value=0>--- Select ruleset ---</option>
</select>
<button id=b_macro>Add to rules</button>
</div>
<div id=rule_template class="hidden">
<fieldset class=rule>
<legend class=comment>
<span class=commentleft>
<span class="ruleicon folder hidden">
<img src=/images/711_1_09_Media_Folder.png>
</span>
<span class="ruleicon file hidden">
<img src=/img/Video_TS_New.png>
</span>
<span class=comment>Unnamed rule</span>
<a class=editcomment href=#>
<img src=/img/context/edit.png>
</a>
</span>
<span class=legendright>
<span class="disabledtext blood hidden">
(Disabled)
</span>
<a class=enadisrule href=#>
<img src=img/disable.png
title="Enable/Disable Rule">
</a>
<a class=delrule href=#>
<img src=/img/context/delete.png
title="Delete Rule">
</a>
<a class=cprule href=#>
<img src=/img/context/page_white_copy.png
title="Duplicate Rule">
</a>
<a class=uprule href=#>
<img src=/img/nav/up.png
title="Move Rule Up">
</a>
<a class=downrule href=#>
<img src=/img/nav/down.png
title="Move Rule Down">
</a>
</span>
</legend>
<a href=# class=addcriterion>
<img src=img/plus.png
title="Add condition">
</a>
<div class=criteria>
<table class="criteria"><tbody></tbody></table>
</div>
<div class=arrow>
<img src=img/arrow.png height=32>
</div>
<div class=action>
<table class="action"><tbody></tbody></table>
</div>
<div class=raw></div>
</fieldset>
</div>
<div class=hidden id=edit_text title="Edit text">
<input name=edit_text_field id=edit_text_field size=80 maxlength=255 />
</div>
<div class=hidden id=edit_int title="Edit int">
<select name=edit_int_op id=edit_int_op>
<option value='='>=</option>
<option value='&gt;'>&gt;</option>
<option value='&lt;'>&lt;</option>
<option value='&gt;='>&gt;=</option>
<option value='&lt;='>&lt;=</option>
</select>
<input name=edit_int_field id=edit_int_field type=number
size=5 maxlength=6 />
</div>
<div class=hidden id=edit_select title="Edit select">
<select name=edit_select_field id=edit_select_field>
</select>
</div>
<div class=hidden id=showconf title="Generated Configuration File">
</div>
<div class=hidden id=newrule title="Add New Rule">
Rule Type:
<input name=newrule_type id=newrule_type_file type=radio
value='file' checked />Process Files
<input name=newrule_type id=newrule_type_folder type=radio
value='folder' />Process Folders
<br>
Description:
<input name=newrule_comment id=newrule_comment size=80 maxlength=255 />
</div>
<div class=hidden id=newcondition title="Add New Condition">
<table>
<tr><th>Condition:</th><td>
<select id=newcondition_cmd name=newcondition_cmd></select>
</td></tr><tr><th>Negate?</th><td>
<input id=newcondition_negate name=newcondition_negate type=checkbox
value='1' title="Invert the sense of the condition."/>
</td></tr>
</table>
</div>
<div class=hidden id=edit_action title="Rule Action">
<select name=edit_action_act id=edit_action_act></select>
<input name=edit_action_arg id=edit_action_arg size=60 maxlength=255 />
<div class="hidden edit_action_help blood" id=edit_action_help_folder>
Enter one of:
<ul>
<li>Relative folder path (e.g. <i>Films/Children</i>);</li>
<li>Absolute path (e.g. <i>/media/drive1/archive</i>);</li>
<li>Leave blank to indicate the media root (i.e. My Video).</li>
</ul>
Tokens may be used, for example <i>Archive/%genre</i>
</div>
<div class="hidden edit_action_help blood"
id=edit_action_help_filenamebase>
Enter new filename base (no extension) e.g. %title_%yyyymmdd_%hhmm
</div>
</div>
<div class=hidden id=testresults title="Test current ruleset">
<span class=blood>
The following output shows what would happen if these rules were applied.
No changes have been made.
</span>
<div id=testresults_inner></div>
</div>
<div class=hidden id=empty_rulebase>
<b>There are no rules currently defined for this folder.</b>
<br>
You can add some example rules by using the <i>Add pre-defined ruleset</i>
option at the bottom of the screen.
</div>
}
footer