<commit_before><!doctype html>
<html>
    <head>
    <meta charset="UTF-8">
    <title>ShutterStem - Importing {{ name }}</title>
    
    <style>
        #config { display: none; }
        .error { display: none; font-family: monospace; font-size: 150%; }
        .error h2 { color: red; }
        
        #new_photos img { margin: 10px; border-style: solid; border-width: 2px; }
        #new_photos img.pending { border-style: dotted; border-color: yellow; }
        #new_photos img.imported { border-color: green; }
        
        #import { font-size: 200%; color: green; }
        #cancel { font-size: 90%; color: gray; }
        #import, #cancel { visibility: hidden; }
        #import.enabled, #cancel.enabled { visibility: visible; }
    </style>
    <script src="{{ database_url }}/_design/shutterstem/couch.js"></script>
    <script src="{{ database_url }}/_design/shutterstem/classlist.js"></script>
    </head>
    
    <body>
        <h2>Some new images found for this source:</h2>
        <div id="new_photos"></div>
        <a href id="import">Start Import</a>
        <a href id="cancel">Cancel</a>
        
        <div id="config"
            data-database_url="{{ database_url }}"
            data-import_id="{{ _id }}"
            data-utility_path="{{ utility_path }}"
            data-csrf_token="{{ csrf_token }}"></div>
        <script>
            var config = document.getElementById('config');
            var database_url = config.getAttribute('data-database_url');
            var import_id = config.getAttribute('data-import_id');
            var utility_path = config.getAttribute('data-utility_path');
            var csrf_token = config.getAttribute('data-csrf_token');
            
            var db = new Couch(database_url);
            
            var new_photos = document.getElementById("new_photos");
            db.http("POST", null, ['_import', import_id, 'folder'], {utility:utility_path, token:csrf_token}, function (status, response) {
                // check for import started (or already in progress)
                if (status != 202 && status != 409) {
                    new_photos.innerText = JSON.stringify(response, null, 4);
                    return;
                }
                
                function updateStatus() {
                    //new_photos.innerText = JSON.stringify(response, null, 4);
                    var response = db.get(['_import', import_id]);
                    new_photos.innerHTML = "";
                    response.recent.forEach(function (image_doc) {
                        var img = new Image();
                        img.width = img.height = 64;
                        img.alt = image_doc.path;
                        //var thumb = image_doc._attachments['thumbnail/64.jpg'];
                        //img.src = "data:" + thumb.type + "base64," + thumb.data;
                        new_photos.appendChild(img);
                    });
                } 
                var timer = setInterval(updateStatus, 2500);
                updateStatus();
                
                if (status == 409) {
                    // no token, can't perform actions
                    // TODO: look into security implications of storing token in localStorage
                    //return;<commit_msg>prevent existing imports from getting action controls<commit_after><!doctype html>
<html>
    <head>
    <meta charset="UTF-8">
    <title>ShutterStem - Importing {{ name }}</title>
    
    <style>
        #config { display: none; }
        .error { display: none; font-family: monospace; font-size: 150%; }
        .error h2 { color: red; }
        
        #new_photos img { margin: 10px; border-style: solid; border-width: 2px; }
        #new_photos img.pending { border-style: dotted; border-color: yellow; }
        #new_photos img.imported { border-color: green; }
        
        #import { font-size: 200%; color: green; }
        #cancel { font-size: 90%; color: gray; }
        #import, #cancel { visibility: hidden; }
        #import.enabled, #cancel.enabled { visibility: visible; }
    </style>
    <script src="{{ database_url }}/_design/shutterstem/couch.js"></script>
    <script src="{{ database_url }}/_design/shutterstem/classlist.js"></script>
    </head>
    
    <body>
        <h2>Some new images found for this source:</h2>
        <div id="new_photos"></div>
        <a href id="import">Start Import</a>
        <a href id="cancel">Cancel</a>
        
        <div id="config"
            data-database_url="{{ database_url }}"
            data-import_id="{{ _id }}"
            data-utility_path="{{ utility_path }}"
            data-csrf_token="{{ csrf_token }}"></div>
        <script>
            var config = document.getElementById('config');
            var database_url = config.getAttribute('data-database_url');
            var import_id = config.getAttribute('data-import_id');
            var utility_path = config.getAttribute('data-utility_path');
            var csrf_token = config.getAttribute('data-csrf_token');
            
            var db = new Couch(database_url);
            
            var new_photos = document.getElementById("new_photos");
            db.http("POST", null, ['_import', import_id, 'folder'], {utility:utility_path, token:csrf_token}, function (status, response) {
                // check for import started (or already in progress)
                if (status != 202 && status != 409) {
                    new_photos.innerText = JSON.stringify(response, null, 4);
                    return;
                }
                
                function updateStatus() {
                    //new_photos.innerText = JSON.stringify(response, null, 4);
                    var response = db.get(['_import', import_id]);
                    new_photos.innerHTML = "";
                    response.recent.forEach(function (image_doc) {
                        var img = new Image();
                        img.width = img.height = 64;
                        img.alt = image_doc.path;
                        //var thumb = image_doc._attachments['thumbnail/64.jpg'];
                        //img.src = "data:" + thumb.type + "base64," + thumb.data;
                        new_photos.appendChild(img);
                    });
                } 
                var timer = setInterval(updateStatus, 2500);
                updateStatus();
                
                if (status == 409) {
                    // no token, can't perform actions
                    // TODO: look into security implications of storing token in localStorage
                    return;
{'fraction_non_alphanumeric': 0.12835191322687556, 'fraction_numerical': 0.01084664055438385, 'mean_word_length': 1.6998779991866613, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4200698', 'n_tokens_mistral': 1874, 'n_tokens_neox': 1732, 'n_words': 415}