sweeper/webif/plugin/sweeper/edit.jim

282 lines
8.5 KiB
Plaintext
Executable File

#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require system.class browse.class plugin
set dir [cgi_get dir ""]
set root [system mediaroot]
if {$dir eq ""} { set dir $root }
jscss {schema.js macro.js config.jim} style.css
eval_plugins sweeperjs
jscss {action.js script.js}
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>
<span class=\"root hidden\">$root</span>
"
# Breadcrumb path
browse breadcrumb $dir
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 config</button>
<button id=b_test>Test config</button>
<button id=b_run>Run now</button>
<button id=b_edit>Text editor</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 recurse hidden">
<img src=/images/711_1_09_Media_Folder.png>
</span>
<span class="ruleicon file recurse hidden">
<img src=/img/Video_TS_New.png>
</span>
<span class=comment>Unnamed rule</span>
<a class=editcomment href=#>
<img src=img/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/delete.png
title="Delete Rule">
</a>
<a class=cprule href=#>
<img src=img/page_white_copy.png
title="Duplicate Rule">
</a>
<a class=uprule href=#>
<img src=img/up.png
title="Move Rule Up">
</a>
<a class=downrule href=#>
<img src=img/down.png
title="Move Rule Down">
</a>
</span>
</legend>
<div class="filecomment hidden">
For each recording
<a class=editdepth href=#><img src=img/edit.png></a>:
</div>
<div class="foldercomment hidden">
For each sub-folder, inspect a recording within and:
</div>
<div class="recursecomment hidden">
For each recording and recordings within folders
(<span class=depth></span> deep<a class=editdepth href=#><img src=img/edit.png></a>):
</div>
<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 class="hidden edit_text_help blood" id=edit_text_help_substr>
<br>
You can enter either a substring which must be found somewhere or a pattern<br>
which must be matched.
<br>
For pattern matching, the following special sequences may appear in the pattern:
<div style="width: 600px;margin: 1em">
* - Matches any sequence of characters in string, including none.
<br>
? - Matches any single character in string.
<br>
[chars] - Matches any character in the set given by chars. If a sequence of the form x-y appears in chars, then any character between x and y, inclusive, will match.
<br>
\x - Matches the single character x. This provides a way of avoiding the special interpretation of the characters \*?[] in pattern.
</div>
</div>
</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_plainint title="Edit int">
<span id=edit_plainint_title></span>
<input name=edit_plainint_field id=edit_plainint_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=edit_textmatch title="Edit textmatch">
<input name=edit_textmatch_target id=edit_textmatch_target
size=20 maxlength=255 />
<input name=edit_textmatch_pattern id=edit_textmatch_pattern
size=20 maxlength=255 />
<div class="hidden edit_textmatch_help blood"
id=edit_textmatch_help_textmatch>
<br>
You can enter either a substring which must be found somewhere, a pattern<br>
which must be matched or a regular expression prefixed with ~.
<br>
For pattern matching, the following special sequences may appear in the pattern:
<div style="width: 600px;margin: 1em">
* - Matches any sequence of characters in string, including none.
<br>
? - Matches any single character in string.
<br>
[chars] - Matches any character in the set given by chars. If a sequence of the form x-y appears in chars, then any character between x and y, inclusive, will match.
<br>
\x - Matches the single character x. This provides a way of avoiding the special interpretation of the characters \*?[] in pattern.
</div>
</div>
</div>
<div class=hidden id=edit_intmatch title="Edit intmatch">
<input name=edit_intmatch_target id=edit_intmatch_target
size=20 maxlength=255 />
<select name=edit_intmatch_op id=edit_intmatch_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_intmatch_field id=edit_intmatch_field type=number
size=5 maxlength=6 />
</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
<input name=newrule_type id=newrule_type_recurse type=radio
value='recurse' />Process Files and Files within Folders
<br>
Rule name:
<input name=newrule_comment id=newrule_comment size=80 maxlength=255 />
<div id=newrule_depth_box class=hidden>
Recursion Depth:
<input name=newrule_depth id=newrule_depth type=number size=5
maxlength=5 />
<span class=footnote>(How many levels deep into the folder structure to look)</span>
</div>
</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=55 maxlength=255
placeholder="Argument..." />
<select class=hidden name=edit_action_select_field
id=edit_action_select_field></select>
<input class=hidden name=edit_action_select_arg
id=edit_action_select_arg
size=20 maxlength=255 placeholder="Options..." />
<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 id=dryrun_info 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