Skip to content

Commit 2bbe89f

Browse files
authored
Merge pull request #136 from kmwallio/beta
Fix image uploading
2 parents 77f2133 + aea9468 commit 2bbe89f

File tree

10 files changed

+252
-11
lines changed

10 files changed

+252
-11
lines changed

com.github.kmwallio.thiefmd.spec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: com.github.kmwallio.thiefmd
2-
Version: 0.2.0
2+
Version: 0.2.1
33
Release: 1%{?dist}
44
Summary: The markdown editor worth stealing.
55
License: GPL-3.0+
@@ -327,6 +327,8 @@ rm -vf %{buildroot}%{_libdir}/libultheme.a
327327
%postun -p /sbin/ldconfig
328328

329329
%changelog
330+
* Sun Mar 28 2021 kmwallio <[email protected]> - 0.2.1
331+
- Fix image upload support when blogging
330332
* Sat Mar 27 2021 kmwallio <[email protected]> - 0.2.0
331333
- Open Bibtex files and Right-Click Insert Citation in Markdown
332334
- Open, Preview, and Export Fountain Screen Plays

data/com.github.kmwallio.thiefmd.appdata.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<summary>The markdown editor worth stealing.</summary>
1010
<description>
1111
<p>Keep your Markdown managed. Write epic tales, a novel, that screen play, keep a journal, or finally write that book report.</p>
12-
<p>ThiefMD is a Markdown providing an easy way to organize, format, and compile your markdown documents. When you're ready to Publish, go to ePub, PDF, Office, Ghost, WordPress, Write-Freely, or more.</p>
12+
<p>ThiefMD is a Markdown Editor providing an easy way to organize, format, and compile your markdown documents. When you're ready to Publish, go to ePub, PDF, Office, Ghost, WordPress, Write-Freely, or more.</p>
1313
<p>Import from and Export to Office, ePUB, HTML, and more. ThiefMD is your one stop shop for making and managing markdown mischief.</p>
1414
<p>Working on a screenplay? ThiefMD can handle and combine Fountain files as well. Write your novel and prepare for that movie deal all from the same app.</p>
1515
</description>
@@ -60,7 +60,21 @@
6060
</screenshot>
6161
</screenshots>
6262
<releases>
63-
<release version="0.2.0" date="2021-03-27" urgency="low">
63+
<release version="0.2.1" date="2021-03-27" urgency="low">
64+
<description>
65+
<p>This one's for the creators, the note takers, and the plain-text savers. Notes support, screen play support, citation insertion, and more.</p>
66+
<ul>
67+
<li>This is a bug fix release of the last release...</li>
68+
<li>Open Bibtex files and Right-Click Insert Citation in Markdown</li>
69+
<li>Open, Preview, and Export Fountain Screen Plays</li>
70+
<li>A new Notes Pane can help take notes for the file you're working on, or at the project level</li>
71+
<li>Know what you're doing? Disable tips and start the app with a black canvas to write in</li>
72+
<li>Links to other Markdown Documents in the Preview will now open in the Preview and Editor</li>
73+
</ul>
74+
</description>
75+
<url>https://github.com/kmwallio/ThiefMD/releases/tag/v0.2.0-creators-edition</url>
76+
</release>
77+
<release version="0.2.0" date="2021-03-26" urgency="low">
6478
<description>
6579
<p>This one's for the creators, the note takers, and the plain-text savers. Notes support, screen play support, citation insertion, and more.</p>
6680
<ul>

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
com.github.kmwallio.thiefmd (0.2.1) groovy; urgency=low
2+
3+
* Fix image uploading for blogs
4+
5+
-- kmwallio <[email protected]> Sat, 27 Mar 2021 23:52:27 -0700
6+
17
com.github.kmwallio.thiefmd (0.2.0) groovy; urgency=load
28

39
* Open Bibtex files and Right-Click Insert Citation in Markdown

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Name our project
22
project('com.github.kmwallio.thiefmd', ['vala', 'c'],
3-
version: '0.2.0'
3+
version: '0.2.1'
44
)
55

66
# Application ID

src/Connections/GhostConnection.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ namespace ThiefMD.Connections {
251251
if (featured_image == replacement.key) {
252252
featured_image = replacement.value;
253253
}
254-
warning ("Replaced %s with %s", replacement.key, replacement.value);
254+
debug ("Replaced %s with %s", replacement.key, replacement.value);
255255
}
256256

