Changeset 28991

Show
Ignore:
Timestamp:
17.04.2014 16:16:12 (5 years ago)
Author:
ak19
Message:

Added in the necessary code so that now the Download File link for the GLI Help module on GTI will also work (didn't work in the original GTI, but the link was there).

Location:
main/trunk/greenstone2
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/gti.pl

    r28977 r28991  
    720720    } 
    721721 
     722     
     723    my $perllib_path = &util::filename_cat($gsdl_root_directory, "perllib"); # strings.properties 
     724    my $gliclasses_path = &util::filename_cat($gsdl_root_directory, "gli", "classes"); # dictionary.properties 
     725    my $os = $^O; 
     726    my $path_separator = ($^O =~ m/mswin/i) ? ";" : ":"; 
     727    my $xalan_path = &util::filename_cat($classpath, "xalan.jar"); 
     728    $classpath = "$perllib_path$path_separator$gliclasses_path$path_separator$classpath$path_separator$xalan_path"; 
     729 
    722730    my $gli_help_directory = &util::filename_cat($gsdl_root_directory, "gli"); 
    723731    $gli_help_directory = &util::filename_cat($gli_help_directory, "help"); 
     
    735743     
    736744    my $target_filepath = &util::filename_cat($gsdl_root_directory, $target_file); 
    737      
     745 
     746    # if gli/help/nl doesn't exist, create it by copying over gli/help/en/help.xml, then process the copied file 
     747    my ($tailname, $glihelp_lang_dir, $suffix) =  &File::Basename::fileparse($target_filepath, "\\.[^\\.]+\$");     
     748    if(!&FileUtils::directoryExists($glihelp_lang_dir)) {  
     749 
     750    # copy across the gli/help/en/help.xml into a new folder for the new language gli/help/<newlang> 
     751    my $en_glihelp_dir = &util::filename_cat($gli_help_directory, "en"); 
     752    my $en_helpxml_file = &util::filename_cat($en_glihelp_dir, "help.xml"); 
     753    &FileUtils::copyFilesRecursiveNoSVN($en_helpxml_file, $glihelp_lang_dir); 
     754 
     755    # In gli/help/<newlang>/help.xml, replace all occurrences of  
     756    # <Text id="1">This text in en will be removed for new langcode</Text>  
     757    # with <!-- Missing translation: 1 -->  
     758    open(FIN,"<$target_filepath") or &throw_fatal_error("Could not open $target_filepath for READING after creating it"); 
     759    my $help_xml_contents; 
     760    # Read in the entire contents of the file in one hit 
     761    sysread(FIN, $help_xml_contents, -s FIN); 
     762    close(FIN);  
     763     
     764    $help_xml_contents =~ s@<Text id="([^"]+?)">(.*?)</Text>@<!-- Missing translation: $1 -->@sg; 
     765 
     766    open(FOUT, ">$target_filepath") or &throw_fatal_error("Could not open $target_filepath for WRITING after creating it"); 
     767    print FOUT $help_xml_contents; 
     768    close(FOUT); 
     769    } 
     770 
    738771    my $perl_exec = &util::get_perl_exec(); 
    739772    my $java_exec = "java"; 
     
    741774        $java_exec = &util::filename_cat($ENV{'JAVA_HOME'}, "bin", "java"); 
    742775    } 
    743      
    744     my $cmd = "$java_exec -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_many_html_xsl_filepath $target_filepath | \"$perl_exec\" -S $split_script_filepath $target_file_directory"; 
     776 
     777    #my $cmd = "$java_exec -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_many_html_xsl_filepath $target_filepath | \"$perl_exec\" -S $split_script_filepath $target_file_directory"; 
     778    my $cmd = "$java_exec -DGSDLHOME=$gsdl_root_directory -cp $classpath ApplyXSLT $target_language_code $gen_many_html_xsl_filepath $target_filepath | \"$perl_exec\" -S $split_script_filepath $target_file_directory"; 
     779    #&throw_fatal_error("RAN gti command: $cmd"); 
    745780    my $response = `$cmd`; 
    746          
    747     $cmd = "$java_exec -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_index_xml_xsl_filepath $target_filepath > " . $target_file_directory . "help_index.xml"; # 2>/dev/null"; 
     781 
     782    #$cmd = "$java_exec -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_index_xml_xsl_filepath $target_filepath > " . $target_file_directory . "help_index.xml"; # 2>/dev/null"; 
     783    $cmd = "$java_exec -cp $classpath -DGSDLHOME=$gsdl_root_directory ApplyXSLT $target_language_code $gen_index_xml_xsl_filepath $target_filepath > " . $target_file_directory . "help_index.xml"; # 2>/dev/null"; 
    748784    $response = `$cmd`; 
    749      
     785 
     786    # create a gti/tmp folder, if one doesn't already exist, and store the downloadable zip file in there 
     787    my $tmpdir = &util::filename_cat($gsdl_root_directory, "tmp"); 
     788    if(!&FileUtils::directoryExists($tmpdir)) { 
     789    &FileUtils::makeDirectory($tmpdir); 
     790    } 
    750791    #my $zip_file_path = "/greenstone/custom/gti/" . $target_language_code . "_GLIHelp.zip";     
    751     my $zip_file_path = &util::filename_cat($gsdl_root_directory, $target_language_code . "_GLIHelp.zip"); 
     792    my $zip_file_path = &util::filename_cat($tmpdir, $target_language_code . "_GLIHelp.zip"); 
    752793    $cmd = "zip -rj $zip_file_path $target_file_directory -i \*.htm \*.xml"; 
     794 
    753795    $response = `$cmd`; 
    754796} 
  • main/trunk/greenstone2/runtime-src/src/recpt/gtiaction.cpp

    r28980 r28991  
    9898    java = existing_javahome;  
    9999    java += "/bin/java"; 
    100   }  
     100  } 
    101101 
    102102#if defined (__WIN32__) 
     
    696696 do_gti_request(gti_arguments, logout);  
    697697 
    698  disp.setmacro("gtiglihelpzipfilepath", "gti", target_language_code + "_GLIHelp.zip"); 
    699  disp.setmacro("gtiglihelpzipfilepathUrlsafe", "gti", encodeForURL(target_language_code) + "_GLIHelp.zip"); 
     698 disp.setmacro("gtiglihelpzipfilepath", "gti", "tmp/" + target_language_code + "_GLIHelp.zip"); 
     699 disp.setmacro("gtiglihelpzipfilepathUrlsafe", "gti", "tmp/" + encodeForURL(target_language_code) + "_GLIHelp.zip"); 
    700700 
    701701 return true;