Class: Evertils::Type::Weekly
Constant Summary collapse
- NOTEBOOK =
:Weekly
- COLOUR =
0xffe8b7
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #add_daily_note_link ⇒ Object
-
#initialize(config, *args) ⇒ Weekly
constructor
A new instance of Weekly.
- #tags ⇒ Object
Methods inherited from Base
#create, #morning_note?, #should_create?
Constructor Details
Instance Method Details
#add_daily_note_link ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/evertils/types/weekly.rb', line 27 def add_daily_note_link da_entity = @note_helper.wait_for(:Daily).entity # parse the ENML note data into something we can work with xml = @api.from_str(@entity.content) # include the XML element builder xml_helper = Evertils::Helper.load('Xml', xml) # internal URL for the linked note note_url = @note_helper.internal_url_for(da_entity) # don't add the note link if it is already there unless xml.search("a[href='#{note_url}']").size.zero? return Notify.warning('Daily note link already exists here, exiting to avoid duplicate content') end a = xml_helper.a( note_url, @format.date_templates[:Daily] ) li = xml_helper.li(a) br = xml_helper.br xml.search('en-note>div:first-child>ul li:last-child').after(li) # add a line break after the UL if one is not there yet if xml.search('en-note>div:first-child').first.next_element.name != 'br' xml.search('en-note>div:first-child').after(br) end @entity.content = xml.to_s Notify.success("#{self.class.name} updated, added daily note link") if @note.update end |
#tags ⇒ Object
18 19 20 21 22 23 |
# File 'lib/evertils/types/weekly.rb', line 18 def [ "week-#{Date.today.cweek}", "month-#{Date.today.month}" ] end |