penguin/AstroJS

Javascript framework for my blog

commit 0f7896a9256edbe0bcb92e653fc1aaf16fc50ee9

author斟酌 鵬兄 <tgckpg@gmail.com>
date2015-09-22T18:23:16Z
subjectAdded Section, early plugin model
commit 0f7896a9256edbe0bcb92e653fc1aaf16fc50ee9
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2015-09-22T18:23:16Z

    Added Section, early plugin model
---
 botanjs/src/Astro/Blog/AstroEdit/Article.js        | 21 +++++++---------
 botanjs/src/Astro/Blog/AstroEdit/Flag.js           |  4 ++--
 botanjs/src/Astro/Blog/Components/Section.css      | 28 ++++++++++++++++++++++
 botanjs/src/Astro/Blog/Components/Section.js       |  1 +
 botanjs/src/Astro/Blog/Layout/TwoColumn.css        |  4 ++--
 .../src/externs/Astro.Blog.AstroEdit.IPlugin.js    |  2 +-
 6 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/botanjs/src/Astro/Blog/AstroEdit/Article.js b/botanjs/src/Astro/Blog/AstroEdit/Article.js
index 5cfde04..faeedd0 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/Article.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/Article.js
@@ -58,14 +58,14 @@
 		}
 	};
 
-	PluginBundles.prototype.getSetData = function( pluginId, data )
+	PluginBundles.prototype.getData = function( pluginId, data )
 	{
 		for( var i in this.plugins )
 		{
 			var p = this.plugins[i];
 			if( p.id == pluginId )
 			{
-			   p.getSetData( data );
+			   return p.getData( data );
 			}
 		}
 	};
@@ -121,6 +121,7 @@
 			, title:   set_field_name( Dand.wrap( "input" ), "title" )
 			, content: set_field_name( Dand.wrap( "input" ), "content" )
 			, tags:    set_field_name( Dand.wrap( "input" ), "tags" )
+			, section: set_field_name( Dand.wrap( "input" ), "section" )
 		};
 
 		// Initialize id
@@ -382,11 +383,10 @@
 					, title: _title
 					, content: _content
 					, draft: 1
+					, tags: plugins.getData( "tags" )
+					, section: plugins.getData( "section" )
 				};
 
-				plugins.getSetData( "tags", _data );
-				plugins.getSetData( "section", _data );
-
 				postData( processorSet, _data, saveSuccess, serverFailed );
 			}
 		};
@@ -417,7 +417,8 @@
 				? ArticleModel.date_published
 				: Math.floor( 0.001*( new Date().getTime() ) )
 				;
-			ae_p_fields.tags.value = _ae_tag.getFlags();
+			ae_p_fields.tags.value = plugins.getData( "tags" );
+			ae_p_fields.section.value = plugins.getData( "section" );
 
 			ae_preview.submit();
 		};
@@ -430,11 +431,6 @@
 				_visualizer = _class;
 				_visualizer.setContentDiv( ae_content );
 			}
-			if ( _class instanceof Flag )
-			{
-				_ae_tag = _class;
-				ArticleModel && ArticleModel.tags && ( _ae_tag ).setFlags( ArticleModel.tags );
-			}
 		};
 
 		this.saveAndPublish = function ()
@@ -461,7 +457,8 @@
 
 				_data.title = _title;
 				_data.content = _content;
-				_data.tags = _ae_tag.getFlags();
+				_data.tags = plugins.getData( "tags" );
+				_data.section = plugins.getData( "section" );
 
 				postData( processorSet, _data, publishSuccess.bind({ contentUpdate: true }), serverFailed );
 			}
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Flag.js b/botanjs/src/Astro/Blog/AstroEdit/Flag.js
index 63081ee..87baaf4 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/Flag.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/Flag.js
@@ -153,7 +153,7 @@
 			}
 		}
 
-		this.getSetData = function ( data )
+		this.getData = function ()
 		{
 			// Compile flag list
 			var tlist = [];
@@ -165,7 +165,7 @@
 					tlist[tlist.length] = flags[i].lastChild.nodeValue;
 			}
 
-			data[ this.id ] = tlist.join("\n");
+			return tlist.join("\n");
 		}
 
 		this.setForView = function ( flagList )
diff --git a/botanjs/src/Astro/Blog/Components/Section.css b/botanjs/src/Astro/Blog/Components/Section.css
new file mode 100644
index 0000000..099fbe8
--- /dev/null
+++ b/botanjs/src/Astro/Blog/Components/Section.css
@@ -0,0 +1,28 @@
+.section-buttons > a {
+    display: inline-block;
+    color: white;
+    background-color: darkslategray;
+    padding: 0.75em 0;
+    opacity: 0.5;
+}
+
+.section-buttons > a:hover, .section-buttons > a[active]:hover {
+    opacity: 0.8;
+    text-decoration: none;
+}
+
+.section-buttons > a[data-name="blog"] {
+    background-color: purple;
+}
+.section-buttons > a[data-name="wenku8"] {
+    background-color: royalblue;
+}
+.section-buttons > a > span {
+    padding: 0.75em 0.5em;
+}
+.section-buttons > a[active] {
+    opacity: 1;
+}
+.section-buttons > a > .count {
+    background-color: rgba( 0, 0, 0, 0.3 );
+}
diff --git a/botanjs/src/Astro/Blog/Components/Section.js b/botanjs/src/Astro/Blog/Components/Section.js
new file mode 100644
index 0000000..4d912c2
--- /dev/null
+++ b/botanjs/src/Astro/Blog/Components/Section.js
@@ -0,0 +1 @@
+// __namespace( "Astro.Blog.Components.Section" );
diff --git a/botanjs/src/Astro/Blog/Layout/TwoColumn.css b/botanjs/src/Astro/Blog/Layout/TwoColumn.css
index d8807c9..92d09c7 100644
--- a/botanjs/src/Astro/Blog/Layout/TwoColumn.css
+++ b/botanjs/src/Astro/Blog/Layout/TwoColumn.css
@@ -11,7 +11,7 @@
 .main {
 	/* background-color: #FAFAFA; */
 	vertical-align: top;
-	min-width: 80%;
+	min-width: 70%;
 
 	position: relative;
 }
@@ -29,7 +29,7 @@ ul.breadcrumb > li.sep:after { content: "\2022"; }
 
 .nav_panel {
 	padding-left 0.5em;
-	min-width: 20%;
+	min-width: 30%;
 }
 
 #dockright {
diff --git a/botanjs/src/externs/Astro.Blog.AstroEdit.IPlugin.js b/botanjs/src/externs/Astro.Blog.AstroEdit.IPlugin.js
index 78a1000..bd79bc7 100644
--- a/botanjs/src/externs/Astro.Blog.AstroEdit.IPlugin.js
+++ b/botanjs/src/externs/Astro.Blog.AstroEdit.IPlugin.js
@@ -5,4 +5,4 @@ Astro.Blog.AstroEdit.IPlugin.id;
 /** @type {Function} */
 Astro.Blog.AstroEdit.IPlugin.setFromData;
 /** @type {Function} */
-Astro.Blog.AstroEdit.IPlugin.getSetData;
+Astro.Blog.AstroEdit.IPlugin.getData;