Convert to ReasonML
This commit is contained in:
parent
9b7ec52ef6
commit
f9dcdeeef0
11 changed files with 106 additions and 10 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,2 +1,7 @@
|
||||||
*.swp
|
*.swp
|
||||||
popup/config.js
|
static/popup/config.js
|
||||||
|
lib/
|
||||||
|
.merlin
|
||||||
|
node_modules
|
||||||
|
src/*.bs.js
|
||||||
|
src/**/*.bs.js
|
||||||
|
|
17
bsconfig.json
Normal file
17
bsconfig.json
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "fanzine",
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"dir": "src",
|
||||||
|
"subdirs": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"package-specs": [
|
||||||
|
{
|
||||||
|
"module": "es6",
|
||||||
|
"in-source": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"suffix": ".bs.js",
|
||||||
|
"bs-dependencies": []
|
||||||
|
}
|
14
package-lock.json
generated
Normal file
14
package-lock.json
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "fanzine",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"rescript": {
|
||||||
|
"version": "9.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/rescript/-/rescript-9.1.4.tgz",
|
||||||
|
"integrity": "sha512-aXANK4IqecJzdnDpJUsU6pxMViCR5ogAxzuqS0mOr8TloMnzAjJFu63fjD6LCkWrKAhlMkFFzQvVQYaAaVkFXw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
package.json
Normal file
27
package.json
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "fanzine",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "A web extension to publish content on a S3 website",
|
||||||
|
"main": "src/main.bs.js",
|
||||||
|
"type": "module",
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {
|
||||||
|
"rescript": "^9.1.4"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"re:build": "rescript",
|
||||||
|
"re:start": "rescript build -w",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@git.deuxfleurs.fr:quentin/fanzine.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"s3",
|
||||||
|
"garage",
|
||||||
|
"web"
|
||||||
|
],
|
||||||
|
"author": "Quentin Dufour",
|
||||||
|
"license": "AGPL-3.0-or-later"
|
||||||
|
}
|
1
src/main.re
Normal file
1
src/main.re
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Js.log("hello world")
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -91,15 +91,16 @@ hr {
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<section id="home">
|
<section id="home">
|
||||||
<div class="menu-title">Publier sur mon site web</div>
|
<div class="menu-title">Publier sur mon site web</div>
|
||||||
<a class="menu-elem" href="#plain-text">Texte brut</a>
|
<a class="menu-elem" href="#plain-text">Texte brut</a>
|
||||||
<div class="menu-elem">Brève</div>
|
<!--<div class="menu-elem">Brève</div>-->
|
||||||
<div class="menu-elem">Galerie photo</div>
|
<div class="menu-elem">Galerie photo</div>
|
||||||
<div class="menu-elem">Fichiers</div>
|
<div class="menu-elem">Fichiers</div>
|
||||||
<div class="menu-elem">Podcast</div>
|
|
||||||
<hr>
|
<hr>
|
||||||
<div class="menu-elem">Manuellement</div>
|
<div class="menu-elem">Site statique</div>
|
||||||
|
<hr>
|
||||||
<div class="menu-elem">Paramètres</div>
|
<div class="menu-elem">Paramètres</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -113,6 +114,11 @@ hr {
|
||||||
<div id="output">Please wait...</div>
|
<div id="output">Please wait...</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section id="configure">
|
||||||
|
<div class="menu-title">Paramètres</div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
<script src="aws-sdk.js"></script>
|
<script src="aws-sdk.js"></script>
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script src="fanzine.js"></script>
|
<script src="fanzine.js"></script>
|
|
@ -7,11 +7,35 @@ AWS.config.update({
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const s3 = new AWS.S3({
|
/*
|
||||||
apiVersion: "2006-03-01",
|
* ROUTER/CONTROLLER*/
|
||||||
params: { Bucket: bucketName }
|
const state = {}
|
||||||
});
|
const router = state => () => {
|
||||||
|
const index = "home";
|
||||||
|
|
||||||
|
if !(window.location.hash) {
|
||||||
|
window.location.hash = index
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.location.hash == "home") {
|
||||||
|
if (!loadCredentials(state)) {
|
||||||
|
window.location.hash = "configure"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const instance = router(state)
|
||||||
|
window.onhashchange = instance
|
||||||
|
instance()
|
||||||
|
|
||||||
|
/* HELPERS */
|
||||||
|
const loadCredentials = state => {
|
||||||
|
if (state.s3) return
|
||||||
|
|
||||||
|
s3: new AWS.S3({ apiVersion: "2006-03-01" }),
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EVENTS */
|
||||||
document
|
document
|
||||||
.querySelector("#plain-text-send")
|
.querySelector("#plain-text-send")
|
||||||
.addEventListener("click", () => {
|
.addEventListener("click", () => {
|
||||||
|
@ -21,15 +45,17 @@ document
|
||||||
const ib64 = btoa(String.fromCharCode(...identifier));
|
const ib64 = btoa(String.fromCharCode(...identifier));
|
||||||
const path = `paste/${ib64}.txt`;
|
const path = `paste/${ib64}.txt`;
|
||||||
|
|
||||||
|
const text = document.querySelector("#plain-text-content").value
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Key: path,
|
Key: path,
|
||||||
ContentType: 'text/plain',
|
ContentType: 'text/plain',
|
||||||
Body: document.querySelector("#plain-text-content").value
|
Body: text
|
||||||
};
|
};
|
||||||
|
|
||||||
// Uploading files to the bucket
|
// Uploading files to the bucket
|
||||||
s3.upload(params, function(err, data) {
|
state.s3.upload(params, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
Loading…
Reference in a new issue