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

index saved in database + search key bold in results

parent 982ea41f
......@@ -19,6 +19,11 @@
database : "mynij-v1.2"
});
this.index_storage = jIO.createJIO({
type : "indexeddb",
database : "mynij-index"
});
this.sub_storages = [];
this.info = jIO.createJIO({
......@@ -31,7 +36,7 @@
.declareMethod ("add_attachment", function (title, rss){
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 (){
var new_sub_storage = {
type : "my_parser",
......@@ -67,6 +72,27 @@
};
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 @@
return gadget.remove_css(rss)
.push(function(rss_without_css){
return storage.add_attachment(title, rss_without_css);
})
.push(function(){
return storage.loaded_doc(title, {"loaded" : "true"});
});
}
});
......
......@@ -6,6 +6,7 @@
<script src="../jio/dist/jio-latest.js"></script>
<script src="../renderjs/dist/renderjs-latest.js"></script>
<script src="gadget_result.js"></script>
<link rel="stylesheet" type="text/css" href="result.css">
</head>
<body>
<ul id="list">
......
......@@ -39,11 +39,15 @@
} else {
return this.cut_description(item.body, key)
.push(function (result){
if (result === null) body.innerHTML = "";
else body.innerHTML = result.slice(1);
var array = [...result.matchAll(key)],
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.appendChild(list_item);
})
});
}
})
......@@ -60,8 +64,10 @@
result;
regEx = new RegExp('[^.?!]*' + ' ' + key + ' ' + '[^.?!]*[.?!]', 'gm');
result = regEx.exec(body);
if (result === null) return null;
else return result[0];
if (result === null) {
return new RegExp('[^.?!]*[.?!]').exec(body)[0];
}
else return result[0].slice(1);
});
}(window, RSVP, rJS, jIO));
\ No newline at end of file
......@@ -3,125 +3,55 @@ body {
margin: 0;
height: 100vh;
width: 100%;
background: #2b2b5d;
background: #fff;
}
form{
position: relative;
top: 5%;
left: 50%;
transform: translate(-50%,-50%);
transition: all 1s;
width: 500px;
height: 50px;
top: 3%;
left: 10%;
width: 86%;
max-width: 50em;
height: 5%;
border: 2px solid #cecece;
background: white;
box-sizing: border-box;
border-radius: 25px;
border: 4px solid white;
padding: 5px;
}
input{
position: absolute;
top: 0;
left: 0;
width: 100%;;
height: 42.5px;
line-height: 30px;
outline: 0;
border: 0;
font-size: 1em;
border-radius: 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;
transition:all 200ms ease-out;
}
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;
}
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: '';
input{
position: absolute;
bottom: -.4em;
left: 50%;
right: 50%;
height: 1px;
background: #2b2b5d;
transition: all ease .2s;
}
a:hover:after {
top: 0;
left: 0;
right: 0;
height: 2px;
width: 100%;;
height: 100%;
line-height: 5%;
outline: 0;
border: 0;
font-size: 1em;
border-radius: 20px;
padding: 0 20px;
}
a:before {
#mynij{
position: absolute;
transform: translateX(-100%);
left: -10px;
color: #2b2b5d;
opacity: .3;
font-weight: 100;
font-size: .8em;
left: 1%;
top: 3%;
font-size: 3em;
font-family: "Roboto", Geneva, "Lucida Console", sans-serif;
font-weight: 500;
color: #485a67;
line-height: 38px;
letter-spacing: -1px;
}
\ No newline at end of file
......@@ -13,9 +13,9 @@
<link rel="stylesheet" type="text/css" href="mynij.css">
</head>
<body>
<div id ="mynij">Mynij</div>
<form id = "search_bar">
<input type="search" required>
<i class="fa fa-search"></i>
</form>
<div data-gadget-url="gadget_result.html"
data-gadget-scope="result"
......
......@@ -9,7 +9,6 @@
to_load: [
"allemandfacile.rss",
"anglaisfacile.rss",
"duolingo.rss",
"espagnolfacile.rss",
"francaisfacile.rss",
"hgeo_college.rss",
......@@ -58,6 +57,7 @@
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.model_gadget.load_index());
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 ?
https://www.francaisfacile.com/ -> https://www.francaisfacile.com/rss.xml
......@@ -30,5 +29,5 @@ https://technologieaucollege27.blogspot.com/ -> https://technologieaucollege27.b
https://www.maths-et-tiques.fr/index.php -> ?
https://www.mathovore.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/
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