lib/controllers/generate.rb in evertils-0.3.0 vs lib/controllers/generate.rb in evertils-0.3.1
- old
+ new
@@ -22,11 +22,11 @@
opt.on("-s", "--start=START", "Specify a date for the note") do |date|
@start = DateTime.parse(date)
end
- opt.on("-n", "--name=NAME", "A name to pass to the script (not all command support this flag)") do |name|
+ opt.on("-n", "--name=NAME", "A name to pass to the script (not all commands support this flag)") do |name|
@name = name
end
end.parse!
super
@@ -34,19 +34,21 @@
# generate daily notes
def daily
title = @format.date_templates[NOTEBOOK_DAILY]
body = @format.template_contents
+ body += to_enml($config.custom_sections[NOTEBOOK_DAILY]) if $config.custom_sections[NOTEBOOK_DAILY]
parent_notebook = NOTEBOOK_DAILY
@model.create_note(title, body, parent_notebook)
end
# generate weekly notes
def weekly
title = @format.date_templates[NOTEBOOK_WEEKLY]
body = @format.template_contents
+ body += to_enml($config.custom_sections[NOTEBOOK_WEEKLY]) if $config.custom_sections[NOTEBOOK_WEEKLY]
parent_notebook = NOTEBOOK_WEEKLY
if !@force
if !Date.today.monday?
Notify.error("Sorry, you can only create new weekly logs on Mondays")
@@ -62,10 +64,11 @@
# generate monthly notes
def monthly
title = @format.date_templates[NOTEBOOK_MONTHLY]
body = @format.template_contents
+ body += to_enml($config.custom_sections[NOTEBOOK_MONTHLY]) if $config.custom_sections[NOTEBOOK_MONTHLY]
parent_notebook = NOTEBOOK_MONTHLY
note = @model.create_note(title, body, parent_notebook)
tag_manager = Evertils::Common::Manager::Tag.new
@@ -77,23 +80,33 @@
def mts
Notify.error("Name argument is required") if @name.nil?
title = "#{@name} #{DateTime.now.strftime('%m-%Y')}"
body = @format.template_contents
+ body += to_enml($config.custom_sections[NOTEBOOK_MTS]) if $config.custom_sections[NOTEBOOK_MTS]
parent_notebook = NOTEBOOK_MTS
# create the note from template
mts_note = @model.create_note(title, body, parent_notebook)
-
+
# tag it
# TODO: maybe move this out of controller?
tag_manager = Evertils::Common::Manager::Tag.new
month_tag = tag_manager.find("month-#{DateTime.now.strftime('%-m')}")
mts_note.tag(month_tag.prop(:name))
# TODO: commented out until support for multiple tags is added
# client_tag = tag_manager.find_or_create(@name)
# mts_note.tag(client_tag.prop(:name))
end
+
+ private
+
+ #
+ # @since 0.3.1
+ def to_enml(hash)
+ enml = Evertils::Helper::EvernoteENML::with_list(hash)
+ end
+
end
end
end