{{extend 'layout.html'}}
{{import os}}

{{def tree(path):}}
    <input type="checkbox" onclick="jQuery(this).parent().find(':checkbox').attr('checked',this.checked)" checked="checked"/>
    <a href="#" onclick="jQuery(this).next().slideToggle();return false;">
      {{=path[len(base):] or '/%s' % app}}
    </a>
    <ul class="collapsible">
      {{for file in files[path]['files']:}}
       <li style="list-style-type: none;">
     {{p = os.path.relpath(os.path.join(path,file),base)}}
     <input type="checkbox" value="{{=p}}" name="file" checked="checked"/>
     {{=file}}
       </li>
       {{pass}}
       {{for dir in files[path]['folders']:}}
       <li style="list-style-type: none;">
     {{tree(os.path.join(path,dir))}}
       </li>
       {{pass}}
    </ul>
    {{return}}

<form action="{{=URL(args=request.args)}}" method="POST">
<h2>{{=T('Select Files to Package')}}</h2>
<input type="submit" value="{{=T('Download .w2p')}}" class="btn"/>
<input type="submit" name="doexe" value="{{=T('Download as .exe')}}" class="btn"/>
<div style="margin-top:20px">
{{tree(base)}}
</div>
</form>
<script>jQuery(function(){jQuery('.collapsible').hide();});</script>
