mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-13 02:42:45 +00:00
feat: insentive replace
This commit is contained in:
@@ -4,6 +4,7 @@ import json
|
||||
import socket
|
||||
import os
|
||||
import urllib
|
||||
import re
|
||||
|
||||
# non standards, in requirements.txt
|
||||
from flask import Flask, request, Markup, render_template, redirect, url_for
|
||||
@@ -52,7 +53,7 @@ class Anonymous_Github:
|
||||
def file_render(file, terms):
|
||||
def removeTerms(content, terms):
|
||||
for term in terms:
|
||||
content = content.replace(term, "XXX")
|
||||
content = re.compile(term, re.IGNORECASE).sub("XXX", content)
|
||||
return content
|
||||
|
||||
if file.size > 1000000:
|
||||
@@ -98,7 +99,6 @@ class Anonymous_Github:
|
||||
break
|
||||
|
||||
return render_template('repo.html',
|
||||
name=data['name'],
|
||||
terms=data["terms"],
|
||||
current_repository=id,
|
||||
current_file=current_file,
|
||||
@@ -126,7 +126,6 @@ class Anonymous_Github:
|
||||
id = request.args.get('id', str(uuid.uuid4()))
|
||||
repo = request.form['githubRepository']
|
||||
terms = request.form['terms']
|
||||
repo_name = request.form['name']
|
||||
|
||||
config_path = self.config_dir + "/" + str(id)
|
||||
if not os.path.exists(config_path):
|
||||
@@ -134,7 +133,6 @@ class Anonymous_Github:
|
||||
with open(config_path + "/config.json", 'w') as outfile:
|
||||
json.dump({
|
||||
"id": id,
|
||||
"name": repo_name,
|
||||
"repository": repo,
|
||||
"terms": terms.splitlines()
|
||||
}, outfile)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<title>GitHub Anonymous</title>
|
||||
<!-- 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">
|
||||
|
||||
@@ -13,23 +13,18 @@
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="container-fluid">
|
||||
<h1>GihHub Anonymous</h1>
|
||||
<h2>Anonymous a GitHub repository</h2>
|
||||
<h1>GitHub Anonymous</h1>
|
||||
<h2>Anonymize a GitHub repository</h2>
|
||||
<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">
|
||||
<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>
|
||||
<input type="url" value="{{ repo.repository }}" class="form-control" name="githubRepository" id="githubRepository" aria-describedby="githubRepository" placeholder="GitHub Repository">
|
||||
</div>
|
||||
<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>
|
||||
<small id="ignoredTermsHelp" class="form-text text-muted">One term per line.</small>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
@@ -38,13 +33,13 @@
|
||||
<form action="" method="get">
|
||||
<div class="form-group">
|
||||
<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>
|
||||
<input class="form-control" name="id" id="name" aria-describedby="name" placeholder="Id Anonymous GitHub Repository">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<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>
|
||||
<input type="url" class="form-control" name="githubRepository" id="githubRepository" aria-describedby="githubRepository" placeholder="GitHub Repository">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="paths">
|
||||
{% set current_path = [] %}
|
||||
{% 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 %}
|
||||
{% do current_path.append(item) %}
|
||||
<span class="path"><a href="{{ current_path|join("/") }}">{{ item }}</a></span>
|
||||
|
||||
Reference in New Issue
Block a user