mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-06 05:38:09 +02:00
add profile page with default optins settings
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
<h6 class="card-subtitle mb-2 text-muted">
|
<h6 class="card-subtitle mb-2 text-muted">
|
||||||
Fill the information to annoymize! It will only take 5min.
|
Fill the information to annoymize! It will only take 5min.
|
||||||
</h6>
|
</h6>
|
||||||
|
<!-- repoUrl -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="repoUrl">Type the url of your repository</label>
|
<label for="repoUrl">Type the url of your repository</label>
|
||||||
<input
|
<input
|
||||||
@@ -52,6 +53,7 @@
|
|||||||
{{repoUrl}} is already anonymized
|
{{repoUrl}} is already anonymized
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- select repo -->
|
||||||
<div class="form-group" ng-hide="repoUrl">
|
<div class="form-group" ng-hide="repoUrl">
|
||||||
<label for="repositories">Or select one of your repository</label>
|
<label for="repositories">Or select one of your repository</label>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
<!-- <span ng-bind="user.username"></span> -->
|
<!-- <span ng-bind="user.username"></span> -->
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||||
<!-- <a class="dropdown-item" href="/profile">My Profile</a> -->
|
<a class="dropdown-item" href="/profile">My Profile</a>
|
||||||
<a class="dropdown-item" href="/dashboard">Projects</a>
|
<a class="dropdown-item" href="/dashboard">Projects</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="/api/user/logout" target="__self"
|
<a class="dropdown-item" href="/api/user/logout" target="__self"
|
||||||
|
|||||||
@@ -0,0 +1,255 @@
|
|||||||
|
<div class="container py-4">
|
||||||
|
<h1 ng-bind="user.username"></h1>
|
||||||
|
|
||||||
|
<h2>Default anonymization options</h2>
|
||||||
|
<form class="form needs-validation" name="default" novalidate>
|
||||||
|
<!-- Terms -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="terms">Terms to anonymize</label>
|
||||||
|
<textarea
|
||||||
|
class="form-control"
|
||||||
|
id="terms"
|
||||||
|
name="terms"
|
||||||
|
rows="3"
|
||||||
|
ng-model="terms"
|
||||||
|
ng-model-options="{ debounce: 250 }"
|
||||||
|
></textarea>
|
||||||
|
<small id="termsHelp" class="form-text text-muted"
|
||||||
|
>One term per line. Each term will be replaced by XXX</small
|
||||||
|
>
|
||||||
|
<div class="invalid-feedback" ng-show="anonymize.terms.$error.format">
|
||||||
|
Terms are in an invalid format
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="accordion mb-3" id="options">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header" id="headingOne">
|
||||||
|
<h2 class="mb-0">
|
||||||
|
<button
|
||||||
|
class="btn btn-block text-left"
|
||||||
|
type="button"
|
||||||
|
data-toggle="collapse"
|
||||||
|
data-target="#collapseOne"
|
||||||
|
aria-expanded="true"
|
||||||
|
aria-controls="collapseOne"
|
||||||
|
>
|
||||||
|
Rendering options
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
id="collapseOne"
|
||||||
|
class="collapse show"
|
||||||
|
aria-labelledby="headingOne"
|
||||||
|
data-parent="#options"
|
||||||
|
>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="link"
|
||||||
|
name="link"
|
||||||
|
ng-model="options.link"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="link">Keep links</label>
|
||||||
|
<small id="termsHelp" class="form-text text-muted"
|
||||||
|
>Keep or remove all the links.</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="image"
|
||||||
|
name="image"
|
||||||
|
ng-model="options.image"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="image"
|
||||||
|
>Display images</label
|
||||||
|
>
|
||||||
|
<small id="termsHelp" class="form-text text-muted"
|
||||||
|
>Images are not anonymized</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="pdf"
|
||||||
|
name="pdf"
|
||||||
|
ng-model="options.pdf"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="pdf">Display PDFs</label>
|
||||||
|
<small id="termsHelp" class="form-text text-muted"
|
||||||
|
>PDF are not anonymized</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="notebook"
|
||||||
|
name="notebook"
|
||||||
|
ng-model="options.notebook"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="notebook"
|
||||||
|
>Display Notebooks</label
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header" id="headingTwo">
|
||||||
|
<h2 class="mb-0">
|
||||||
|
<button
|
||||||
|
class="btn btn-block text-left collapsed"
|
||||||
|
type="button"
|
||||||
|
data-toggle="collapse"
|
||||||
|
data-target="#collapseTwo"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-controls="collapseTwo"
|
||||||
|
>
|
||||||
|
Features
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
id="collapseTwo"
|
||||||
|
class="collapse"
|
||||||
|
aria-labelledby="headingTwo"
|
||||||
|
data-parent="#options"
|
||||||
|
>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="page"
|
||||||
|
name="page"
|
||||||
|
ng-model="options.page"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="page">Github page</label>
|
||||||
|
<small id="termsHelp" class="form-text text-muted"
|
||||||
|
>Enable anonymized Github pages. It currently only suported
|
||||||
|
for Github pages that are defined in the same branch.</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="loc"
|
||||||
|
name="loc"
|
||||||
|
ng-model="options.loc"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="page">Line of code</label>
|
||||||
|
<small id="termsHelp" class="form-text text-muted"
|
||||||
|
>Display the number of line of code in the reposiotry</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="update"
|
||||||
|
name="update"
|
||||||
|
ng-model="options.update"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="update"
|
||||||
|
>Auto update</label
|
||||||
|
>
|
||||||
|
<small id="termsHelp" class="form-text text-muted"
|
||||||
|
>Automatically update the anonymized repository with the
|
||||||
|
latest commit of the repository. The repository is updated
|
||||||
|
once per hour maximum.</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="mode">Proxy mode</label>
|
||||||
|
<select
|
||||||
|
class="form-control"
|
||||||
|
id="mode"
|
||||||
|
name="mode"
|
||||||
|
ng-model="options.mode"
|
||||||
|
>
|
||||||
|
<option value="stream" selected>Stream</option>
|
||||||
|
<option value="download">Download</option>
|
||||||
|
</select>
|
||||||
|
<small class="form-text text-muted"
|
||||||
|
>How the repository will be anonymized. Stream mode will
|
||||||
|
request the content on the flight. This is the only option for
|
||||||
|
repositories bigger than 10mb. Download will download the
|
||||||
|
repository the repository on the anonymous.4open.science
|
||||||
|
server, it is faster and offer more features.</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header" id="headingThree">
|
||||||
|
<h2 class="mb-0">
|
||||||
|
<button
|
||||||
|
class="btn btn-block text-left collapsed"
|
||||||
|
type="button"
|
||||||
|
data-toggle="collapse"
|
||||||
|
data-target="#collapseThree"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-controls="collapseThree"
|
||||||
|
>
|
||||||
|
Expiration
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
id="collapseThree"
|
||||||
|
class="collapse"
|
||||||
|
aria-labelledby="headingThree"
|
||||||
|
data-parent="#options"
|
||||||
|
>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="expiration">Expiration options</label>
|
||||||
|
<select
|
||||||
|
class="form-control"
|
||||||
|
id="expiration"
|
||||||
|
name="expiration"
|
||||||
|
ng-model="options.expirationMode"
|
||||||
|
>
|
||||||
|
<option value="never" selected>Never expire</option>
|
||||||
|
<option value="redirect">Redirect to GitHub</option>
|
||||||
|
<option value="remove">Remove anonymized repository</option>
|
||||||
|
</select>
|
||||||
|
<small class="form-text text-muted"
|
||||||
|
>Define the expiration strategy for the repository.</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="alert alert-danger"
|
||||||
|
role="alert"
|
||||||
|
ng-if="error"
|
||||||
|
ng-bind="error"
|
||||||
|
></div>
|
||||||
|
<button
|
||||||
|
id="save"
|
||||||
|
type="submit"
|
||||||
|
class="btn btn-primary"
|
||||||
|
ng-click="saveDefault($event)"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
@@ -42,6 +42,11 @@ angular
|
|||||||
controller: "faqController",
|
controller: "faqController",
|
||||||
title: "FAQ - Anonymous GitHub",
|
title: "FAQ - Anonymous GitHub",
|
||||||
})
|
})
|
||||||
|
.when("/profile", {
|
||||||
|
templateUrl: "/partials/profile.htm",
|
||||||
|
controller: "profileController",
|
||||||
|
title: "Profile - Anonymous GitHub",
|
||||||
|
})
|
||||||
.when("/claim", {
|
.when("/claim", {
|
||||||
templateUrl: "/partials/claim.htm",
|
templateUrl: "/partials/claim.htm",
|
||||||
controller: "claimController",
|
controller: "claimController",
|
||||||
@@ -124,6 +129,47 @@ angular
|
|||||||
}
|
}
|
||||||
getSupportedFileTypes();
|
getSupportedFileTypes();
|
||||||
})
|
})
|
||||||
|
.controller("profileController", function($scope, $http) {
|
||||||
|
$scope.terms = "";
|
||||||
|
$scope.options = {
|
||||||
|
expirationMode: "remove",
|
||||||
|
update: false,
|
||||||
|
image: true,
|
||||||
|
pdf: true,
|
||||||
|
notebook: true,
|
||||||
|
loc: true,
|
||||||
|
link: true,
|
||||||
|
mode: "download",
|
||||||
|
};
|
||||||
|
|
||||||
|
function getDefault() {
|
||||||
|
$http.get("/api/user/default").then((res) => {
|
||||||
|
const data = res.data;
|
||||||
|
if (data.terms) {
|
||||||
|
$scope.terms = data.terms.join("\n");
|
||||||
|
}
|
||||||
|
$scope.option = Object.assign({}, $scope.option, data.options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getDefault();
|
||||||
|
|
||||||
|
$scope.saveDefault = () => {
|
||||||
|
const params = {
|
||||||
|
terms: $scope.terms.trim().split("\n"),
|
||||||
|
options: $scope.options,
|
||||||
|
};
|
||||||
|
$http.post("/api/user/default", params).then(
|
||||||
|
() => {
|
||||||
|
getDefault();
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
$translate("ERRORS." + error.data.error).then((translation) => {
|
||||||
|
$scope.error = translation;
|
||||||
|
}, console.error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
})
|
||||||
.controller("claimController", function($scope, $location, $http) {
|
.controller("claimController", function($scope, $location, $http) {
|
||||||
$scope.repoId = null;
|
$scope.repoId = null;
|
||||||
$scope.repoUrl = null;
|
$scope.repoUrl = null;
|
||||||
@@ -271,6 +317,7 @@ angular
|
|||||||
$scope.repoUrl = "";
|
$scope.repoUrl = "";
|
||||||
$scope.repoId = "";
|
$scope.repoId = "";
|
||||||
$scope.terms = "";
|
$scope.terms = "";
|
||||||
|
$scope.defaultTerms = "";
|
||||||
$scope.branch = "";
|
$scope.branch = "";
|
||||||
|
|
||||||
$scope.branches = [];
|
$scope.branches = [];
|
||||||
@@ -292,6 +339,18 @@ angular
|
|||||||
$scope.html_readme = "";
|
$scope.html_readme = "";
|
||||||
$scope.isUpdate = false;
|
$scope.isUpdate = false;
|
||||||
|
|
||||||
|
function getDefault() {
|
||||||
|
$http.get("/api/user/default").then((res) => {
|
||||||
|
const data = res.data;
|
||||||
|
if (data.terms) {
|
||||||
|
$scope.defaultTerms = data.terms.join("\n");
|
||||||
|
}
|
||||||
|
$scope.options = Object.assign({}, $scope.options, data.options);
|
||||||
|
$scope.options.expirationDate = new Date($scope.options.expirationDate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getDefault();
|
||||||
|
|
||||||
if ($routeParams.repoId && $routeParams.repoId != "") {
|
if ($routeParams.repoId && $routeParams.repoId != "") {
|
||||||
$scope.isUpdate = true;
|
$scope.isUpdate = true;
|
||||||
$scope.repoId = $routeParams.repoId;
|
$scope.repoId = $routeParams.repoId;
|
||||||
@@ -341,7 +400,7 @@ angular
|
|||||||
$scope.getRepositories();
|
$scope.getRepositories();
|
||||||
|
|
||||||
$scope.repoSelected = async () => {
|
$scope.repoSelected = async () => {
|
||||||
$scope.terms = "";
|
$scope.terms = $scope.defaultTerms;
|
||||||
$scope.repoId = "";
|
$scope.repoId = "";
|
||||||
$scope.branch = "";
|
$scope.branch = "";
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,21 @@ router.get("/", async (req, res) => {
|
|||||||
res.json({ username: req.user.profile.username, photo });
|
res.json({ username: req.user.profile.username, photo });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get("/default", async (req, res) => {
|
||||||
|
const d = await db
|
||||||
|
.get("users")
|
||||||
|
.findOne({ username: req.user.username }, { projection: { default: 1 } });
|
||||||
|
res.json(d.default);
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post("/default", async (req, res) => {
|
||||||
|
const d = req.body;
|
||||||
|
await db
|
||||||
|
.get("users")
|
||||||
|
.updateOne({ username: req.user.username }, { $set: { default: d } });
|
||||||
|
res.send("ok");
|
||||||
|
});
|
||||||
|
|
||||||
router.get("/anonymized_repositories", async (req, res) => {
|
router.get("/anonymized_repositories", async (req, res) => {
|
||||||
const repos = await db
|
const repos = await db
|
||||||
.get("anonymized_repositories")
|
.get("anonymized_repositories")
|
||||||
|
|||||||
Reference in New Issue
Block a user