From b6da9977710fdcf4795810cffc6a485802e09268 Mon Sep 17 00:00:00 2001 From: "mattia.astorino" Date: Tue, 2 Aug 2016 08:16:45 +0200 Subject: [PATCH] feat: New changelog command Now the `Changelog` command will open the changelog as a sublime text tab. --- changes.py | 38 ++++++++++++++++++++++++++++++++++++++ urls.py | 10 +--------- 2 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 changes.py diff --git a/changes.py b/changes.py new file mode 100644 index 00000000..3996357d --- /dev/null +++ b/changes.py @@ -0,0 +1,38 @@ +"""Changelog.""" +import sublime +import sublime_plugin +import mdpopups + +CSS = ''' +.mt-config-changes { {{'.background'|css}} margin: 0; padding: 0; } +.mt-config-changes ul li, .bracket-hightlighter p { {{'.foreground'|css}} } +.mt-config-changes a { color: #4B67FF; } +.mt-config-changes h1, .mt-config-changes h2, .mt-config-changes h3, +.mt-config-changes h4, .mt-config-changes h5, .mt-config-changes h6 { + {{'.string'|css('color')}} +} +.mt-config-changes h1, .mt-config-changes h2 { margin-top: 50px; } +.mt-config-changes h3, .mt-config-changes h4 { margin-top: 30px; } +.mt-config-changes blockquote { {{'.foreground'|css('color')}} } +''' + + +class MtChangesCommand(sublime_plugin.WindowCommand): + """Changelog command.""" + + def run(self): + """Show the changelog in a new view.""" + text = sublime.load_resource('Packages/Material Theme/CHANGELOG.md') + view = self.window.new_file() + view.set_name('Material Theme - Changelog') + view.settings().set('gutter', False) + html = '
%s
' % mdpopups.md2html(view, text) + mdpopups.add_phantom(view, 'changelog', sublime.Region(0), html, sublime.LAYOUT_INLINE, css=CSS) + view.set_read_only(True) + view.set_scratch(True) + + def is_enabled(self): + """Check if is enabled.""" + return (mdpopups.version() >= (1, 7, 3)) and (int(sublime.version()) >= 3118) + + is_visible = is_enabled \ No newline at end of file diff --git a/urls.py b/urls.py index 54077ece..e20c64a3 100644 --- a/urls.py +++ b/urls.py @@ -17,12 +17,4 @@ class MtIssuesCommand(sublime_plugin.WindowCommand): def run(self): """Show the changelog in a new view.""" - webbrowser.open_new_tab('https://github.com/equinusocio/material-theme/issues') - - -class MtChangesCommand(sublime_plugin.WindowCommand): - """Changelog command.""" - - def run(self): - """Show the changelog in a new view.""" - webbrowser.open_new_tab('https://github.com/equinusocio/material-theme/blob/master/CHANGELOG.md') \ No newline at end of file + webbrowser.open_new_tab('https://github.com/equinusocio/material-theme/issues') \ No newline at end of file