257257
int published_state = publish_state.get_active ();

src/Constants/AppSettings.vala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ namespace ThiefMD {
9090
public const double SIZE_1_REM_IN_PT = 12;
9191
public const double SINGLE_SPACING = 1.0;
9292

93+
// Citation length limit
94+
public const int CITATION_TITLE_MAX_LEN = 30;
95+
9396
// Visual Settings
9497
public const double MINIMUM_CONTRAST_RATIO = 1.2;
9598

src/Controllers/Pandoc.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ namespace ThiefMD.Controllers.Pandoc {
258258

259259
RegexEvalCallback add_upload_paths = (match_info, result) =>
260260
{
261-
if (match_info.get_match_count () >= 2) {
261+
if (match_info.get_match_count () > 2) {
262262
var url = match_info.fetch (2);
263263
string abs_path = "";
264264
if (!url.contains (":") && find_file_to_upload (url, "", out abs_path) && abs_path != "") {
@@ -325,7 +325,7 @@ namespace ThiefMD.Controllers.Pandoc {
325325
Regex url_search = new Regex ("\\((.+?)\\)", RegexCompileFlags.MULTILINE | RegexCompileFlags.CASELESS, 0);
326326
Regex src_search = new Regex ("src=['\"](.+?)['\"]", RegexCompileFlags.MULTILINE | RegexCompileFlags.CASELESS, 0);
327327
Regex css_url_search = new Regex ("url\\(['\"]?(.+?)['\"]?\\)", RegexCompileFlags.MULTILINE | RegexCompileFlags.CASELESS, 0);
328-
Regex cover_image_search = new Regex ("(cover-image|coverimage|feature_image|featureimage|featured_image|featuredimage|bibliography):\\s*['\"]?(.+?)['\"]?\\s*$", RegexCompileFlags.MULTILINE | RegexCompileFlags.CASELESS, 0);
328+
Regex cover_image_search = new Regex ("(cover-image|coverimage|feature_image|featureimage|featured_image|csl|featuredimage|bibliography):\\s*['\"]?(.+?)['\"]?\\s*$", RegexCompileFlags.MULTILINE | RegexCompileFlags.CASELESS, 0);
329329

330330
processed_mk = url_search.replace_eval (
331331
processed_mk,

src/Enrichments/Fountain.vala

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,64 @@ using ThiefMD;
2121
using ThiefMD.Widgets;
2222

2323
namespace ThiefMD.Enrichments {
24+
public class FountainCharacterSuggestor : Gtk.SourceCompletionProvider, GLib.Object {
25+
public Gee.HashSet<string> characters;
26+
27+
public class FountainCharacterSuggestor () {
28+
characters = new Gee.HashSet<string> ();
29+
}
30+
31+
public override string get_name () {
32+
return _("Characters");
33+
}
34+
35+
public override bool match (Gtk.SourceCompletionContext context) {
36+
Gtk.TextIter? start = null, iter = null;
37+
if (context.get_iter (out iter)) {
38+
if (iter.ends_line () && context.get_iter (out start)) {
39+
start.backward_word_start ();
40+
if ((iter.get_offset () - start.get_offset ()) >= 2) {
41+
string check = start.get_text (iter);
42+
return check == check.up ();
43+
}
44+
}
45+
}
46+
47+
return false;
48+
}
49+
50+
public override void populate (Gtk.SourceCompletionContext context) {
51+
List<Gtk.SourceCompletionItem> completions = new List<Gtk.SourceCompletionItem> ();
52+
Gtk.TextIter? start = null, iter = null;
53+
if (context.get_iter (out iter)) {
54+
if (iter.ends_line () && context.get_iter (out start)) {
55+
start.backward_word_start ();
56+
if ((iter.get_offset () - start.get_offset ()) >= 2) {
57+
string check = start.get_text (iter);
58+
foreach (var character in characters) {
59+
if (character.has_prefix (check) && character != check) {
60+
var com_item = new Gtk.SourceCompletionItem ();
61+
com_item.text = character;
62+
com_item.label = character;
63+
com_item.markup = character;
64+
completions.append (com_item);
65+
}
66+
}
67+
}
68+
}
69+
}
70+
context.add_proposals (this, completions, true);
71+
}
72+
73+
public override bool activate_proposal (Gtk.SourceCompletionProposal proposal, Gtk.TextIter iter) {
74+
return false;
75+
}
76+
}
77+
2478
public class FountainEnrichment {
25-
private Gtk.TextView view;
79+
private FountainCharacterSuggestor character_suggester;
80+
private Gtk.SourceCompletionWords source_completion;
81+
private Gtk.SourceView view;
2682
private Gtk.TextBuffer buffer;
2783
private Mutex checking;
2884

@@ -49,9 +105,11 @@ namespace ThiefMD.Enrichments {
49105
} catch (Error e) {
50106
warning ("Could not build regexes: %s", e.message);
51107
}
108+
character_suggester = new FountainCharacterSuggestor ();
52109
checking = Mutex ();
53110
limit_updates = new TimedMutex (250);
54111
last_cursor = -1;
112+
source_completion = null;
55113
}
56114

57115
public void reset () {
@@ -139,6 +197,9 @@ namespace ThiefMD.Enrichments {
139197
}
140198

141199
private void tag_char_diag_helper (Regex regex) {
200+
Gtk.TextIter cursor_iter;
201+
var cursor = buffer.get_insert ();
202+
buffer.get_iter_at_mark (out cursor_iter, cursor);
142203
try {
143204
MatchInfo match_info;
144205
if (regex.match_full (checking_copy, checking_copy.length, 0, 0, out match_info)) {
@@ -175,6 +236,22 @@ namespace ThiefMD.Enrichments {
175236
buffer.apply_tag (tag_parenthetical, start, end);
176237
} else {
177238
buffer.apply_tag (tag_character, start, end);
239+
start.backward_word_start ();
240+
end.forward_word_end ();
241+
if (!character_suggester.characters.contains (character) && !cursor_iter.in_range (start, end)) {
242+
bool partial_character_name = false;
243+
if (character.has_suffix ("^")) {
244+
character = character.substring (0, character.length - 1);
245+
}
246+
foreach (var person in character_suggester.characters) {
247+
if (person.contains (character)) {
248+
partial_character_name = true;
249+
}
250+
}
251+
if (!partial_character_name) {
252+
character_suggester.characters.add (character);
253+
}
254+
}
178255
}
179256
}
180257

@@ -226,7 +303,7 @@ namespace ThiefMD.Enrichments {
226303
} while (match_info.next ());
227304
}
228305

229-
public bool attach (Gtk.TextView textview) {
306+
public bool attach (Gtk.SourceView textview) {
230307
if (textview == null) {
231308
return false;
232309
}
@@ -265,10 +342,26 @@ namespace ThiefMD.Enrichments {
265342
last_cursor = -1;
266343

267344
calculate_margins ();
345+
settings_changed ();
346+
settings.changed.connect (settings_changed);
268347

269348
return true;
270349
}
271350

351+
private void settings_changed () {
352+
var settings = AppSettings.get_default ();
353+
if (settings.experimental && source_completion == null) {
354+
var completion = view.get_completion ();
355+
completion.add_provider (character_suggester);
356+
source_completion = new Gtk.SourceCompletionWords ("Character Suggestor", null);
357+
source_completion.register (buffer);
358+
} else if (!settings.experimental && source_completion != null) {
359+
var completion = view.get_completion ();
360+
source_completion.unregister (buffer);
361+
completion.remove_provider (character_suggester);
362+
}
363+
}
364+
272365
private void calculate_margins () {
273366
var settings = AppSettings.get_default ();
274367
int f_w = (int)(settings.get_css_font_size () * ((settings.fullscreen ? 1.4 : 1)));
@@ -321,6 +414,7 @@ namespace ThiefMD.Enrichments {
321414
}
322415

323416
public void detach () {
417+
var settings = AppSettings.get_default ();
324418
Gtk.TextIter start, end;
325419
buffer.get_bounds (out start, out end);
326420

@@ -332,7 +426,17 @@ namespace ThiefMD.Enrichments {
332426
buffer.tag_table.remove (tag_character);
333427
buffer.tag_table.remove (tag_parenthetical);
334428
buffer.tag_table.remove (tag_dialogue);
429+
430+
if (source_completion != null) {
431+
source_completion.unregister (buffer);
432+
}
433+
434+
settings.changed.disconnect (settings_changed);
435+
335436
tag_scene_heading = null;
437+
tag_character = null;
438+
tag_parenthetical = null;
439+
tag_dialogue = null;
336440

337441
view = null;
338442
buffer = null;

0 commit comments

Comments
 (0)