notebook view and preferences window

James Peret 8 years ago
parent
commit
3c3323ce3f

+ 1 - 3
.gitignore

@@ -5,6 +5,4 @@ node_modules
5 5
 
6 6
 */.DS_Store
7 7
 
8
-codex/Research/*
9
-codex/Inbox/*
10
-codex/*.thumb.png
8
+codex/*

+ 38 - 12
app.js

@@ -1,22 +1,13 @@
1 1
 var app = require('app');  // Module to control application life.
2 2
 var BrowserWindow = require('browser-window');  // Module to create native browser window.
3
+var ipc = require('ipc');
3 4
 
4 5
 // Keep a global reference of the window object, if you don't, the window will
5 6
 // be closed automatically when the JavaScript object is garbage collected.
6 7
 var mainWindow = null;
8
+var preferencesWindow = null;
7 9
 
8
-// Quit when all windows are closed.
9
-app.on('window-all-closed', function() {
10
-  // On OS X it is common for applications and their menu bar
11
-  // to stay active until the user quits explicitly with Cmd + Q
12
-  if (process.platform != 'darwin') {
13
-    app.quit();
14
-  }
15
-});
16
-
17
-// This method will be called when Electron has finished
18
-// initialization and is ready to create browser windows.
19
-app.on('ready', function() {
10
+var createMainWindow = function() {
20 11
   // Create the browser window.
21 12
   mainWindow = new BrowserWindow({
22 13
     width: 1030,
@@ -41,4 +32,39 @@ app.on('ready', function() {
41 32
     // when you should delete the corresponding element.
42 33
     mainWindow = null;
43 34
   });
35
+}
36
+
37
+var createPreferencesWindow = function() {
38
+  if(preferencesWindow === null){
39
+    preferencesWindow = new BrowserWindow({
40
+      width: 500,
41
+      height: 300,
42
+      show: true,
43
+      'title-bar-style': 'hidden',
44
+      'fullscreen' : false
45
+    });
46
+    preferencesWindow.loadUrl('file://' + __dirname + '/app/preferences-window.html');
47
+    preferencesWindow.on('closed', function() {
48
+      preferencesWindow = null;
49
+    });
50
+  }
51
+}
52
+
53
+// Quit when all windows are closed.
54
+app.on('window-all-closed', function() {
55
+  // On OS X it is common for applications and their menu bar
56
+  // to stay active until the user quits explicitly with Cmd + Q
57
+  if (process.platform != 'darwin') {
58
+    app.quit();
59
+  }
60
+});
61
+
62
+// This method will be called when Electron has finished
63
+// initialization and is ready to create browser windows.
64
+app.on('ready', function() {
65
+  createMainWindow();
66
+  //createPreferencesWindow();
67
+  ipc.on('show-preferences-window', function() {
68
+      createPreferencesWindow();
69
+  });
44 70
 });

BIN
app/content/imgs/prefs-icon.png


+ 140 - 3
app/index.html

@@ -32,8 +32,145 @@
32 32
     <script src="scripts/services/date-formatter.js" charset="utf-8"></script>
33 33
 
34 34
     <script>
35
-     var remote = require('remote');
36
-     var dialog = remote.require('dialog');
35
+      var remote = require('remote');
36
+      var ipc = require('ipc');
37
+      var dialog = remote.require('dialog');
38
+      var Menu = remote.require('menu');
39
+      var template = [
40
+        {
41
+          label: 'Codex',
42
+          submenu: [
43
+            {
44
+              label: 'About Codex',
45
+              selector: 'orderFrontStandardAboutPanel:'
46
+            },
47
+            {
48
+              type: 'separator'
49
+            },
50
+            {
51
+              label: 'Preferences',
52
+              click: function () {
53
+                ipc.send('show-preferences-window')
54
+              }
55
+            },
56
+            {
57
+              type: 'separator'
58
+            },
59
+            {
60
+              label: 'Services',
61
+              submenu: []
62
+            },
63
+            {
64
+              type: 'separator'
65
+            },
66
+            {
67
+              label: 'Hide Codex',
68
+              accelerator: 'Command+H',
69
+              selector: 'hide:'
70
+            },
71
+            {
72
+              label: 'Hide Others',
73
+              accelerator: 'Command+Shift+H',
74
+              selector: 'hideOtherApplications:'
75
+            },
76
+            {
77
+              label: 'Show All',
78
+              selector: 'unhideAllApplications:'
79
+            },
80
+            {
81
+              type: 'separator'
82
+            },
83
+            {
84
+              label: 'Quit',
85
+              accelerator: 'Command+Q',
86
+              selector: 'terminate:'
87
+            },
88
+          ]
89
+        },
90
+        {
91
+          label: 'Edit',
92
+          submenu: [
93
+            {
94
+              label: 'Undo',
95
+              accelerator: 'Command+Z',
96
+              selector: 'undo:'
97
+            },
98
+            {
99
+              label: 'Redo',
100
+              accelerator: 'Shift+Command+Z',
101
+              selector: 'redo:'
102
+            },
103
+            {
104
+              type: 'separator'
105
+            },
106
+            {
107
+              label: 'Cut',
108
+              accelerator: 'Command+X',
109
+              selector: 'cut:'
110
+            },
111
+            {
112
+              label: 'Copy',
113
+              accelerator: 'Command+C',
114
+              selector: 'copy:'
115
+            },
116
+            {
117
+              label: 'Paste',
118
+              accelerator: 'Command+V',
119
+              selector: 'paste:'
120
+            },
121
+            {
122
+              label: 'Select All',
123
+              accelerator: 'Command+A',
124
+              selector: 'selectAll:'
125
+            }
126
+          ]
127
+        },
128
+        {
129
+          label: 'View',
130
+          submenu: [
131
+            {
132
+              label: 'Reload',
133
+              accelerator: 'Command+R',
134
+              click: function() { remote.getCurrentWindow().reload(); }
135
+            },
136
+            {
137
+              label: 'Toggle DevTools',
138
+              accelerator: 'Alt+Command+I',
139
+              click: function() { remote.getCurrentWindow().toggleDevTools(); }
140
+            },
141
+          ]
142
+        },
143
+        {
144
+          label: 'Window',
145
+          submenu: [
146
+            {
147
+              label: 'Minimize',
148
+              accelerator: 'Command+M',
149
+              selector: 'performMiniaturize:'
150
+            },
151
+            {
152
+              label: 'Close',
153
+              accelerator: 'Command+W',
154
+              selector: 'performClose:'
155
+            },
156
+            {
157
+              type: 'separator'
158
+            },
159
+            {
160
+              label: 'Bring All to Front',
161
+              selector: 'arrangeInFront:'
162
+            }
163
+          ]
164
+        },
165
+        {
166
+          label: 'Help',
167
+          submenu: []
168
+        }
169
+      ];
170
+
171
+      menu = Menu.buildFromTemplate(template);
172
+
173
+      Menu.setApplicationMenu(menu);
37 174
     </script>
38 175
   </head>
39 176
 
@@ -90,7 +227,7 @@
90 227
                 <span class="icon icon-archive"></span>
91 228
                 All Files
92 229
               </span>
93
-              <span class="nav-group-item">
230
+              <span class="nav-group-item" ng-class="sidebar[2].active" ng-click="goToNotebooks()">
94 231
                 <span class="icon icon-book"></span>
95 232
                 Notebooks
96 233
               </span>

+ 29 - 0
app/preferences-window.html

@@ -0,0 +1,29 @@
1
+<!DOCTYPE html>
2
+<html  class="no-js">
3
+
4
+  <head>
5
+    <title>Codex</title>
6
+    <meta charset="UTF-8">
7
+    <!-- Stylesheets -->
8
+    <link rel="stylesheet" href="../css/tomorrow-night-eighties.css">
9
+    <link rel="stylesheet" href="../css/photon.min.css">
10
+    <link rel="stylesheet" href="../css/codex.css">
11
+
12
+    <script>
13
+      var remote = require('remote');
14
+      var ipc = require('ipc');
15
+      var dialog = remote.require('dialog');
16
+    </script>
17
+  </head>
18
+
19
+  <body>
20
+    <header class="toolbar toolbar-header">
21
+      <h1 class="title">Preferences</h1>
22
+
23
+      <div class="toolbar-actions">
24
+        <img src="content/imgs/prefs-icon.png" style="width: 32px; height: 32px;">
25
+      </div>
26
+    </header>
27
+
28
+  </body>
29
+</html>

+ 2 - 0
app/scripts/controllers/app-ctrl.js

@@ -19,6 +19,8 @@ angular.module('codexApp.index', [])
19 19
         case "All Files":
20 20
           $scope.files = FileService.getAllFiles();
21 21
           break;
22
+        case "Notebooks":
23
+          $scope.files = FileService.getFolders();
22 24
       }
23 25
     }
24 26
 

+ 17 - 0
app/scripts/controllers/sidebar-ctrl.js

@@ -30,6 +30,18 @@ angular.module('codexApp.sidebar', [])
30 30
       $state.go("index");
31 31
     }
32 32
 
33
+    $scope.goToNotebooks = function() {
34
+      PrefsService.setCurrentView("Notebooks");
35
+      $scope.activateSidebarBtn(2);
36
+      $rootScope.$broadcast('main-window:file-list');
37
+      $rootScope.$broadcast('window-view:change');
38
+      $state.go("index");
39
+    }
40
+
41
+    $rootScope.$on('main-window:note-view', function(){
42
+      $scope.activateSidebarBtn();
43
+    });
44
+
33 45
     $rootScope.$on('sidebar:toogle', function() {
34 46
       if(!$scope.$$phase) {
35 47
         $scope.$apply(function(){
@@ -56,6 +68,10 @@ angular.module('codexApp.sidebar', [])
56 68
       {
57 69
         "view" : "All Files",
58 70
         "active" : ""
71
+      },
72
+      {
73
+        "view" : "Notebooks",
74
+        "active" : ""
59 75
       }
60 76
     ]
61 77
 
@@ -71,6 +87,7 @@ angular.module('codexApp.sidebar', [])
71 87
         for (var i = 0; i < $scope.sidebar.length; i++) {
72 88
           $scope.sidebar[i].active = "";
73 89
         }
90
+        if (typeof(num)==='undefined') return;
74 91
         $scope.sidebar[num].active = "active";
75 92
       }
76 93
     }

+ 21 - 5
app/scripts/services/file-service.js

@@ -284,19 +284,35 @@ angular.module('codexApp')
284 284
     return absoluteToRelativeURL(current_url, absolute_url);
285 285
   }
286 286
 
287
+  // Get folders
288
+
289
+  var getFolders = function(root) {
290
+    if (typeof(root)==='undefined') root = notes_dir;
291
+    var filesystem = require("fs");
292
+    var results = [];
293
+    filesystem.readdirSync(root).forEach(function(file) {
294
+        file_path = root+'/'+file;
295
+        var stat = filesystem.statSync(file_path);
296
+        if (stat && stat.isDirectory()) {
297
+          results.push(SetFileInfo( undefined, root, file_path, stat));
298
+        }
299
+    });
300
+    console.log(results);
301
+    return results;
302
+  }
303
+
304
+  this.getFolders = function(root){
305
+    return getFolders(root);
306
+  }
307
+
287 308
   // Sort files
288 309
   var date_sort_asc = function (date1, date2) {
289
-    // This is a comparison function that will result in dates being sorted in
290
-    // ASCENDING order. As you can see, JavaScript's native comparison operators
291
-    // can be used to compare dates. This was news to me.
292 310
     if (date1.modified_at > date2.modified_at) return 1;
293 311
     if (date1.modified_at < date2.modified_at) return -1;
294 312
     return 0;
295 313
   };
296 314
 
297 315
   var date_sort_desc = function (date1, date2) {
298
-    // This is a comparison function that will result in dates being sorted in
299
-    // DESCENDING order.
300 316
     if (date1.modified_at > date2.modified_at) return -1;
301 317
     if (date1.modified_at < date2.modified_at) return 1;
302 318
     return 0;

+ 1 - 1
app/scripts/services/prefs-service.js

@@ -1,7 +1,7 @@
1 1
 angular.module('codexApp')
2 2
 .service('PrefsService', [ '$rootScope', '$http',  function($rootScope, $http) {
3 3
 
4
-  var views = ["All Notes", "All Files"];
4
+  var views = ["All Notes", "All Files", "Notebooks"];
5 5
   var current_view = "All Notes"
6 6
 
7 7
   this.getCurrentView = function() {

+ 5 - 2
codex/dev/codex-app/todos.md

@@ -13,7 +13,7 @@
13 13
 * [X] Syntax Highlight
14 14
 * [X] File Sorting Asc
15 15
 * [ ] Image View
16
-* [ ] All Files / All Notes View
16
+* [X] All Files / All Notes View
17 17
 * [ ] Folders/Notebook view & navigation
18 18
 * [ ] Nav btns go to file views
19 19
 * [ ] Note versioning
@@ -28,4 +28,7 @@
28 28
 * [ ] S3 Backup
29 29
 * [ ] Web Clipper
30 30
 * [ ] Multiple source folders
31
-* [ ] Footer bar infos
31
+* [ ] Footer bar infos
32
+* [ ] File View Buffering
33
+* [ ] Retina Thumbnails
34
+* [ ] Charset Encoding bug