Commit 8f806624 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

fwi: use index_list gadget for blog post

parent 4bdd7671
...@@ -9,13 +9,8 @@ ...@@ -9,13 +9,8 @@
<script src="../../dist/renderjs-latest.js" type="text/javascript"></script> <script src="../../dist/renderjs-latest.js" type="text/javascript"></script>
<script src="blog.js" type="text/javascript"></script> <script src="blog.js" type="text/javascript"></script>
</head> </head>
<header><h1 style="text-align:center;">Free Web Initiative</h1></header>
<body style="background-color: white; color: black;"> <body style="background-color: white; color: black;">
<div class="sidebar" id="index"></div> <div id="post-content"></div>
<div class="main-container">
<div class="main wrapper clearfix">
<div id="content"></div>
</div>
</div> </div>
</body> </body>
</html> </html>
......
...@@ -6,41 +6,10 @@ ...@@ -6,41 +6,10 @@
*/ */
var gk = rJS(window); var gk = rJS(window);
var loadAndDisplayIndexView = function () {
var i, length, rows, row, page_list_html = "<ul>";
rows = this.page_list.data.rows;
length = rows.length;
for (i = 0; i < length; i += 1) {
page_list_html += "<li><a href=\"#" + rows[i].doc.title.replace(/"/g, "\\\"") +
"\">" + rows[i].doc.title + "</a></li>";
}
page_list_html += "</ul>";
place.index.dom.innerHTML = page_list_html;
};
var loadAndDisplayContentPage = function (value) {
var i; //,
//rows = this.page_list.data.rows,
//length = rows.length;
//for (i = 0; i < length; i += 1) {
//if (rows[i].doc.title === page_title) {
// // show page
$("#content").empty().append(value);
//place.content.dom.innerHTML = rows[i].doc.text_content;
// return;
// }
//}
//place.content.dom.innerHTML = "<p>404</p>";
};
/* Initialize Page List */ /* Initialize Page List */
gk.declareMethod('setPageList', function (page_list) { gk.declareMethod('setContent', function (value) {
this.page_list = page_list;
});
gk.declareMethod('displayHTML', function (value) {
this.value = value; this.value = value;
loadAndDisplayContentPage(value); $("#post-content").empty().append(value.text_content);
}); });
/** /**
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
function attachIOToBlog(all_param) { function attachIOToBlog(all_param) {
var blog = all_param[0], var blog = all_param[0],
io = all_param[1], io = all_param[1],
id = all_param[2], index = all_param[2],
jio_config = { jio_config = {
"type": "dropbox", "type": "dropbox",
"access_token": "v43SQLCEoi8AAAAAAAAAAVixCoMfDelgGj3NRPfEnqscAuNGp2LhoS8-GiAaDD4C" "access_token": "v43SQLCEoi8AAAAAAAAAAVixCoMfDelgGj3NRPfEnqscAuNGp2LhoS8-GiAaDD4C"
...@@ -48,15 +48,21 @@ ...@@ -48,15 +48,21 @@
$(blog.element).trigger('create'); $(blog.element).trigger('create');
return io.configureIO(jio_config) return io.configureIO(jio_config)
.then(function () { .then(function () {
return io.getIO('48c3ca06-78b9-2f4c-80db-d5cb2417de45').fail(function (error) { return io.getIOList().fail(function (error) {
if (error.status === 404) { if (error.status === 404) {
return ""; return "";
} }
throw error; throw error;
}); });
}) })
.then(function (document) { .then(function (document_list) {
return blog.displayHTML(document.text_content); return RSVP.all([
blog.setContent(document_list[0].doc),
index.setDocumentList(
document_list,
blog, blog.setContent,
io, io.getIO)
]);
}); });
} }
...@@ -96,19 +102,21 @@ ...@@ -96,19 +102,21 @@
}; };
} }
function createLoadNewBlogCallback(g, blog_path, e_c, io_path, i_c) { function createLoadNewBlogCallback(g, blog_path, e_c, io_path, i_c, index_path, index_c) {
return function () { return function () {
e_c.empty(); e_c.empty();
i_c.empty(); i_c.empty();
$('.sidebar').empty(); $('.sidebar').empty();
return RSVP.all([ return RSVP.all([
g.declareGadget(blog_path, {element: e_c[0], sandbox: 'iframe'}), g.declareGadget(blog_path),
g.declareGadget(io_path), g.declareGadget(io_path),
"officejs" g.declareGadget(index_path)
]) ])
.then(function (all_param) { .then(function (all_param) {
e_c[0].appendChild(all_param[0].element);
index_c[0].appendChild(all_param[2].element);
return attachIOToBlog(all_param); return attachIOToBlog(all_param);
}) })
.fail(handleError); .fail(handleError);
}; };
} }
...@@ -156,14 +164,13 @@ ...@@ -156,14 +164,13 @@
i; i;
// Load 1 editor and 1 IO and plug them // Load 1 editor and 1 IO and plug them
return RSVP.all([ return RSVP.all([
g.declareGadget( g.declareGadget(blog_list[0].path),
blog_list[0].path, g.declareGadget(io_list[0].path),
{element: blog_a_context[0], sandbox: 'iframe'} g.declareGadget(index_definition)
),
g.declareGadget(io_list[0].path),// io_a_context),
"officejs"
]) ])
.then(function (all_param) { .then(function (all_param) {
blog_a_context[0].appendChild(all_param[0].element);
index_a_context[0].appendChild(all_param[2].element);
io_blog_a_context.empty(); io_blog_a_context.empty();
return attachIOToBlog(all_param); return attachIOToBlog(all_param);
}) })
...@@ -176,8 +183,12 @@ ...@@ -176,8 +183,12 @@
'data-iconpos="left">' + blog_definition.title + '</a>' 'data-iconpos="left">' + blog_definition.title + '</a>'
); );
panel_context.find('a').last().click( panel_context.find('a').last().click(
createLoadNewBlogCallback(g, blog_definition.path, createLoadNewBlogCallback(
blog_a_context, io_list[0].path, io_blog_a_context) g,
blog_definition.path, blog_a_context,
io_list[0].path, io_blog_a_context,
index_definition, index_a_context
)
); );
} }
for (i = 0; i < editor_list.length; i += 1) { for (i = 0; i < editor_list.length; i += 1) {
......
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