Changeset 1941


Ignore:
Timestamp:
08/16/07 15:58:57 (12 years ago)
Author:
jukka
Message:

Simplified collection download interface.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Collection.py

    r1920 r1941  
    499499 
    500500#Zip / SCORM download stuff begin -------------------------------------------------------------------------------- 
    501     def download(self, SHARED='False', SCORM='False'): 
    502         """ Builds a zip. Set SHARED to True to make shared files appear only once in the zip. Set SCORM to True to generate an imsmanifest.xml file, too. """ 
     501    def download(self, PACKAGE_TYPE="HTML"): 
     502        """ Builds a zip. Set PACKAGE_TYPE to SCORM to generate an imsmanifest.xml file. """ 
    503503 
    504504        def splitHTML(htmlPage, pageURL): 
     
    726726 
    727727                fileName = addExtension(src['fileName'], src['extension']) 
    728                 if len(src['usedBy']) > 1 and SHARED == 'True': 
    729                     src['finalURL'] = '_SharedFiles/' + fileName 
    730                     if src['extension'] != 'xml': 
    731                         zip.writestr(src['finalURL'], data) 
    732                 else: 
    733                     src['finalURL'] = '_Files/' + fileName 
    734                     if src['extension'] != 'xml': 
    735                         for i in src['usedBy']: 
    736                             zip.writestr(baseDirs[i] + src['finalURL'], data) 
     728                src['finalURL'] = '_Files/' + fileName 
     729                if src['extension'] != 'xml': 
     730                    for i in src['usedBy']: 
     731                        zip.writestr(baseDirs[i] + src['finalURL'], data) 
    737732 
    738733        def processHrefs(hrefs, srcs, htmlURLs, baseDirs, portalURL): 
     
    768763                        absURL, flash = getAbsoluteURL(splitHtml[j], infoList[j], baseURLs[i]) 
    769764                        src = srcs[absURL] 
    770                         if baseDirs[i] != '' and len(src['usedBy']) > 1 and SHARED == 'True': 
    771                             finalURL = '../../' + src['finalURL'] 
    772                         else: 
    773                             finalURL = src['finalURL'] 
     765                        finalURL = src['finalURL'] 
    774766                        if infoList[j] == 'src': 
    775767                            splitHtml[j] = finalURL 
     
    789781                        href = hrefs[absURL] 
    790782                        if href['type'] == 1: 
    791                             if baseDirs[i] != '' and len(href['usedBy']) > 1 and SHARED == 'True': 
    792                                 finalURL = 'href="../../%s"' % href['finalURL'] 
    793                             else: 
    794                                 finalURL = 'href="%s"' % href['finalURL'] 
     783                            finalURL = 'href="%s"' % href['finalURL'] 
    795784                        else: 
    796785                            finalURL = href['finalURL'] 
     
    805794                        absURL2, flash = getAbsoluteURL(splitXML[j], xmlInfoList[j]) 
    806795                        src = srcs[absURL2] 
    807                         if len(src['usedBy']) > 1 and SHARED == 'True': 
    808                             splitXML[j] = '../../' + src['finalURL'] 
    809                         else: 
    810                             splitXML[j] = src['finalURL'] 
     796                        splitXML[j] = src['finalURL'] 
    811797 
    812798        def addHtmlsToZip(splitHtmls, zip, baseDirs = None): 
     
    876862                    src = srcs[absURL] 
    877863                    if i in src['usedBy']: 
    878                         if len(src['usedBy']) > 1 and SHARED == 'True': 
    879                             finalURL = src['finalURL'] 
    880                         else: 
    881                             finalURL = htmlList[i][1] + src['finalURL'] 
     864                        finalURL = htmlList[i][1] + src['finalURL'] 
    882865                        manifest += '\t\t\t<file href="%s" />\n' % finalURL 
    883866                manifest += '\t\t</resource>\n' 
     
    924907        addHtmlsToZip(splitHtmls, zip, baseDirs) 
    925908        addPilotXMLsToZip(xmlDatas, srcs, zip) 
    926         if SCORM == 'True': 
     909        if PACKAGE_TYPE == 'SCORM': 
    927910            addSCORMFiles(str(max(times)), htmlList, srcs, zip) 
    928911        zip.close() 
  • trunk/skins/lemill/collection_download.pt

    r1920 r1941  
    11<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" 
    2       metal:use-macro="here/main_template/macros/master" 
     2      metal:use-macro="here/form_template/macros/master" 
    33      i18n:domain="lemill"> 
    44<head> 
     
    99    <metal:fill fill-slot="main"> 
    1010        <metal:main_macro define-macro="body"> 
    11 <h1><span i18n:translate="text_coll_down_01">Downloading collection</span>: <span tal:content="here/TitleOrId">Collection's name</span></h1> 
    12 <p i18n:translate="text_coll_down_02">Please select the desired download options then press &quot;Download&quot;.</p> 
     11<h1><span i18n:translate="heading_download_collection">Downloading collection</span>: <span tal:content="here/TitleOrId">Collection's name</span></h1> 
     12<p i18n:translate="explanation_download_collection">Download standalone package of the collection</p> 
     13 
    1314<form method="get" action="" tal:attributes="action string:${here_url}/download"> 
    14     <table width="100%" border="0"> 
    15         <tr> 
    16             <td valign="top"><h2 i18n:translate="text_coll_down_03">Shared files</h2> 
    17             <p i18n:translate="text_coll_down_04">By allowing shared files you can reduce the size of the downloaded archive but you might not be able to separate the contents later.</p></td> 
    18             <td valign="top"><h2 i18n:translate="text_coll_down_05">SCORM package</h2> 
    19             <p i18n:translate="text_coll_down_06">By adding the necessary files you can make the downloaded archive SCORM compatible. This way you will be able to import the package to other SCORM compatible learning management systems. Although it is not required you should disable shared files in order to meet the SCORM requirements.</p></td> 
    20         </tr> 
    21         <tr> 
    22             <td width="50%" valign="top"> 
    23                 <label> 
    24                 <input type="checkbox" name="SHARED" id="SHARED" checked="checked" value="True" /> 
    25                 <span i18n:translate="text_coll_down_07">Allow file sharing</span></label> 
    26             </td> 
    27             <td valign="top"> 
    28                     <label> 
    29                     <input type="checkbox" name="SCORM" id="SCORM" value="True" /> 
    30                     <span i18n:translate="text_coll_down_08">Include SCORM files</span></label> 
    31             </td> 
    32         </tr> 
    33     </table> 
    34     <div align="center"> 
    35             <hr /> 
    36             <div> 
    37                 <p class="byTextsFont" style="display: none;" id="wait_text" i18n:translate="text_coll_down_09">Please wait while your download begins.</p> 
    38             </div> 
    39             <input class="context" type="submit" value="Download" onclick="javascript:document.getElementById('wait_text').style.display = 'block';" i18n:attributes="value label_download" /> 
    40             <input class="context" type="button" value="Cancel" onclick="javascript:history.back()" i18n:attributes="value label_cancel;" /> 
    41     </div> 
     15             
     16<p> 
     17    <label> 
     18        <input type="radio" name="PACKAGE_TYPE" id="PACKAGE_TYPE" value="HTML" checked="1" /> 
     19        <span i18n:translate="collection_download_option_html_package">HTML (zip) package</span> 
     20    </label> 
     21</p> 
     22<p> 
     23    <label> 
     24        <input type="radio" name="PACKAGE_TYPE" id="PACKAGE_TYPE" value="SCORM" /> 
     25        <span i18n:translate="collection_download_option_html_package">SCORM package</span> 
     26    </label> 
     27</p> 
     28 
     29    <div> 
     30        <input class="context" type="submit" value="Download" onclick="javascript:document.getElementById('wait_text').style.display = 'block';" i18n:attributes="value label_download" /> 
     31        <input class="context" type="button" value="Cancel" onclick="javascript:history.back()" i18n:attributes="value label_cancel;" /> 
     32    </div>             
     33    <div> 
     34        <p class="byTextsFont" style="display: none;" id="wait_text" i18n:translate="collection_download_waiting">Please wait while your download begins. <br/><br/><a href="" tal:attributes="href context/absolute_url" i18n:translate="collection_back_link">Then return to view collection</a></p> 
     35    </div> 
     36 
     37 
    4238</form> 
    4339        </metal:main_macro> 
Note: See TracChangeset for help on using the changeset viewer.