Commit 342dcb09 authored by Alexandra Rogova's avatar Alexandra Rogova

index saved in database + search key bold in results

parent 982ea41f
...@@ -18,8 +18,13 @@ ...@@ -18,8 +18,13 @@
type : "indexeddb", type : "indexeddb",
database : "mynij-v1.2" database : "mynij-v1.2"
}); });
this.index_storage = jIO.createJIO({
type : "indexeddb",
database : "mynij-index"
});
this.sub_storages = []; this.sub_storages = [];
this.info = jIO.createJIO({ this.info = jIO.createJIO({
type : "indexeddb", type : "indexeddb",
...@@ -31,7 +36,7 @@ ...@@ -31,7 +36,7 @@
.declareMethod ("add_attachment", function (title, rss){ .declareMethod ("add_attachment", function (title, rss){
var gadget = this, sub_id; var gadget = this, sub_id;
return this.feeds.putAttachment("feeds_doc", title, new Blob([rss], {type : "text/xml"})) return gadget.feeds.putAttachment("feeds_doc", title, new Blob([rss], {type : "text/xml"}))
.push(function (){ .push(function (){
var new_sub_storage = { var new_sub_storage = {
type : "my_parser", type : "my_parser",
...@@ -67,6 +72,27 @@ ...@@ -67,6 +72,27 @@
}; };
gadget.index.addDoc(doc); gadget.index.addDoc(doc);
} }
return gadget.index_storage.put("index", {index : JSON.stringify(gadget.index)});
});
})
.declareMethod("load_index", function(){
var raw_index,
gadget = this;
return gadget.index_storage.get("index")
.push(function(result){
var key,
doc;
raw_index = JSON.parse(result.index);
for (key in raw_index.documentStore.docs){
doc = {
"id" : raw_index.documentStore.docs[key].id,
"title" : raw_index.documentStore.docs[key].title,
"body" : raw_index.documentStore.docs[key].body,
"link" : raw_index.documentStore.docs[key].link
};
gadget.index.addDoc(doc);
}
}); });
}) })
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
return gadget.remove_css(rss) return gadget.remove_css(rss)
.push(function(rss_without_css){ .push(function(rss_without_css){
return storage.add_attachment(title, rss_without_css); return storage.add_attachment(title, rss_without_css);
})
.push(function(){
return storage.loaded_doc(title, {"loaded" : "true"});
}); });
} }
}); });
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<script src="../jio/dist/jio-latest.js"></script> <script src="../jio/dist/jio-latest.js"></script>
<script src="../renderjs/dist/renderjs-latest.js"></script> <script src="../renderjs/dist/renderjs-latest.js"></script>
<script src="gadget_result.js"></script> <script src="gadget_result.js"></script>
<link rel="stylesheet" type="text/css" href="result.css">
</head> </head>
<body> <body>
<ul id="list"> <ul id="list">
......
...@@ -39,11 +39,15 @@ ...@@ -39,11 +39,15 @@
} else { } else {
return this.cut_description(item.body, key) return this.cut_description(item.body, key)
.push(function (result){ .push(function (result){
if (result === null) body.innerHTML = ""; var array = [...result.matchAll(key)],
else body.innerHTML = result.slice(1); i;
for (i=0; i<array.length; i+=1){
result = result.slice(0, array[i].index) + "<b>" + result.slice(array[i].index, array[i].index+array[i][0].length+1) + "</b>" + result.slice(array[i].index+array[i][0].length+1);
}
body.innerHTML = result;
list_item.appendChild(body); list_item.appendChild(body);
list.appendChild(list_item); list.appendChild(list_item);
}) });
} }
}) })
...@@ -60,8 +64,10 @@ ...@@ -60,8 +64,10 @@
result; result;
regEx = new RegExp('[^.?!]*' + ' ' + key + ' ' + '[^.?!]*[.?!]', 'gm'); regEx = new RegExp('[^.?!]*' + ' ' + key + ' ' + '[^.?!]*[.?!]', 'gm');
result = regEx.exec(body); result = regEx.exec(body);
if (result === null) return null; if (result === null) {
else return result[0]; return new RegExp('[^.?!]*[.?!]').exec(body)[0];
}
else return result[0].slice(1);
}); });
}(window, RSVP, rJS, jIO)); }(window, RSVP, rJS, jIO));
\ No newline at end of file
...@@ -3,22 +3,31 @@ body { ...@@ -3,22 +3,31 @@ body {
margin: 0; margin: 0;
height: 100vh; height: 100vh;
width: 100%; width: 100%;
background: #2b2b5d; background: #fff;
} }
form{ form{
position: relative; position: relative;
top: 5%; top: 3%;
left: 50%; left: 10%;
transform: translate(-50%,-50%); width: 86%;
transition: all 1s; max-width: 50em;
width: 500px; height: 5%;
height: 50px; border: 2px solid #cecece;
background: white; background: white;
box-sizing: border-box; box-sizing: border-box;
border-radius: 25px; border-radius: 25px;
border: 4px solid white; transition:all 200ms ease-out;
padding: 5px; }
form:hover{
cursor: pointer;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
transition:all 200ms ease-out;
}
form:hover input{
display: block;
} }
input{ input{
...@@ -26,102 +35,23 @@ input{ ...@@ -26,102 +35,23 @@ input{
top: 0; top: 0;
left: 0; left: 0;
width: 100%;; width: 100%;;
height: 42.5px; height: 100%;
line-height: 30px; line-height: 5%;
outline: 0; outline: 0;
border: 0; border: 0;
font-size: 1em; font-size: 1em;
border-radius: 20px; border-radius: 20px;
padding: 0 20px; padding: 0 20px;
text-align: center;
}
.fa{
box-sizing: border-box;
padding: 10px;
width: 42.5px;
height: 42.5px;
position: absolute;
top: 0;
right: 0;
border-radius: 50%;
color: #07051a;
text-align: center;
font-size: 1.2em;
transition: all 1s;
background: #2b2b5d;
}
form:hover{
cursor: pointer;
} }
form:hover input{ #mynij{
display: block;
}
ul, il{
margin : 0;
}
li {
list-style-type: none;
position: relative;
font-size: large;
padding: 2% 0;
margin: auto;
margin-top: 3%;
margin-bottom: 2%;
background: #fff;
color: #2b2b5d;
width: 40%;
box-shadow: 10px 20px #1e1e44;
}
.title {
margin-left : 5%;
color: #2b2b5d;
text-decoration: none;
font-size: x-large;
}
.link, .link:visited {
margin-left : 5%;
text-decoration: none;
color: #5c7ece;
}
.body{
margin-left : 5%;
}
a {
position: relative;
}
a:after {
content: '';
position: absolute;
bottom: -.4em;
left: 50%;
right: 50%;
height: 1px;
background: #2b2b5d;
transition: all ease .2s;
}
a:hover:after {
left: 0;
right: 0;
height: 2px;
}
a:before {
position: absolute; position: absolute;
transform: translateX(-100%); left: 1%;
left: -10px; top: 3%;
color: #2b2b5d; font-size: 3em;
opacity: .3; font-family: "Roboto", Geneva, "Lucida Console", sans-serif;
font-weight: 100; font-weight: 500;
font-size: .8em; color: #485a67;
} line-height: 38px;
letter-spacing: -1px;
}
\ No newline at end of file
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
<link rel="stylesheet" type="text/css" href="mynij.css"> <link rel="stylesheet" type="text/css" href="mynij.css">
</head> </head>
<body> <body>
<div id ="mynij">Mynij</div>
<form id = "search_bar"> <form id = "search_bar">
<input type="search" required> <input type="search" required>
<i class="fa fa-search"></i>
</form> </form>
<div data-gadget-url="gadget_result.html" <div data-gadget-url="gadget_result.html"
data-gadget-scope="result" data-gadget-scope="result"
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
to_load: [ to_load: [
"allemandfacile.rss", "allemandfacile.rss",
"anglaisfacile.rss", "anglaisfacile.rss",
"duolingo.rss",
"espagnolfacile.rss", "espagnolfacile.rss",
"francaisfacile.rss", "francaisfacile.rss",
"hgeo_college.rss", "hgeo_college.rss",
...@@ -58,6 +57,7 @@ ...@@ -58,6 +57,7 @@
for (i = 0; i < gadget.state.to_load.length; i++){ for (i = 0; i < gadget.state.to_load.length; i++){
promise_list.push(gadget.state.parser_gadget.read_file_new("./test-files/" + gadget.state.to_load[i])); promise_list.push(gadget.state.parser_gadget.read_file_new("./test-files/" + gadget.state.to_load[i]));
} }
promise_list.push(gadget.state.model_gadget.load_index());
RSVP.all(promise_list); RSVP.all(promise_list);
}) })
......
This source diff could not be displayed because it is too large. You can view the blob instead.
X = a parser
? = RSS pas applicable ? ? = RSS pas applicable ?
https://www.francaisfacile.com/ -> https://www.francaisfacile.com/rss.xml https://www.francaisfacile.com/ -> https://www.francaisfacile.com/rss.xml
...@@ -30,5 +29,5 @@ https://technologieaucollege27.blogspot.com/ -> https://technologieaucollege27.b ...@@ -30,5 +29,5 @@ https://technologieaucollege27.blogspot.com/ -> https://technologieaucollege27.b
https://www.maths-et-tiques.fr/index.php -> ? https://www.maths-et-tiques.fr/index.php -> ?
https://www.mathovore.fr/ -> ? https://www.mathovore.fr/ -> ?
https://www.logicieleducatif.fr/ -> ? https://www.logicieleducatif.fr/ -> ?
https://www.duolingo.com/ -> https://making.duolingo.com/feeds/all.atom.xml https://www.duolingo.com/ -> ?
https://lewebpedagogique.com/lapasserelle/ -> https://lewebpedagogique.com/lapasserelle/feed/ https://lewebpedagogique.com/lapasserelle/ -> https://lewebpedagogique.com/lapasserelle/feed/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment