mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-10 02:32:20 +08:00
Allow Journal Entries to have their own file naming scheme
Adding an individual setting is becoming way too complex now.
This commit is contained in:
@ -398,6 +398,7 @@ feature:
|
||||
inlineTags: Inline Tags
|
||||
singleJournalEntry: Single Journal Entry File per day
|
||||
configureBottomMenuBar: Configure the Bottom Menu Bar
|
||||
customFileNamePerEditor: Custom FileName per Editor
|
||||
|
||||
feature_timeline:
|
||||
title: Feature Timeline
|
||||
|
@ -6,6 +6,7 @@
|
||||
- text: "Move metadata configuration features from Pro to Basic"
|
||||
- text: "Allow the Bottom Menu bar to be hidden - #261"
|
||||
image: bottom_menu_bar.gif
|
||||
- text: "Allow Journal Entries to have their own file naming scheme"
|
||||
bugs:
|
||||
- text: "Dark Theme: Render checkboxes in a lighter color"
|
||||
- text: "Fix Relative Parent links not working - #256"
|
||||
|
@ -512,7 +512,10 @@ class Note with NotesNotifier {
|
||||
|
||||
String _buildFileName() {
|
||||
var date = created ?? modified ?? fileLastModified ?? DateTime.now();
|
||||
switch (parent.config.fileNameFormat) {
|
||||
var isJournal = type == NoteType.Journal;
|
||||
switch (!isJournal
|
||||
? parent.config.fileNameFormat
|
||||
: parent.config.journalFileNameFormat) {
|
||||
case NoteFileNameFormat.SimpleDate:
|
||||
return toSimpleDateTime(date);
|
||||
case NoteFileNameFormat.FromTitle:
|
||||
|
@ -25,6 +25,7 @@ class NotesFolderConfig extends Equatable {
|
||||
final StandardViewHeader viewHeader;
|
||||
final bool showNoteSummary;
|
||||
final NoteFileNameFormat fileNameFormat;
|
||||
final NoteFileNameFormat journalFileNameFormat;
|
||||
final NotesFolderFS folder;
|
||||
final bool yamlHeaderEnabled;
|
||||
//int _version = 1;
|
||||
@ -44,6 +45,7 @@ class NotesFolderConfig extends Equatable {
|
||||
@required this.viewHeader,
|
||||
@required this.showNoteSummary,
|
||||
@required this.fileNameFormat,
|
||||
@required this.journalFileNameFormat,
|
||||
@required this.folder,
|
||||
@required this.yamlHeaderEnabled,
|
||||
@required this.yamlModifiedKey,
|
||||
@ -61,6 +63,7 @@ class NotesFolderConfig extends Equatable {
|
||||
defaultView,
|
||||
viewHeader,
|
||||
fileNameFormat,
|
||||
journalFileNameFormat,
|
||||
folder,
|
||||
yamlHeaderEnabled,
|
||||
yamlModifiedKey,
|
||||
@ -93,6 +96,7 @@ class NotesFolderConfig extends Equatable {
|
||||
showNoteSummary: settings.showNoteSummary,
|
||||
viewHeader: viewHeader,
|
||||
fileNameFormat: settings.noteFileNameFormat,
|
||||
journalFileNameFormat: settings.journalNoteFileNameFormat,
|
||||
folder: folder,
|
||||
yamlHeaderEnabled: settings.yamlHeaderEnabled,
|
||||
yamlCreatedKey: settings.yamlCreatedKey,
|
||||
@ -126,6 +130,7 @@ class NotesFolderConfig extends Equatable {
|
||||
}
|
||||
settings.folderViewHeaderType = ht;
|
||||
settings.noteFileNameFormat = fileNameFormat;
|
||||
settings.journalNoteFileNameFormat = journalFileNameFormat;
|
||||
settings.yamlHeaderEnabled = yamlHeaderEnabled;
|
||||
settings.yamlCreatedKey = yamlCreatedKey;
|
||||
settings.yamlModifiedKey = yamlModifiedKey;
|
||||
@ -143,6 +148,7 @@ class NotesFolderConfig extends Equatable {
|
||||
StandardViewHeader viewHeader,
|
||||
bool showNoteSummary,
|
||||
NoteFileNameFormat fileNameFormat,
|
||||
NoteFileNameFormat journalFileNameFormat,
|
||||
NotesFolderFS folder,
|
||||
bool yamlHeaderEnabled,
|
||||
String yamlCreatedKey,
|
||||
@ -159,6 +165,8 @@ class NotesFolderConfig extends Equatable {
|
||||
viewHeader: viewHeader ?? this.viewHeader,
|
||||
showNoteSummary: showNoteSummary ?? this.showNoteSummary,
|
||||
fileNameFormat: fileNameFormat ?? this.fileNameFormat,
|
||||
journalFileNameFormat:
|
||||
journalFileNameFormat ?? this.journalFileNameFormat,
|
||||
folder: folder ?? this.folder,
|
||||
yamlHeaderEnabled: yamlHeaderEnabled ?? this.yamlHeaderEnabled,
|
||||
yamlCreatedKey: yamlCreatedKey ?? this.yamlCreatedKey,
|
||||
@ -215,6 +223,7 @@ class NotesFolderConfig extends Equatable {
|
||||
}
|
||||
|
||||
var fileNameFormat = map['noteFileNameFormat']?.toString();
|
||||
var journalFileNameFormat = map['journalFileNameFormat'].toString();
|
||||
var yamlHeaderEnabled = map["yamlHeaderEnabled"]?.toString() != "false";
|
||||
|
||||
var yamlCreatedKey = map['yamlCreatedKey']?.toString();
|
||||
@ -231,6 +240,8 @@ class NotesFolderConfig extends Equatable {
|
||||
showNoteSummary: showNoteSummary,
|
||||
viewHeader: viewHeader,
|
||||
fileNameFormat: NoteFileNameFormat.fromInternalString(fileNameFormat),
|
||||
journalFileNameFormat:
|
||||
NoteFileNameFormat.fromInternalString(journalFileNameFormat),
|
||||
folder: folder,
|
||||
yamlHeaderEnabled: yamlHeaderEnabled,
|
||||
yamlCreatedKey: yamlCreatedKey,
|
||||
@ -266,6 +277,7 @@ class NotesFolderConfig extends Equatable {
|
||||
"showNoteSummary": showNoteSummary,
|
||||
"folderViewHeaderType": ht,
|
||||
"noteFileNameFormat": fileNameFormat.toInternalString(),
|
||||
'journalFileNameFormat': journalFileNameFormat.toInternalString(),
|
||||
'yamlHeaderEnabled': yamlHeaderEnabled,
|
||||
'yamlModifiedKey': yamlModifiedKey,
|
||||
'yamlCreatedKey': yamlCreatedKey,
|
||||
|
@ -41,6 +41,7 @@ class Features {
|
||||
Feature.inlineTags,
|
||||
Feature.singleJournalEntry,
|
||||
Feature.configureBottomMenuBar,
|
||||
Feature.customFileNamePerEditor,
|
||||
];
|
||||
|
||||
static final inProgress = <String>[
|
||||
@ -347,6 +348,14 @@ class Feature {
|
||||
"",
|
||||
true,
|
||||
);
|
||||
|
||||
static final customFileNamePerEditor = Feature(
|
||||
"customFileNamePerEditor",
|
||||
DateTime(2020, 10, 05),
|
||||
tr("feature.customFileNamePerEditor"),
|
||||
"",
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
// Feature Adding checklist
|
||||
|
@ -93,6 +93,22 @@ class SettingsEditorsScreenState extends State<SettingsEditorsScreen> {
|
||||
},
|
||||
),
|
||||
),
|
||||
ProOverlay(
|
||||
feature: Feature.singleJournalEntry,
|
||||
child: ListPreference(
|
||||
title: tr('settings.note.fileName'),
|
||||
currentOption: settings.journalNoteFileNameFormat.toPublicString(),
|
||||
options: NoteFileNameFormat.options
|
||||
.map((f) => f.toPublicString())
|
||||
.toList(),
|
||||
onChange: (String publicStr) {
|
||||
var format = NoteFileNameFormat.fromPublicString(publicStr);
|
||||
settings.journalNoteFileNameFormat = format;
|
||||
settings.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
]);
|
||||
|
||||
return Scaffold(
|
||||
|
@ -15,6 +15,7 @@ class Settings extends ChangeNotifier {
|
||||
String gitAuthor = "GitJournal";
|
||||
String gitAuthorEmail = "app@gitjournal.io";
|
||||
NoteFileNameFormat noteFileNameFormat = NoteFileNameFormat.Default;
|
||||
NoteFileNameFormat journalNoteFileNameFormat = NoteFileNameFormat.Default;
|
||||
|
||||
String yamlModifiedKey = "modified";
|
||||
String yamlCreatedKey = "created";
|
||||
@ -70,6 +71,8 @@ class Settings extends ChangeNotifier {
|
||||
|
||||
noteFileNameFormat = NoteFileNameFormat.fromInternalString(
|
||||
pref.getString("noteFileNameFormat"));
|
||||
journalNoteFileNameFormat = NoteFileNameFormat.fromInternalString(
|
||||
pref.getString("journalNoteFileNameFormat"));
|
||||
|
||||
yamlModifiedKey = pref.getString("yamlModifiedKey") ?? yamlModifiedKey;
|
||||
yamlCreatedKey = pref.getString("yamlCreatedKey") ?? yamlCreatedKey;
|
||||
@ -148,6 +151,11 @@ class Settings extends ChangeNotifier {
|
||||
"noteFileNameFormat",
|
||||
noteFileNameFormat.toInternalString(),
|
||||
defaultSet.noteFileNameFormat.toInternalString());
|
||||
_setString(
|
||||
pref,
|
||||
"journalNoteFileNameFormat",
|
||||
journalNoteFileNameFormat.toInternalString(),
|
||||
defaultSet.journalNoteFileNameFormat.toInternalString());
|
||||
_setString(
|
||||
pref, "yamlModifiedKey", yamlModifiedKey, defaultSet.yamlModifiedKey);
|
||||
_setString(
|
||||
@ -265,6 +273,7 @@ class Settings extends ChangeNotifier {
|
||||
"gitAuthor": gitAuthor,
|
||||
"gitAuthorEmail": gitAuthorEmail,
|
||||
"noteFileNameFormat": noteFileNameFormat.toInternalString(),
|
||||
"journalNoteFileNameFormat": journalNoteFileNameFormat.toInternalString(),
|
||||
"yamlModifiedKey": yamlModifiedKey,
|
||||
"yamlCreatedKey": yamlCreatedKey,
|
||||
"yamlTagsKey": yamlTagsKey,
|
||||
|
@ -33,6 +33,7 @@ void main() {
|
||||
SortingMode(SortingField.Modified, SortingOrder.Descending),
|
||||
viewHeader: StandardViewHeader.TitleOrFileName,
|
||||
fileNameFormat: NoteFileNameFormat.Default,
|
||||
journalFileNameFormat: NoteFileNameFormat.Default,
|
||||
folder: folder,
|
||||
yamlHeaderEnabled: true,
|
||||
yamlCreatedKey: 'created',
|
||||
|
Reference in New Issue
Block a user