tobychui 4 жил өмнө
parent
commit
01b83d7b31

+ 26 - 0
web/Blog/backend/config.js

@@ -0,0 +1,26 @@
+/*
+    Config.js
+
+    This script handle the save and restore of the 
+    1) Blog post source
+    2) Blog post release (Merged with template)
+*/
+
+//Create the blog table if not exists
+newDBTableIfNotExists("blog");
+
+function getBlogPostStore(){
+    return readDBItem("blog", "post-store");
+}
+
+function setBlogPostStore(newpath){
+    return writeDBItem("blog", "post-store", newpath);
+}
+
+function getBlogReleasePath(){
+    return readDBItem("blog", "post-release");
+}
+
+function setBlogReleasePath(newpath){
+    return writeDBItem("blog", "post-release", newpath);
+}

+ 38 - 0
web/Blog/backend/listPosts.js

@@ -0,0 +1,38 @@
+/*
+    ListPost.js
+    Author: tobychui
+
+    This script list all the post within the system
+
+*/
+
+//Require the file library
+requirelib("filelib");
+
+//Require the internal library for handling the path of blog posting
+includes("config.js");
+
+var blogPostStorage = getBlogPostStore();
+function main(){
+    //Create a directory in user:/Document/ for storing Blog stuffs
+    if (blogPostStorage == ""){
+        //The blog post storage is not set. Use default
+        blogPostStorage = "user:/Document/Blog/Posts/";
+    }
+
+    //Filter out the last / if exists
+    if (blogPostStorage.substr(blogPostStorage.length - 1, 1) == "/"){
+        blogPostStorage = blogPostStorage.substr(0, blogPostStorage.length - 1);
+    }
+
+    //If it doesn't exists
+    filelib.mkdir(blogPostStorage);	
+
+    //List all the created post
+    var allPosts = filelib.aglob(blogPostStorage + "/*.json");
+
+    //Return the value of the posts
+    sendJSONResp(JSON.stringify(allPosts));
+}
+
+main();

BIN
web/Blog/img/desktop_icon.png


BIN
web/Blog/img/desktop_icon.psd


BIN
web/Blog/img/module_icon.png


BIN
web/Blog/img/module_icon.psd


BIN
web/Blog/img/pwa/128.png


BIN
web/Blog/img/pwa/192.png


BIN
web/Blog/img/pwa/256.png


BIN
web/Blog/img/pwa/512.png


BIN
web/Blog/img/small_icon.png


BIN
web/Blog/img/small_icon.psd


+ 75 - 0
web/Blog/index.html

@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<meta charset="UTF-8">
+		<meta name="apple-mobile-web-app-capable" content="yes" />
+		<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
+		<meta name="theme-color" content="#ff9224">
+		<link rel="stylesheet" href="../script/tocas/tocas.css">
+		<script src="../script/tocas/tocas.js"></script>
+		<script src="../script/jquery.min.js"></script>
+		<script src="../script/ao_module.js"></script>
+
+		<link rel="manifest" crossorigin="use-credentials" href="manifest.json">
+		<title>Blog</title>
+		<style>
+			body{
+				background-color: white;
+			}
+			.postControls{
+				position: absolute;
+				top: 0.5em;
+				right: 0.5em;
+			}
+		</style>
+	</head>
+	<body>
+		<br><br>
+		<div class="ts container">
+			<div>
+				<h4><img class="ts mini spaced image" src="img/module_icon.png" style="margin-right: 12px;">  Blog Writer</h4>
+			</div>
+			<div class="ts divider"></div>
+			<div class="ts stackable grid">
+				<!-- Post container-->
+				<div class="twelve wide column">
+					<div class="ts segment post">
+						<div class="ts header">
+							Awesome Blog Title
+							<div class="sub header"><i class="tag icon"></i> tag1, tag2, tag3, tag4</div>
+						</div>
+						<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eu libero quis orci ornare scelerisque at vitae tortor. Duis at mauris purus. Donec pharetra orci hendrerit dui auctor facilisis. Praesent et nunc elementum, posuere diam in, varius velit. Integer ac ante blandit lacus ultrices elementum. Fusce sed viverra arcu. Cras laoreet neque turpis, in porta mi ornare vel. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse vitae aliquet libero. Donec risus enim, iaculis quis ornare vel, ornare a dolor. Maecenas a iaculis diam. Integer eget tellus scelerisque, finibus felis nec, mollis sem. Donec euismod turpis elit, quis volutpat nisl imperdiet at. </p>
+						<p><a>Show More</a></p>
+		
+						<div class="postControls">
+							<button class="ts mini icon button"><i class="edit icon"></i></button>
+						</div>
+					</div>
+				</div>
+				<!-- Setting container-->
+				<div class="four wide column">
+					<div class="ts segment">
+						
+					</div>
+				</div>
+			</div>
+			
+		</div>
+		<script>
+			//List all the post stored in the system
+			listPost();
+
+			function listPost(){
+				ao_module_agirun("Blog/backend/listPosts.js", {}, function(data){
+					if (data.length == 0){
+						//There is no post in the system
+
+					}else{
+						//Render the post
+
+					}
+				})
+			}
+		</script>
+	</body>
+</html>

