Skip to content

Commit fa1bdb7

Browse files
committed
Initial commit of TextBundle import/export.
1 parent 0dfbd22 commit fa1bdb7

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

TODO

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ TODO:
22

33
☐ Add auto-completion when entering note links
44
Not exactly sure how to currently implement this
5-
☐ Add support for undo/redo
5+
☐ Add support for undo/redo @ip
66
Need to figure out what we will be able to undo/redo (it won't be everything)
7+
See Undo-Actions.minder for a full breakdown of the tasks associated with this todo
78
☐ Add ability to import a directory full of Markdown notes into notebook(s)
89
This could be used to import notes from another tool perhaps
10+
Use TextBundle format
911
☐ Add ability to export all notes into a series of directories @ip
10-
Similar in structure to how IA writer notes are handled (I forget the format)
12+
Similar in structure to how IA writer notes are handled (TextBundle)
1113
☐ Add support for saving a note as a template.
1214
☐ Add support for create a new note based on a saved template.
1315
☐ Add support for editing and deleting a note template

src/TextBundle.vala

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2024 (https://github.com/phase1geo/MosaicNote)
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2 of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public
15+
* License along with this program; if not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+
* Boston, MA 02110-1301 USA
18+
*
19+
* Authored by: Trevor Williams <[email protected]>
20+
*/
21+
22+
public class TextBundle {
23+
24+
private MainWindow _win;
25+
26+
//-------------------------------------------------------------
27+
// Default constructor
28+
public TextBundle( MainWindow win ) {
29+
_win = win;
30+
}
31+
32+
//-------------------------------------------------------------
33+
// Imports a TextBundle of the given name.
34+
public void import( string filename ) {
35+
36+
var directory_path = filename;
37+
38+
try {
39+
40+
var directory = File.new_for_path( directory_path );
41+
var enumerator = directory.enumerate_children( "standard::*", FileQueryInfoFlags.NONE );
42+
43+
FileInfo? info;
44+
while( (info = enumerator.next_file()) != null ) {
45+
string name = info.get_name();
46+
if( info.get_file_type() == FileType.REGULAR ) {
47+
if( name.has_prefix( "test." ) && (name.has_suffix( ".markdown" ) || name.has_suffix( ".md" )) ) {
48+
import_markdown( name );
49+
}
50+
}
51+
}
52+
enumerator.close();
53+
} catch( Error e ) {
54+
stderr.printf("Error: %s\n", e.message);
55+
}
56+
57+
}
58+
59+
private void import_markdown( string filename ) {
60+
61+
// TODO
62+
63+
}
64+
65+
//=============================================================
66+
67+
//-------------------------------------------------------------
68+
// Exports
69+
public void export( string filename ) {
70+
// TODO
71+
}
72+
73+
}

src/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ sources += files(
4040
'TagBox.vala',
4141
'TagEntry.vala',
4242
'Tags.vala',
43+
'TextBundle.vala',
4344
'Themes.vala',
4445
'ToolbarCode.vala',
4546
'ToolbarItem.vala',

0 commit comments

Comments
 (0)