<commit_before>async function(args) {
/*
created_timestamp(-1)
base_component_id("homepage")
is_app(true)
control_type("SYSTEM")
display_name("Homepage app")
description('Homepage app')
uses_javascript_librararies(["aframe"])

load_once_from_file(true)
read_only(true)
logo_url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxIQEg8SEBETEBAWFhYQFhITGBkQExUXFhIaFhUWFRUaHSkgGBomGxUVIj0kJSorLi4uFx8zODM4NygtLisBCgoKDg0OGxAQGzMlHyUtLS0tLS0rLS0tLS0tMi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS01LS0tLS0tLS0tLf/<KEY>BMwMBEQACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAABAUBAgMGB//EAEUQAAEDAgEHBwgGCQUBAAAAAAEAAgMEESEFEhUxQVORBhMUIlFU4VJhcYGSoaLSMjNicqOxFpSys7TBwtHTIzRzgvAH/8QAGwEBAAIDAQEAAAAAAAAAAAAAAAECAwQGBQf/xAA3EQEAAQMABwcDAgUEAwAAAAAAAQIDEQQSEzFRUpEFFBUhQVNhFjJxM4EiNLHB8AZCkqE10eH/2gAMAwEAAhEDEQA/ALBbLjBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE<KEY>ICD//2Q==")
*/
    console.log(`calling await loadV2("app_editor_3")`)
    await loadV2("app_editor_3")
    console.log(`calling await loadV2("app_editor_3") loaded`)

    var mm = null




    Vue.component('homepage', {

      template:
`<div>
    <div    style="position: sticky; left:0px; top:0px; width: 100vw ;z-index: 2;background-color: black;padding:0;margin:0;">
        <h4 style="border:0px; padding: 5px; margin: 0px;padding-left:15px;font-family: Helvetica;color: white;">
             <b>App</b>Share
        </h4>
        <h6 style="color: lightgray;border:0px;padding: 2px; margin: 0px;padding-left:15px;font-family: Helvetica;">
            Build apps in minutes
        </h6>
    </div>


    <div    style='padding:10px; margin:0;border: 2px solid pink;'>
        <h4>
            Create a new app
        </h4>

        <select v-model="app_type">
            <option           value="new">Blank app</option>
            <option           value="quicksort">Quicksort</option>
            <option selected value="bubblesort">Bubblesort</option>
            <option          value="vb">Drag and Drop Builder</option>
            <option          value="todo">Database app</option>
            <option          value="game">3d AFrame app</option>
            <option          value="new_app">Text only</option>
        </select>

        <button style='margin-bottom:10px;' class='btn btn-primary btn-lg' v-on:click='copyAndEditApp($event,app_type)'>
            Go
        </button>
    </div>



    <div  class="container-fluid" style='position: relative; padding:20;margin:0; width: 95%;'>

        <div v-bind:refresh='refresh'
             ref='maingrid'
             id='maingrid'
             class="grid"
             style='background-color: white; color: black; padding-top: 20px;padding-bottom: 20px;'>

            <div    v-for="(item, index) in intro_apps"
                    class="grid-item col-lg-4">
                    <div
                    style="border-radius: 0px;background-color:white;border-width: 0px;margin:0px;padding:10px;">


               <div v-if="item.type == 'app'" >

               <div v-if="(edit_app == item.data.id)"
                       style="position: fixed; left:0px; top:0px; height:100%; width: 100vw ;z-index: 200000;background-color: white;overflow-y:none; padding: 0px;">
                       <component v-if='' :is='"app_editor_3"' v-bind:app_id='item.data.id' v-bind:card_index='index'></component>
               </div>




               <div style='border-radius: 0px;padding:0px; margin:0;border: 2px solid lightgray;'>

                    <div v-if='isInlineApp(item.data.id)' >
                        <kbd v-on:click='editApp($event,item.data.id)'>
                            {{item.data.id?"" + item.data.id.substring(0,20):""}}{{(item.data.id && ((item.data.id.length > 20))?"...":"")}}
                        </kbd>

                        <component v-if='edit_app != item.data.id' :is='item.data.id'>
                        </component>
                    </div>

                    <div v-if='!isInlineApp(item.data.id)' >
                        <kbd v-on:click='editApp($event,item.data.id)'>{{item.data.id?"" + item.data.id.substring(0,20):""}}{{(item.data.id && ((item.data.id.length > 20))?"...":"")}}
                        </kbd>

                        <span v-if='isEditable(item.data.id)' class="badge badge-warning" >
                            Editable
                        </span>

                        <span v-if='!isEditable(item.data.id)' class="badge badge-info" >
                            Read only
                        </span>

                        <img    v-if='(app_records[item.data.id] && app_records[item.data.id].logo_url && (app_records[item.data.id].logo_url != ""))'
                                v-bind:src='app_records[item.data.id].logo_url'
                                style='width: 100%;'
                                v-bind:alt='app_records[item.data.id].logo_url'
                                v-on:click='editApp($event,item.data.id)'
                                >
                        </img>
                    </div>


                    <ul class="nav flex-column">
                        <li class="nav-item" v-if='!isEditable(item.data.id)'>
                            <a  v-on:click='editApp($event,item.data.id)'
                                class="nav-link active" href="#">View source</a>
                        </li>

                        <li class="nav-item" v-if='isEditable(item.data.id)'>
                            <a  v-on:click='editApp($event,item.data.id)'
                                class="nav-link active" href="#">Edit</a>
                        </li>
                    </ul>

                </div>
            </div>
        </div>


    </div>

</div>`
      ,


    data: function() {
        return {
                    apps:           [],
                    app_type:       "bubblesort",
                    intro_apps:     [],
                    loaded_app:     new Object(),
                    show_menu:      null,
                    refresh:        0,
                    edit_app:       null,
                    app_records:    new Object(),
                    msnry:          null
                }},

    mounted: async function() {
        mm = this

        this.msnry = new Masonry(
           document.getElementById("maingrid"),
            {
                itemSelector: '.grid-item'
            }
        );


       var sql =    "select  *  from  system_code  where " +
                    "        component_type = 'app' and base_component_id like 'homepage_%'" +
                    "        and code_tag = 'LATEST' order by base_component_id asc"

       var results = await callApp(
           {
                driver_name:    "systemFunctions2",
                method_name:    "sql"
           }
           ,
           {
               sql: sql
           }
       )
       for (var rt=0; rt < results.length; rt++) {
           var appId = results[rt].base_component_id
           mm.addAppFast(appId,-1, results[rt])
           component_loaded[appId] = true
       }





       //
       // search
       //
       var sql2 =    `SELECT  id, base_component_id, logo_url, read_write_status
                         FROM
                     system_code
                         where
                             component_type = 'app'
                                 and
                             code_tag = 'LATEST'
                                 and
                             visibility = 'PUBLIC'
                     order by base_component_id asc; `

       var results2 = await callApp(
           {
                driver_name:    "systemFunctions2",
                method_name:    "sql"
           }
           ,
           {
               sql: sql2
           })
       for (var rt2=0; rt2 < results2.length; rt2++) {
           var appId = results2[rt2].base_component_id
           if (!mm.loaded_app[  appId  ]) {
                 mm.addAppFast(appId,-1, results2[rt2])
           }
       }










        this.$root.$on('message', async function(text) {
            if (text.type == "insert_app_at") {
                console.log(JSON.stringify(text,null,2));
                mm.intro_apps.splice(text.card_index, 0, {});
                await mm.addApp(text.base_component_id, text.card_index)
                mm.edit_app = text.base_component_id
                mm.refresh++
            }

            if (text.type == "close_app") {
                mm.show_menu = null;
                mm.edit_app = null;
                mm.refresh++
            }

        })

         globalEventBus.$on('new-appshare-app-uploaded',
            async function(data) {
                //zzz
                //alert(JSON.stringify(data,null,2))
                mm.intro_apps.splice(1, 0, {});
                await mm.addApp(data, 1)
                setTimeout(function() {
                      mm.editApp(null, data)
                },50)
         });

         setTimeout(function() {
             mm.msnry.reloadItems();
             mm.msnry.layout();
         },50)




      },



      methods: {
          addAppFast: function(baseComponentId, cardIndex,vv) {
              if (baseComponentId) {

                  if (vv.code) {
                      var x = eval("(" + vv.code + ")")
                      x.call()
                  }
                  var app = {
                                        type: "app",
                                        data:
                                            {
                                                id: baseComponentId
                                            }
                                      }
                  if (cardIndex != -1) {
                    mm.intro_apps[cardIndex] =  app

                  } else {
                    mm.intro_apps.push( app  )
                  }
                  mm.loaded_app[baseComponentId] = true
                  if (vv) {
                      mm.app_records[vv.base_component_id] = vv
                      mm.refresh++
                  }

              }
          },




            addApp: async function(baseComponentId, cardIndex) {
              if (baseComponentId) {
                  var app = {
                                        type: "app",
                                        data:
                                            {
                                                id: baseComponentId
                                            }
                                      }
                  if (cardIndex != -1) {
                    mm.intro_apps[cardIndex] =  app

                  } else {
                    mm.intro_apps.push( app  )
                  }
                  mm.loaded_app[baseComponentId] = true
                  component_loaded[baseComponentId] = false
                  dev_app_component_loaded[baseComponentId] = false
                  component_cache[baseComponentId] = null
                  var vv = await loadV2(baseComponentId)
                  if (vv) {
                      mm.app_records[vv.base_component_id] = vv
                      mm.refresh++
                  }
              }
              return null
          },
          copyApp: async function(  baseComponentId ) {
              callDriverMethod( {driver_name: "copyApp",
                                 method_name: "copyAppshareApp"}
                                ,{base_component_id:    baseComponentId}
                          ,
                          async function(result) {
                              mm.intro_apps.splice(1, 0, {});
                              await mm.addApp(result.value.base_component_id, 1)

                          })
          },
          copyAndEditApp: async function(event,  baseComponentId ) {
              callDriverMethod( {driver_name: "copyApp",
                                 method_name: "copyAppshareApp"}
                                ,{base_component_id:    baseComponentId}
                          ,
                          async function(result) {
                              mm.intro_apps.splice(1, 0, {});
                              await mm.addApp(result.value.base_component_id, 1)
                              setTimeout(function() {
                                    mm.editApp(event, result.value.base_component_id)
                              },50)

                          })
          },
          isEditable: function(baseComponentId) {
                if (this.app_records[baseComponentId]) {
                    if ((this.app_records[baseComponentId].read_write_status == null ) ||
                         (this.app_records[baseComponentId].read_write_status.indexOf("READ") == -1 ))   {
                         return true
                }

                }

               return false
          },
          isInlineApp: function(baseComponentId) {
                if (baseComponentId && (baseComponentId.length > 0)) {
                    if ((!this.isEditable(baseComponentId)) && (baseComponentId.startsWith("homepage"))) {
                        return true
                    }
                }

               return false
          },
          editApp: async function(event,item) {
              if (event) {
                  event.stopPropagation()
              }
              this.show_menu = null;
              this.edit_app = item;
          },
          showMenu: async function(item) {
            this.show_menu= item;
          }


      }
    })

}
<commit_msg>Change the name of the product to Creator<commit_after>async function(args) {
/*
created_timestamp(-1)
base_component_id("homepage")
is_app(true)
control_type("SYSTEM")
display_name("Homepage app")
description('Homepage app')
uses_javascript_librararies(["aframe"])

load_once_from_file(true)
read_only(true)
logo_url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxIQEg8SEBETEBAWFhYQFhITGBkQExUXFhIaFhUWFRUaHSkgGBomGxUVIj0kJSorLi4uFx8zODM4NygtLisBCgoKDg0OGxAQGzMlHyUtLS0tLS0rLS0tLS0tMi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS01LS0tLS0tLS0tLf/AABEIAKQBMwMBEQACEQEDEQH/<KEY>)
*/
    console.log(`calling await loadV2("app_editor_3")`)
    await loadV2("app_editor_3")
    console.log(`calling await loadV2("app_editor_3") loaded`)

    var mm = null




    Vue.component('homepage', {

      template:
`<div>
    <div    style="position: sticky; left:0px; top:0px; width: 100vw ;z-index: 2;background-color: black;padding:0;margin:0;">

        <div style="border:0px; padding: 0px; margin: 0px;padding-left:15px;font-size: 13px;font-family: Helvetica;color: red;">
             <b>Dannea</b>
        </div>

        <div class='display-4' style="border:0px; padding: 0px; margin: 0px;padding-left:15px;font-family: Helvetica;color: white;">
             Creator
        </div>

        <h6 class="display-6" style="color: lightgray;border:0px;padding: 0px; margin: 0px;padding-left:15px;font-family: Helvetica;">
            Build internal tools visually
        </h6>

    </div>


    <div    style='padding:10px; margin:0;border: 2px solid pink;'>
        <h4>
            Create a new app
        </h4>

        <select v-model="app_type">
            <option           value="new">Blank app</option>
            <option           value="quicksort">Quicksort</option>
            <option selected value="bubblesort">Bubblesort</option>
            <option          value="vb">Drag and Drop Builder</option>
            <option          value="todo">Database app</option>
            <option          value="game">3d AFrame app</option>
            <option          value="new_app">Text only</option>
        </select>

        <button style='margin-bottom:10px;' class='btn btn-primary btn-lg' v-on:click='copyAndEditApp($event,app_type)'>
            Go
        </button>
    </div>



    <div  class="container-fluid" style='position: relative; padding:20;margin:0; width: 95%;'>

        <div v-bind:refresh='refresh'
             ref='maingrid'
             id='maingrid'
             class="grid"
             style='background-color: white; color: black; padding-top: 20px;padding-bottom: 20px;'>

            <div    v-for="(item, index) in intro_apps"
                    class="grid-item col-lg-4">
                    <div
                    style="border-radius: 0px;background-color:white;border-width: 0px;margin:0px;padding:10px;">


               <div v-if="item.type == 'app'" >

               <div v-if="(edit_app == item.data.id)"
                       style="position: fixed; left:0px; top:0px; height:100%; width: 100vw ;z-index: 200000;background-color: white;overflow-y:none; padding: 0px;">
                       <component v-if='' :is='"app_editor_3"' v-bind:app_id='item.data.id' v-bind:card_index='index'></component>
               </div>




               <div style='border-radius: 0px;padding:0px; margin:0;border: 2px solid lightgray;'>

                    <div v-if='isInlineApp(item.data.id)' >
                        <kbd v-on:click='editApp($event,item.data.id)'>
                            {{item.data.id?"" + item.data.id.substring(0,20):""}}{{(item.data.id && ((item.data.id.length > 20))?"...":"")}}
                        </kbd>

                        <component v-if='edit_app != item.data.id' :is='item.data.id'>
                        </component>
                    </div>

                    <div v-if='!isInlineApp(item.data.id)' >
                        <kbd v-on:click='editApp($event,item.data.id)'>{{item.data.id?"" + item.data.id.substring(0,20):""}}{{(item.data.id && ((item.data.id.length > 20))?"...":"")}}
                        </kbd>

                        <span v-if='isEditable(item.data.id)' class="badge badge-warning" >
                            Editable
                        </span>

                        <span v-if='!isEditable(item.data.id)' class="badge badge-info" >
                            Read only
                        </span>

                        <img    v-if='(app_records[item.data.id] && app_records[item.data.id].logo_url && (app_records[item.data.id].logo_url != ""))'
                                v-bind:src='app_records[item.data.id].logo_url'
                                style='width: 100%;'
                                v-bind:alt='app_records[item.data.id].logo_url'
                                v-on:click='editApp($event,item.data.id)'
                                >
                        </img>
                    </div>


                    <ul class="nav flex-column">
                        <li class="nav-item" v-if='!isEditable(item.data.id)'>
                            <a  v-on:click='editApp($event,item.data.id)'
                                class="nav-link active" href="#">View source</a>
                        </li>

                        <li class="nav-item" v-if='isEditable(item.data.id)'>
                            <a  v-on:click='editApp($event,item.data.id)'
                                class="nav-link active" href="#">Edit</a>
                        </li>
                    </ul>

                </div>
            </div>
        </div>


    </div>

</div>`
      ,


    data: function() {
        return {
                    apps:           [],
                    app_type:       "bubblesort",
                    intro_apps:     [],
                    loaded_app:     new Object(),
                    show_menu:      null,
                    refresh:        0,
                    edit_app:       null,
                    app_records:    new Object(),
                    msnry:          null
                }},

    mounted: async function() {
        mm = this

        this.msnry = new Masonry(
           document.getElementById("maingrid"),
            {
                itemSelector: '.grid-item'
            }
        );


       var sql =    "select  *  from  system_code  where " +
                    "        component_type = 'app' and base_component_id like 'homepage_%'" +
                    "        and code_tag = 'LATEST' order by base_component_id asc"

       var results = await callApp(
           {
                driver_name:    "systemFunctions2",
                method_name:    "sql"
           }
           ,
           {
               sql: sql
           }
       )
       for (var rt=0; rt < results.length; rt++) {
           var appId = results[rt].base_component_id
           mm.addAppFast(appId,-1, results[rt])
           component_loaded[appId] = true
       }





       //
       // search
       //
       var sql2 =    `SELECT  id, base_component_id, logo_url, read_write_status
                         FROM
                     system_code
                         where
                             component_type = 'app'
                                 and
                             code_tag = 'LATEST'
                                 and
                             visibility = 'PUBLIC'
                     order by base_component_id asc; `

       var results2 = await callApp(
           {
                driver_name:    "systemFunctions2",
                method_name:    "sql"
           }
           ,
           {
               sql: sql2
           })
       for (var rt2=0; rt2 < results2.length; rt2++) {
           var appId = results2[rt2].base_component_id
           if (!mm.loaded_app[  appId  ]) {
                 mm.addAppFast(appId,-1, results2[rt2])
           }
       }










        this.$root.$on('message', async function(text) {
            if (text.type == "insert_app_at") {
                console.log(JSON.stringify(text,null,2));
                mm.intro_apps.splice(text.card_index, 0, {});
                await mm.addApp(text.base_component_id, text.card_index)
                mm.edit_app = text.base_component_id
                mm.refresh++
            }

            if (text.type == "close_app") {
                mm.show_menu = null;
                mm.edit_app = null;
                mm.refresh++
            }

        })

         globalEventBus.$on('new-appshare-app-uploaded',
            async function(data) {
                //zzz
                //alert(JSON.stringify(data,null,2))
                mm.intro_apps.splice(1, 0, {});
                await mm.addApp(data, 1)
                setTimeout(function() {
                      mm.editApp(null, data)
                },50)
         });

         setTimeout(function() {
             mm.msnry.reloadItems();
             mm.msnry.layout();
         },50)




      },



      methods: {
          addAppFast: function(baseComponentId, cardIndex,vv) {
              if (baseComponentId) {

                  if (vv.code) {
                      var x = eval("(" + vv.code + ")")
                      x.call()
                  }
                  var app = {
                                        type: "app",
                                        data:
                                            {
                                                id: baseComponentId
                                            }
                                      }
                  if (cardIndex != -1) {
                    mm.intro_apps[cardIndex] =  app

                  } else {
                    mm.intro_apps.push( app  )
                  }
                  mm.loaded_app[baseComponentId] = true
                  if (vv) {
                      mm.app_records[vv.base_component_id] = vv
                      mm.refresh++
                  }

              }
          },




            addApp: async function(baseComponentId, cardIndex) {
              if (baseComponentId) {
                  var app = {
                                        type: "app",
                                        data:
                                            {
                                                id: baseComponentId
                                            }
                                      }
                  if (cardIndex != -1) {
                    mm.intro_apps[cardIndex] =  app

                  } else {
                    mm.intro_apps.push( app  )
                  }
                  mm.loaded_app[baseComponentId] = true
                  component_loaded[baseComponentId] = false
                  dev_app_component_loaded[baseComponentId] = false
                  component_cache[baseComponentId] = null
                  var vv = await loadV2(baseComponentId)
                  if (vv) {
                      mm.app_records[vv.base_component_id] = vv
                      mm.refresh++
                  }
              }
              return null
          },
          copyApp: async function(  baseComponentId ) {
              callDriverMethod( {driver_name: "copyApp",
                                 method_name: "copyAppshareApp"}
                                ,{base_component_id:    baseComponentId}
                          ,
                          async function(result) {
                              mm.intro_apps.splice(1, 0, {});
                              await mm.addApp(result.value.base_component_id, 1)

                          })
          },
          copyAndEditApp: async function(event,  baseComponentId ) {
              callDriverMethod( {driver_name: "copyApp",
                                 method_name: "copyAppshareApp"}
                                ,{base_component_id:    baseComponentId}
                          ,
                          async function(result) {
                              mm.intro_apps.splice(1, 0, {});
                              await mm.addApp(result.value.base_component_id, 1)
                              setTimeout(function() {
                                    mm.editApp(event, result.value.base_component_id)
                              },50)

                          })
          },
          isEditable: function(baseComponentId) {
                if (this.app_records[baseComponentId]) {
                    if ((this.app_records[baseComponentId].read_write_status == null ) ||
                         (this.app_records[baseComponentId].read_write_status.indexOf("READ") == -1 ))   {
                         return true
                }

                }

               return false
          },
          isInlineApp: function(baseComponentId) {
                if (baseComponentId && (baseComponentId.length > 0)) {
                    if ((!this.isEditable(baseComponentId)) && (baseComponentId.startsWith("homepage"))) {
                        return true
                    }
                }

               return false
          },
          editApp: async function(event,item) {
              if (event) {
                  event.stopPropagation()
              }
              this.show_menu = null;
              this.edit_app = item;
          },
          showMenu: async function(item) {
            this.show_menu= item;
          }


      }
    })

}

{'fraction_non_alphanumeric': 0.1123999706335805, 'fraction_numerical': 0.012003523970339916, 'mean_word_length': 1.176653883029722, 'pattern_counts': {'":': 4, '<': 156, '<?xml version=': 0, '>': 158, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 3, 'word_list_counts': {'cursed_substrings.json': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6332088', 'n_tokens_mistral': 8057, 'n_tokens_neox': 7487, 'n_words': 1146}