mirror of
				https://github.com/dgtlmoon/changedetection.io.git
				synced 2025-11-04 08:34:57 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			misc-fixes
			...
			export-reg
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					23d0679d13 | 
							
								
								
									
										24
									
								
								changedetectionio/blueprint/extract/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								changedetectionio/blueprint/extract/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from flask import Blueprint, request, make_response
 | 
			
		||||
from flask_login import login_required
 | 
			
		||||
import os
 | 
			
		||||
import logging
 | 
			
		||||
from changedetectionio.store import ChangeDetectionStore
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def construct_blueprint(datastore: ChangeDetectionStore):
 | 
			
		||||
 | 
			
		||||
    browser_steps_blueprint = Blueprint('browser_steps', __name__, template_folder="templates")
 | 
			
		||||
 | 
			
		||||
    @login_required
 | 
			
		||||
    @browser_steps_blueprint.route("/extract-regex", methods=['POST'])
 | 
			
		||||
    def browsersteps_ui_update():
 | 
			
		||||
        import time
 | 
			
		||||
 | 
			
		||||
        return {123123123: 'yup'}
 | 
			
		||||
 | 
			
		||||
    return browser_steps_blueprint
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										40
									
								
								changedetectionio/static/js/extract.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								changedetectionio/static/js/extract.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
$(document).ready(function () {
 | 
			
		||||
 | 
			
		||||
    $('#extract').click(function (e) {
 | 
			
		||||
        download_csv_file();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
//create CSV file data in an array
 | 
			
		||||
    var csvFileData = [
 | 
			
		||||
        ['Alan Walker', 'Singer'],
 | 
			
		||||
        ['Cristiano Ronaldo', 'Footballer'],
 | 
			
		||||
        ['Saina Nehwal', 'Badminton Player'],
 | 
			
		||||
        ['Arijit Singh', 'Singer'],
 | 
			
		||||
        ['Terence Lewis', 'Dancer']
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
//create a user-defined function to download CSV file
 | 
			
		||||
    function download_csv_file() {
 | 
			
		||||
 | 
			
		||||
        //define the heading for each row of the data
 | 
			
		||||
        var csv = 'Name,Profession\n';
 | 
			
		||||
 | 
			
		||||
        //merge the data with CSV
 | 
			
		||||
        csvFileData.forEach(function (row) {
 | 
			
		||||
            csv += row.join(',');
 | 
			
		||||
            csv += "\n";
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        //display the created CSV data on the web browser
 | 
			
		||||
        document.write(csv);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        var hiddenElement = document.createElement('a');
 | 
			
		||||
        hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
 | 
			
		||||
        hiddenElement.target = '_blank';
 | 
			
		||||
        //provide the name for the CSV file to be downloaded
 | 
			
		||||
        hiddenElement.download = 'Famous Personalities.csv';
 | 
			
		||||
        hiddenElement.click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
});
 | 
			
		||||
@@ -23,6 +23,7 @@
 | 
			
		||||
<script type="text/javascript" src="{{url_for('static_content', group='js', filename='visual-selector.js')}}" defer></script>
 | 
			
		||||
{% if playwright_enabled %}
 | 
			
		||||
<script type="text/javascript" src="{{url_for('static_content', group='js', filename='browser-steps.js')}}" defer></script>
 | 
			
		||||
<script type="text/javascript" src="{{url_for('static_content', group='js', filename='extract.js')}}" defer></script>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
<div class="edit-form monospaced-textarea">
 | 
			
		||||
@@ -37,6 +38,7 @@
 | 
			
		||||
            <li class="tab"><a id="visualselector-tab" href="#visualselector">Visual Filter Selector</a></li>
 | 
			
		||||
            <li class="tab"><a href="#filters-and-triggers">Filters & Triggers</a></li>
 | 
			
		||||
            <li class="tab"><a href="#notifications">Notifications</a></li>
 | 
			
		||||
            <li class="tab"><a href="#export">Export</a></li>
 | 
			
		||||
        </ul>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
@@ -374,6 +376,30 @@ Unavailable") }}
 | 
			
		||||
                </fieldset>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
            <div class="tab-pane-inner" id="export">
 | 
			
		||||
                    <div class="pure-control-group">
 | 
			
		||||
                    </div>
 | 
			
		||||
 | 
			
		||||
                <fieldset>
 | 
			
		||||
                    <div class="pure-control-group">
 | 
			
		||||
                        <div>
 | 
			
		||||
                            Enter a regular-expression, all history snapshots will be scanned and where the regex
 | 
			
		||||
                            matches, it will exported along with the times-stamp.<br>
 | 
			
		||||
                            For a complete backup, use the <strong>Backup</strong> button<br>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <p>
 | 
			
		||||
                            <label>Scan and Extract</label>
 | 
			
		||||
                            <input name=regex type="text" placeholder="Example: Temperature (\d+)">
 | 
			
		||||
                        </p>
 | 
			
		||||
                        <span class="pure-form-message-inline">
 | 
			
		||||
                                The regex you enter will be stored for next time
 | 
			
		||||
                            </span>
 | 
			
		||||
                        <div class="pure-control-group">
 | 
			
		||||
                            <input class="pure-button pure-button-primary" id="extract" name="extract" type="button" value="Scan and Extract">
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </fieldset>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div id="actions">
 | 
			
		||||
                <div class="pure-control-group">
 | 
			
		||||
                    {{ render_button(form.save_button) }}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user