mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-25 18:37:47 +02:00
feat: insentive replace
This commit is contained in:
@@ -4,6 +4,7 @@ import json
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import urllib
|
import urllib
|
||||||
|
import re
|
||||||
|
|
||||||
# non standards, in requirements.txt
|
# non standards, in requirements.txt
|
||||||
from flask import Flask, request, Markup, render_template, redirect, url_for
|
from flask import Flask, request, Markup, render_template, redirect, url_for
|
||||||
@@ -52,7 +53,7 @@ class Anonymous_Github:
|
|||||||
def file_render(file, terms):
|
def file_render(file, terms):
|
||||||
def removeTerms(content, terms):
|
def removeTerms(content, terms):
|
||||||
for term in terms:
|
for term in terms:
|
||||||
content = content.replace(term, "XXX")
|
content = re.compile(term, re.IGNORECASE).sub("XXX", content)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
if file.size > 1000000:
|
if file.size > 1000000:
|
||||||
@@ -98,7 +99,6 @@ class Anonymous_Github:
|
|||||||
break
|
break
|
||||||
|
|
||||||
return render_template('repo.html',
|
return render_template('repo.html',
|
||||||
name=data['name'],
|
|
||||||
terms=data["terms"],
|
terms=data["terms"],
|
||||||
current_repository=id,
|
current_repository=id,
|
||||||
current_file=current_file,
|
current_file=current_file,
|
||||||
@@ -126,7 +126,6 @@ class Anonymous_Github:
|
|||||||
id = request.args.get('id', str(uuid.uuid4()))
|
id = request.args.get('id', str(uuid.uuid4()))
|
||||||
repo = request.form['githubRepository']
|
repo = request.form['githubRepository']
|
||||||
terms = request.form['terms']
|
terms = request.form['terms']
|
||||||
repo_name = request.form['name']
|
|
||||||
|
|
||||||
config_path = self.config_dir + "/" + str(id)
|
config_path = self.config_dir + "/" + str(id)
|
||||||
if not os.path.exists(config_path):
|
if not os.path.exists(config_path):
|
||||||
@@ -134,7 +133,6 @@ class Anonymous_Github:
|
|||||||
with open(config_path + "/config.json", 'w') as outfile:
|
with open(config_path + "/config.json", 'w') as outfile:
|
||||||
json.dump({
|
json.dump({
|
||||||
"id": id,
|
"id": id,
|
||||||
"name": repo_name,
|
|
||||||
"repository": repo,
|
"repository": repo,
|
||||||
"terms": terms.splitlines()
|
"terms": terms.splitlines()
|
||||||
}, outfile)
|
}, outfile)
|
||||||
|
|||||||
+8
-13
@@ -4,7 +4,7 @@
|
|||||||
<!-- Required meta tags -->
|
<!-- Required meta tags -->
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<title>GitHub Anonymous</title>
|
||||||
<!-- Bootstrap CSS -->
|
<!-- Bootstrap CSS -->
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
|
||||||
|
|
||||||
@@ -13,23 +13,18 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<h1>GihHub Anonymous</h1>
|
<h1>GitHub Anonymous</h1>
|
||||||
<h2>Anonymous a GitHub repository</h2>
|
<h2>Anonymize a GitHub repository</h2>
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<div class="form-group">
|
|
||||||
<label for="name">GitHub Repository</label>
|
|
||||||
<input class="form-control" value="{{ repo.name }}" name="name" id="name" aria-describedby="name" placeholder="Anonymous Name">
|
|
||||||
<small id="nameHelp" class="form-text text-muted">The anonymous name of the repository.</small>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="githubRepository">GitHub Repository</label>
|
<label for="githubRepository">GitHub Repository</label>
|
||||||
<input type="url" value="{{ repo.repository }}" class="form-control" name="githubRepository" id="githubRepository" aria-describedby="githubRepository" placeholder="GitHub Repository">
|
|
||||||
<small id="githubRepositoryHelp" class="form-text text-muted">The github url to the repository that you want to anonymous.</small>
|
<small id="githubRepositoryHelp" class="form-text text-muted">The github url to the repository that you want to anonymous.</small>
|
||||||
|
<input type="url" value="{{ repo.repository }}" class="form-control" name="githubRepository" id="githubRepository" aria-describedby="githubRepository" placeholder="GitHub Repository">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="ignoredTerms">The text to remove from the repository</label>
|
<label for="ignoredTerms">The text to remove from the repository will be replaced by XXX.</label>
|
||||||
|
<small id="ignoredTermsHelp" class="form-text text-muted">One term per line (case insensitive).</small>
|
||||||
<textarea class="form-control" name="terms" id="ignoredTerms" rows="5">{{ repo.terms|join('\n') }}</textarea>
|
<textarea class="form-control" name="terms" id="ignoredTerms" rows="5">{{ repo.terms|join('\n') }}</textarea>
|
||||||
<small id="ignoredTermsHelp" class="form-text text-muted">One term per line.</small>
|
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -38,13 +33,13 @@
|
|||||||
<form action="" method="get">
|
<form action="" method="get">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Anonymous GitHub Repository</label>
|
<label for="name">Anonymous GitHub Repository</label>
|
||||||
<input class="form-control" name="id" id="name" aria-describedby="name" placeholder="Id Anonymous GitHub Repository">
|
|
||||||
<small id="nameHelp" class="form-text text-muted">The id of the Anonymous GitHub repository.</small>
|
<small id="nameHelp" class="form-text text-muted">The id of the Anonymous GitHub repository.</small>
|
||||||
|
<input class="form-control" name="id" id="name" aria-describedby="name" placeholder="Id Anonymous GitHub Repository">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="githubRepository">GitHub Repository</label>
|
<label for="githubRepository">GitHub Repository</label>
|
||||||
<input type="url" class="form-control" name="githubRepository" id="githubRepository" aria-describedby="githubRepository" placeholder="GitHub Repository">
|
|
||||||
<small id="githubRepositoryHelp" class="form-text text-muted">The github url to the repository that you want to anonymous.</small>
|
<small id="githubRepositoryHelp" class="form-text text-muted">The github url to the repository that you want to anonymous.</small>
|
||||||
|
<input type="url" class="form-control" name="githubRepository" id="githubRepository" aria-describedby="githubRepository" placeholder="GitHub Repository">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
<div class="paths">
|
<div class="paths">
|
||||||
{% set current_path = [] %}
|
{% set current_path = [] %}
|
||||||
{% do current_path.append('/repository/' + current_repository) %}
|
{% do current_path.append('/repository/' + current_repository) %}
|
||||||
<span class="path"><a href="{{ current_path|join("/") }}">{{ name }}</a></span>
|
<span class="path"><a href="{{ current_path|join("/") }}">Root</a></span>
|
||||||
{% for item in path %}
|
{% for item in path %}
|
||||||
{% do current_path.append(item) %}
|
{% do current_path.append(item) %}
|
||||||
<span class="path"><a href="{{ current_path|join("/") }}">{{ item }}</a></span>
|
<span class="path"><a href="{{ current_path|join("/") }}">{{ item }}</a></span>
|
||||||
|
|||||||
Reference in New Issue
Block a user