Changeset 67 for branches


Ignore:
Timestamp:
Sep 5, 2019 9:42:27 AM (6 years ago)
Author:
anonymous
Message:

full, partial

Location:
branches/testa-single-bookmark
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/testa-single-bookmark/index.html

    r65 r67  
    88    <link rel="stylesheet" href="./css/style.css" />
    99    <link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
    10     <link rel="stylesheet" href="css/style-3.css?146">
    11     <link rel="stylesheet" href="css/tab.css?146">
    12     <link rel="stylesheet" href="css/menu.css?146">
     10    <link rel="stylesheet" href="css/style-3.css?170">
     11    <link rel="stylesheet" href="css/tab.css?170">
     12    <link rel="stylesheet" href="css/menu.css?170">
    1313    <link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
    1414    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    1515    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    1616    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js"></script>
    17     <script src="js/storagex.js?146>"></script>
    18     <script src="js/sidemenu.js?146>"></script>
    19     <script src="js/bookmark.js?146>"></script>
    20     <script src="js/bookmarkmgr.js?146"></script>
    21     <script src="js/bookmarkmenu.js?146"></script>
    22     <script src="js/tab.js?146"></script>
    23     <script src="js/topmenu.js?146"></script>
    24     <script src="js/remotex.js?146"></script>
    25     <script src="js/build.js?146"></script>
    26     <script src="js/main.js?146"></script>
     17    <script src="js/storagex.js?170>"></script>
     18    <script src="js/sidemenu.js?170>"></script>
     19    <script src="js/bookmark.js?170>"></script>
     20    <script src="js/bookmarkmgr.js?170"></script>
     21    <script src="js/bookmarkmenu.js?170"></script>
     22    <script src="js/tab.js?170"></script>
     23    <script src="js/topmenu.js?170"></script>
     24    <script src="js/remotex.js?170"></script>
     25    <script src="js/build.js?170"></script>
     26    <script src="js/main.js?170"></script>
    2727
    2828<!-- AREA-END -->
     
    238238    </script>
    239239  </body>
    240 </html>
    241 
    242 
    243 
    244 
  • branches/testa-single-bookmark/js/build.js

    r66 r67  
    11class Build {
    22    constructor(){
    3     }
    4 
    5     set_anchor_url( part, item_name, href, text , kind){
    6         if( href === undefined ){
    7             href = ""
    8         }
    9         Globalx.output_url_listx[text] = href
    10         Globalx[part].sidemenu.set_anchor_down_url( item_name, href, text , kind)
    113    }
    124
     
    1810            const content = textarea.val()
    1911
    20             this.set_anchor_url( part, Globalx[part].item_name, "", "" , "full")
    21             this.set_anchor_url( part, Globalx[part].item_name, "", "" , "partial")
     12            let words = Globalx[part].item_name.split('.')
     13            let base = words[0]
     14            Globalx[part].sidemenu.set_anchor_url( part, base, "", "" , "full")
     15            Globalx[part].sidemenu.set_anchor_url( part, base, "", "" , "partial")
    2216
    2317            Globalx.remotex.upload_file( cmd, Globalx.num, part, Globalx[part].key, content , (data) => {
     
    2721                    console.log("partial_download_url=" + obj["partial_download_url"])
    2822
    29                     this.set_anchor_url( part, Globalx[part].item_name, obj["full_download_url"],    Globalx[part].item_name, "full")
    30                     this.set_anchor_url( part, Globalx[part].item_name, obj["partial_download_url"], Globalx[part].item_name, "partial")
     23                    Globalx[part].sidemenu.set_anchor_url( part, base, obj["full_download_url"],    Globalx[part].item_name, "full")
     24                    Globalx[part].sidemenu.set_anchor_url( part, base, obj["partial_download_url"], Globalx[part].item_name, "partial")
    3125                }
    3226                else{
  • branches/testa-single-bookmark/js/main.js

    r66 r67  
    4545}
    4646
     47function set_output_url_listx(text){
     48    if( text.match( /{.*}/ ) !== null ){
     49        const obj = JSON.parse( text )
     50        //console.log("update_all_info_on_host text=" + text )
     51        Globalx.output_url_listx = {}
     52        obj["htmlfname"].forEach( (item) => {
     53            let words = item.full.split('.')
     54            let base = words[0]
     55            Globalx.output_url_listx[ base ] = {}
     56            Globalx.output_url_listx[ base ].full = `${obj["output_url"]}/${item.full}`
     57            Globalx.output_url_listx[ base ].partial = `${obj["output_url"]}/${item.partial}`
     58            console.log(`${words[0].full}=${ Globalx.output_url_listx[ base ].full }`)
     59            console.log(`${words[0].partial}=${ Globalx.output_url_listx[ base ].partial }`)
     60        } )
     61        Globalx.storagex.save_as_info_from_globalx()
     62    }
     63}
     64
    4765async function update_all_info_on_host_async( ) {
    48     await Globalx.remotex.get_output_url_listx( Globalx.num , (text) => {
    49         if( text.match( /{.*}/ ) !== null ){
    50             const obj = JSON.parse( text )
    51 //console.log("update_all_info_on_host text=" + text )
    52             Globalx.output_url_listx = obj
    53             Globalx.storagex.save_as_info_from_globalx()
    54         }
     66    await Globalx.remotex.update_output_url_listx( Globalx.num , (text) => {
     67        set_output_url_listx(text)
    5568    } )
    5669
     
    8699async function get_output_url_listx_async( num ) {
    87100    await Globalx.remotex.get_output_url_listx( num , (text) => {
    88         if( text.match( /{.*}/ ) !== null ){
    89             const obj = JSON.parse( text )
    90 //console.log("update_all_info_on_host text=" + text )
    91             Globalx.output_url_listx = obj
    92             Globalx.storagex.save_as_info_from_globalx()
    93         }
     101        set_output_url_listx(text)
    94102    } )
    95103}
     104
    96105async function setup(){
    97106    await get_output_url_listx_async( Globalx.num )
    98     await get_output_url( Globalx.num )
     107//    await get_output_url( Globalx.num )
    99108}
    100109
  • branches/testa-single-bookmark/js/remotex.js

    r66 r67  
    3838    async get_output_url_listx( num, func) {
    3939        let param_array = [['cmd', 'get_output_url_listx'] , ['num', num]]
     40        await this.fetchx( this.filename , param_array, 2, func )
     41    }
     42
     43    async update_output_url_listx( num, func) {
     44        let param_array = [['cmd', 'update_output_url_listx'] , ['num', num]]
    4045        await this.fetchx( this.filename , param_array, 2, func )
    4146    }
  • branches/testa-single-bookmark/js/sidemenu.js

    r66 r67  
    8383            Globalx[part].editor.getSession().setValue( "" );
    8484
     85            let words = Globalx[part].item_name.split('.')
     86            let base = words[0]
    8587            $( this.textarea_sel ).val( "" );
    86             this.set_anchor_url( part, Globalx[part].item_name, "", "" , "full")
    87             this.set_anchor_url( part, Globalx[part].item_name, "", "" , "partial")
     88            this.set_anchor_url( part, base, "", "" , "full")
     89            this.set_anchor_url( part, base, "", "" , "partial")
    8890
    8991            if( Globalx[part].key != '/' ){
     
    128130
    129131        if( jsondata !== undefined && jsondata[Globalx[part].key] !== undefined ){
     132            let words = item_name.split('.')
     133            let base = words[0]
    130134            if( jsondata[Globalx[part].key].length == 0 ){
    131135                Globalx[part].key_indicate_file = true;
    132136console.log("Globalx[" + part + "].key_indicate_file = " + Globalx[part].key_indicate_file)
    133                 let url = ""
     137                let url = Globalx.output_url_listx[base].full
     138console.log( "item_name="+item_name )
     139console.log( "base="+base )
     140console.log( "url="+url )
    134141                $( Globalx[part].download_url_sel ).val( Globalx[part].key )
    135142                $( Globalx[part].download_url_sel ).attr('href' , url )
     
    142149                });
    143150
    144                 this.set_anchor_down_url( item_name, Globalx.output_url_listx[item_name], item_name , "full" )
    145                 this.set_anchor_down_url( item_name, Globalx.output_url_listx[item_name], item_name , "partial" )
     151                this.set_anchor_down_url( base, Globalx.output_url_listx[base].full, item_name , "full" )
     152                this.set_anchor_down_url( base, Globalx.output_url_listx[base].partial, item_name , "partial" )
    146153            }
    147154            else{
    148                 this.set_anchor_url( part, Globalx[part].item_name, "", "" , "full")
    149                 this.set_anchor_url( part, Globalx[part].item_name, "", "" , "partial")
     155                this.set_anchor_url( part, base, "", "" , "full")
     156                this.set_anchor_url( part, base, "", "" , "partial")
    150157            }
    151158        }
     
    184191    }
    185192
    186     set_anchor_down_url( item_name, href, text , kind ){
     193    set_anchor_url( part, base, href, text , kind){
     194        if( href === undefined ){
     195            href = ""
     196        }
     197        if( text === "" ){
     198            Globalx[part].sidemenu.set_anchor_down_url( base, href, text , kind)
     199        }
     200        else{
     201            let words = text.split('.')
     202            let base = words[0]
     203            if( Globalx.output_url_listx[base] !==  undefined ){
     204                Globalx[part].sidemenu.set_anchor_down_url( base, href, text , kind)
     205            }
     206        }
     207    }
     208
     209    set_anchor_down_url( base, href, text , kind ){
    187210        let sel = null
    188211        if( href === undefined ){
    189212            href = ""
    190213        }
    191         Globalx.output_url_listx[item_name] = href
    192 
     214        if( href === "" ){
     215            text = ""
     216        }
     217        if( text !== "" ){
     218            if( kind == "full" ){
     219                Globalx.output_url_listx[base].full = href
     220            }
     221            else{
     222                Globalx.output_url_listx[base].partial = href
     223            }
     224        }
    193225        if( kind === "full" ){
    194226            sel = this.full_download_url_sel
  • branches/testa-single-bookmark/php/content3.php

    r63 r67  
    1515require_once( dirname(__FILE__) . "/spyc-0.5/spyc.php"); // ★の部分にはspyc.phpを置いたパスを入れます
    1616
    17 $exec_path = dirname(__FILE__) . "/..";
     17$Top_path = dirname(__FILE__) . "/..";
     18$Url_data = null;
     19$Url_data_array = null;
    1820
    1921function get_url_data_array()
     
    2527}
    2628
    27 function get_url_data_array0()
    28 {
    29         $array = array(
    30         array('url' => 'https://toppers.jp', 'path' =>  '/var/www/vhosts/devconf.northern-cross.info/httpdocs/a/tmp/devconf-guest-4/tmp/md2site-x/_xtest/wtjx/t12/src') );
    31 
    32         return $array;
    33 }
    34 
    3529function get_url_data( $num ){
    36     $array = get_url_data_array();
    37     return $array[$num];
     30    global $Url_data_array;
     31    return $Url_data_array[$num];
    3832}
    3933
     
    4337
    4438function get_path_from_url_data( $num , $part){
     39    global $Url_data_array;
     40
    4541    switch($part){
    4642    case 'data':
    47         $ret = get_url_data( $num )['path'];
     43        $ret = $Url_data_array[$num]['path'];
    4844        break;
    4945    case 'conf':
    50         $ret = get_url_data( $num )['conf_path'];
     46        $ret = $Url_data_array[$num]['conf_path'];
    5147        break;
    5248    case 'output':
    53         $ret = get_url_data( $num )['output_path'];
     49        $ret = $Url_data_array[$num]['output_path'];
    5450        break;
    5551    default:
     
    123119}
    124120
    125 
    126121function get_path_info( $num , $part){
    127122    $path_info = get_path_list_by_url( $num , $part);
     
    138133function ensure_storage_dir( $storage_dir , $num, $filename ) {
    139134    $dir = implode( "/" , array( $storage_dir , $num) );
    140     mkdir($dir);
     135    if( !file_exists( $dir ) ){
     136        mkdir($dir);
     137    }
    141138    $path = implode( "/" , array( $dir , $filename) );
    142139    ensure_dir( $dir );
     
    152149}
    153150
    154 function build_one_html( $exec_path, $num , $md_path , $part) {
     151function build_one_html( $top_path, $num , $md_path , $part) {
    155152    $pathinfo = pathinfo( $md_path );
    156153    $md_fname = $pathinfo['basename'];
     
    169166    $output_url = $url_data["output_url"];
    170167
    171     $cmd_line_items = array( $exec_path . "/bin/build.sh" , $bundle_path , $t, $s, $conf_path);
     168    $cmd_line_items = array( $top_path . "/bin/build.sh" , $bundle_path , $t, $s, $conf_path);
    172169
    173170    $cmd_line = implode(" " , $cmd_line_items);
     
    191188
    192189function cmdx(){
    193     global $exec_path;
     190    global $Top_path;
     191    global $Url_data;
     192    global $Url_data_array;
     193
     194    $Url_data_array = get_url_data_array();
    194195
    195196    $filelist_filename = array("data"=> "filelist.json", "conf"=> "conf-filelist.json", "output" => "output-filelist.json");
     197    $output_url_filename = "output_url.json";
    196198    #    $storage_dir = dirname(__FILE__) . '/../storage';
    197199    $storage_dir = dirname(__FILE__) . '/../storage-devconf';
     
    202204        if (isset($_GET['num'])) {
    203205            $num = $_GET['num'];
     206
     207            $Url_data = get_url_data($num);
     208
    204209            if (isset($_GET['part'])) {
    205210                $part = $_GET['part'];
     
    237242                    $content = json_encode($info);
    238243                    break;
     244                case 'update_output_url_listx':
     245                    $content = update_output_url_list( $num );
     246                case 'get_output_url_listx':
     247                    $path = ensure_storage_dir( $storage_dir , $num , $output_url_filename );
     248                    if( file_exists($path) ){
     249                        $content = input_file( $path );
     250                    }
     251                    else {
     252                        $content = update_output_url_list( $num );
     253                    }
     254                    break;
    239255                default:
     256                    $content = "bad cmd=" . $cmd;
    240257                    break;
    241258                }
     
    248265        if (isset($_POST['num'])) {
    249266            $num = $_POST['num'];
     267
     268            $Url_data = get_url_data($num);
     269
    250270            if (isset($_POST['part'])) {
    251271                $part = $_POST['part'];
     
    259279                        $top_path = get_path_from_url_data( $num , $part);
    260280                        $filename_abs_path = $top_path . DIRECTORY_SEPARATOR . $path;
    261                         $ret = build_one_html( $exec_path , $num, $path, $part );
     281                        $ret = build_one_html( $Top_path , $num, $path, $part );
    262282                    }
    263283                    else{
     
    304324    }
    305325    else{
    306         echo($content);
     326        echo("no content");
    307327    }
    308328}
     
    331351
    332352function get_full_path($num, $key, $fname){
    333     $array = get_url_data_array();
    334     return $array[$num][$key] . "/" . $fname;
    335 }
    336 
    337 function get_restrict_from_settings_yml() {
    338     $settings = get_url_data_array();
    339     $array = $settings[0]['restrict'];
     353    global $Url_data_array;
     354    return $Url_data_array[$num][$key] . "/" . $fname;
     355}
     356
     357function get_restrict_from_settings_yml( $num ) {
     358    global $Url_data_array;
     359
     360    /*    $settings = get_url_data_array();*/
     361    $settings = $Url_data_array;
     362    if( !isset($settings[$num]) ){
     363        return array();
     364    }
     365    $array = $settings[$num]['restrict'];
     366    if( !isset( $array ) ){
     367        return array();
     368    }
    340369
    341370    $r_keys = array_keys( $array );
     
    361390    $list = get_site_tsv($num );
    362391
    363     $restrict_array = get_restrict_from_settings_yml();
     392    $restrict_array = get_restrict_from_settings_yml( $num );
    364393
    365394    foreach( $list as $k => $v ){
     
    399428}
    400429
     430function update_output_url_list( $num ){
     431    $json_data = get_output_url_list( $num );
     432    $content = json_encode($json_data);
     433    output_file( $path , $content );
     434
     435    return $content;
     436}
     437
     438function get_output_url_list( $num ){
     439    $output_url = get_output_url($num);
     440    $data = array( "output_url" => get_output_url($num),
     441           "htmlfname" => array()
     442    );
     443
     444    $list = get_site_tsv( $num );
     445    $restrict_htmlnames = get_restrict_basenames( $num );
     446
     447    $output_path = get_path_from_url_data( $num, 'output' );
     448    foreach( $list as $k => $v ){
     449        $htmlfname = $v["output_html"];
     450        if( $htmlfname !== null ){
     451            $array = array( "full" => "", "partial" => "" );
     452            if( !isset( $restrict_htmlnames[$htmlfname] ) ){
     453                $fpath =  $output_path . '/' . $htmlfname;
     454                if( file_exist($fpath) ){
     455                    $array["full"] = $htmlfname;
     456                }
     457                $fpath_tmp =  $fpath . '.tmp';
     458                if( file_exist($fpath_tmp) ){
     459                    $array["partial"] = $htmlfname_tmp;
     460                }
     461                array_push( $data["htmlfname"] , $array);
     462            }
     463        }
     464    }
     465
     466    return $data;
     467}
     468
    401469function get_output_url($num){
    402     $settings = get_url_data_array();
    403     return $settings[$num]['output_url'];
     470    return $Url_data['output_url'];
    404471}
    405472
    406473function get_restrict($num){
    407     $settings = get_url_data_array();
    408     return $settings[$num]['restrict'];
    409 }
    410 
    411 function get_item($num, $name){
    412     $settings = get_url_data_array();
    413     return $settings[$num][$name];
    414 }
    415 
    416 function get_settings_file( $name ){
    417     $dir = get_item( 0 , "conf_path" );
    418     $path = implode( "/" , [$dir, $name] );
    419 
    420     return $path;
    421 }
    422 
    423 function do_exec(){
    424     $cmd = "ls -l /z";
    425 
    426     exec($cmd, $opt, $ret);
    427 
    428 #    print_r($opt);
    429 #    echo "ret=" . $ret . "\n";
     474    /*    $settings = get_url_data_array();*/
     475    global $Url_data_array;
     476    return $Url_data_array[$num]['restrict'];
    430477}
    431478
    432479cmdx();
    433 /*
    434 do_exec();
    435 */
    436 /*
    437 $num = 0;
    438 $path = "/attempt/devconf2018/data/devconf2018.md";
    439 $part = "data";
    440 $lines = build_one_html( $exec_path, $num , $path , $part );
    441 
    442 var_dump( $lines );
    443 
    444 foreach( $lines as $k => $v ){
    445     if( is_array( $v )){
    446         echo implode( "\n" , $v );
    447     }
    448     else{
    449         echo $v . "\n";
    450     }
    451 }
    452 */
     480
     481#echo json_encode( get_output_url_list(0) );
     482# var_dump( get_output_url_list(0) );
     483#var_dump( get_output_url_list(0) );
     484#echo json_encode( get_output_url_list(0) );
    453485?>
  • branches/testa-single-bookmark/tmp/tmp.txt

    r66 r67  
    88    <link rel="stylesheet" href="./css/style.css" />
    99    <link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
    10     <link rel="stylesheet" href="css/style-3.css?146">
    11     <link rel="stylesheet" href="css/tab.css?146">
    12     <link rel="stylesheet" href="css/menu.css?146">
     10    <link rel="stylesheet" href="css/style-3.css?170">
     11    <link rel="stylesheet" href="css/tab.css?170">
     12    <link rel="stylesheet" href="css/menu.css?170">
    1313    <link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
    1414    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    1515    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    1616    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js"></script>
    17     <script src="js/storagex.js?146>"></script>
    18     <script src="js/sidemenu.js?146>"></script>
    19     <script src="js/bookmark.js?146>"></script>
    20     <script src="js/bookmarkmgr.js?146"></script>
    21     <script src="js/bookmarkmenu.js?146"></script>
    22     <script src="js/tab.js?146"></script>
    23     <script src="js/topmenu.js?146"></script>
    24     <script src="js/remotex.js?146"></script>
    25     <script src="js/build.js?146"></script>
    26     <script src="js/main.js?146"></script>
     17    <script src="js/storagex.js?170>"></script>
     18    <script src="js/sidemenu.js?170>"></script>
     19    <script src="js/bookmark.js?170>"></script>
     20    <script src="js/bookmarkmgr.js?170"></script>
     21    <script src="js/bookmarkmenu.js?170"></script>
     22    <script src="js/tab.js?170"></script>
     23    <script src="js/topmenu.js?170"></script>
     24    <script src="js/remotex.js?170"></script>
     25    <script src="js/build.js?170"></script>
     26    <script src="js/main.js?170"></script>
    2727
    2828<!-- AREA-END -->
     
    7272              <ul>
    7373                <li><a id="data-host-update-all" onclick="update_all_info_on_host_async()">Update all on host</a></li>
    74 <!--            <li><a id="data-host-update" onclick="Globalx.remotex.update('data')">Update on host</a></li> -->
    7574                <li><a href="#" onclick="Globalx.storagex.save_info_from_globalx()">Save info</a></li>
    7675                <li><a href="#" onclick="Globalx.storagex.reset_info()">Reset Info</a></li>
     
    171170            <ul>
    172171              <li><a id="conf-file-upload" onclick="upload_to_host('conf')">Save on host</a></li>
    173 <!--          <li><a id="conf-file-download" onclick="download_cmd('data')">Download</a></li> -->
    174172              <li><a id="conf-file-rename" class="disabled" >-Rename</a></li>
    175173              <li><a id="conf-file-move" class="disabled" >-Move</a></li>
     
    181179            <ul>
    182180              <li><a id="conf-dir-create" class="disabled" href="#">-Create</a></li>
    183               <li><a id="conf-dir-rename" class="disabled" href="#">-Rename</a></li>
     181p             <li><a id="conf-dir-rename" class="disabled" href="#">-Rename</a></li>
    184182              <li><a id="conf-dir-move" class="disabled" href="#">-Move</a></li>
    185183              <li><a id="conf-dir-delete" class="disabled" href="#">-Delete</a></li>
Note: See TracChangeset for help on using the changeset viewer.