+ 24 - 0
web/Blog/init.agi

@@ -0,0 +1,24 @@
+/*
+	Blog Engine initiation script
+*/
+
+//Setup the module information
+var moduleLaunchInfo = {
+    Name: "Blog",
+	Desc: "The blog engine that power the ArozOS Blog",
+	Group: "Media",
+	IconPath: "Blog/img/module_icon.png",
+	Version: "0.1.0",
+	StartDir: "Blog/index.html",
+	SupportFW: true,
+	LaunchFWDir: "Blog/index.html",
+	SupportEmb: true,
+	LaunchEmb: "Blog/embedded.html",
+	InitFWSize: [1080, 580],
+	InitEmbSize: [360, 240],
+	SupportedExt: [".md",".txt"]
+}
+
+
+//Register the module
+registerModule(JSON.stringify(moduleLaunchInfo));

+ 26 - 0
web/Blog/manifest.json

@@ -0,0 +1,26 @@
+{
+  "name": "Blog",
+  "short_name": "Blog",
+  "icons": [{
+    "src": "img/pwa/128.png",
+      "sizes": "128x128",
+      "type": "image/png"
+    },{
+      "src": "img/pwa/192.png",
+      "sizes": "192x192",
+      "type": "image/png"
+    }, {
+      "src": "img/pwa/256.png",
+      "sizes": "256x256",
+      "type": "image/png"
+    }, {
+      "src": "img/pwa/512.png",
+      "sizes": "512x512",
+      "type": "image/png"
+    }],
+  "start_url": "index.html",
+  "display": "fullscreen",
+  "scope": "./",
+  "background_color": "#e6e6e6",
+  "theme_color": "#e6e6e6"
+}

+ 1 - 1
web/Music/init.agi

@@ -1,5 +1,5 @@
 /*
-	Video Module Register Script
+	Music Module Register Script
 */
 
 //Setup the module information

+ 2 - 2
web/Notebook/init.agi

@@ -13,8 +13,8 @@ var moduleLaunchInfo = {
 	Desc: "Basic Text Editor",
 	Group: "Utilities",
 	IconPath: "Notebook/img/notebook.png",
-	Version: "2.0",
-	StartDir: "",
+	Version: "3.0",
+	StartDir: "Notebook/notebook.html",
 	SupportFW: true,
 	LaunchFWDir: "Notebook/notebook.html",
 	SupportEmb: false,

+ 19 - 0
web/Notebook/notebook.html

@@ -100,8 +100,27 @@
             }else{
                 simplemde = new SimpleMDE({ element: document.getElementById("maintext") });
             }
+
+            function handleNewFileSave(filedata){
+                for (var i=0; i < filedata.length; i++){
+                    var thisFilename = filedata[i].filename;
+                    var thisFilepath = filedata[i].filepath;
+                    
+                    //Update the current editing filepath
+                    filepath = thisFilepath;
+                }
+
+                saveText();
+            }
           
             function saveText(callback=undefined){
+                if (filepath == ""){
+                    //This is a new file. Ask for save directory.
+                    ao_module_openFileSelector(handleNewFileSave, "user:/Desktop", "new",false, {
+                        defaultName: "Untitled.txt"
+                    });
+                    return;
+                }
                 var newcontent = simplemde.value();
                 ao_module_agirun("Notebook/filesaver.js", {
                     filepath: filepath,