atom-markdown-image-assistant icon indicating copy to clipboard operation
atom-markdown-image-assistant copied to clipboard

Prepend current date

Open icemtel opened this issue 5 years ago • 3 comments

I'd like to add a date to the filename of the image, E.g. instead of readme-a85f5b36.png I would like to have readme-2019-04-15-a85f5b36.png.

icemtel avatar Apr 15 '19 13:04 icemtel

I have some progress on that, but I need some advice, since I never used Coffeescript before.

  • I added a new entry to config

     prependCurrentdate:
          title: "Prepend current date"
          description: "Whether to prepend current date in format yyyy-mm-dd"
          type: 'boolean'
          default: true
    

    It is displayed in settings, so I assume that it works.

  • I add the following lines (simplified)

      if atom.config.get('markdown-image-assistant.prependCurrentDate')
          today = 'yay'
      else
          today = 'whoops'
      img_filename = today + img_filename
    

The problem is that I always get 'whoops' prepended, no matter if the "prependCurrentdate" is ticked in the settings or not. If I get this fixed, I can make a pull request.

icemtel avatar Apr 15 '19 13:04 icemtel

Maybe try initializing today prior to the if-else? Can you verify that atom.config.get('markdown-image-assistant.prependCurrentDate') is returning the right value?

tlnagy avatar Apr 17 '19 23:04 tlnagy

Indeed, this variable was undefined, because of 1 lower-case letter instead of upper-case.

icemtel avatar Apr 18 '19 08:04 icemtel