Browse Source

Support publishing posts

Adds a menu option and publishes whatever is in the editor, using the
`writeas` command-line client.
master
Matt Baer 5 years ago
parent
commit
378d335549
5 changed files with 30 additions and 0 deletions
  1. +4
    -0
      writeas.xcodeproj/project.pbxproj
  2. +4
    -0
      writeas/AppDelegate.swift
  3. +9
    -0
      writeas/Base.lproj/Main.storyboard
  4. +13
    -0
      writeas/ViewController.swift
  5. BIN
      writeas/writeas

+ 4
- 0
writeas.xcodeproj/project.pbxproj View File

@@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
C98EE9AC1F29532F002F646E /* writeas in Resources */ = {isa = PBXBuildFile; fileRef = C98EE9AB1F29532F002F646E /* writeas */; };
C99B910D1C33841E00A91990 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99B910C1C33841E00A91990 /* AppDelegate.swift */; };
C99B910F1C33841E00A91990 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99B910E1C33841E00A91990 /* ViewController.swift */; };
C99B91111C33841F00A91990 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C99B91101C33841F00A91990 /* Assets.xcassets */; };
@@ -14,6 +15,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
C98EE9AB1F29532F002F646E /* writeas */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = writeas; sourceTree = "<group>"; };
C99B91091C33841E00A91990 /* Write.as.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Write.as.app; sourceTree = BUILT_PRODUCTS_DIR; };
C99B910C1C33841E00A91990 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C99B910E1C33841E00A91990 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@@ -52,6 +54,7 @@
C99B910B1C33841E00A91990 /* writeas */ = {
isa = PBXGroup;
children = (
C98EE9AB1F29532F002F646E /* writeas */,
C99B910C1C33841E00A91990 /* AppDelegate.swift */,
C99B910E1C33841E00A91990 /* ViewController.swift */,
C99B91101C33841F00A91990 /* Assets.xcassets */,
@@ -122,6 +125,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C98EE9AC1F29532F002F646E /* writeas in Resources */,
C99B91111C33841F00A91990 /* Assets.xcassets in Resources */,
C99B91141C33841F00A91990 /* Main.storyboard in Resources */,
);


+ 4
- 0
writeas/AppDelegate.swift View File

@@ -42,5 +42,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBAction func saveDocument(_ sender: AnyObject) {
vc?.saveDocument()
}

@IBAction func publishDoc(_ sender: Any) {
vc?.publish()
}
}


+ 9
- 0
writeas/Base.lproj/Main.storyboard View File

@@ -65,6 +65,15 @@
<action selector="saveDocument:" target="Voe-Tx-rLC" id="6F3-Jk-bXC"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="aJh-i4-bef"/>
<menuItem title="Publish" id="Vdf-ed-k4A">
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
<connections>
<action selector="publishDoc:" target="Voe-Tx-rLC" id="krY-d8-wc3"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>


+ 13
- 0
writeas/ViewController.swift View File

@@ -87,6 +87,19 @@ class ViewController: NSViewController, NSTextViewDelegate {
}
}

func publish() {
saveDocument()

let task = Process()
task.launchPath = Bundle.main.executablePath! + "/../../Resources/writeas"
let pipe = Pipe()
task.standardInput = pipe
task.launch()
let fh: FileHandle = pipe.fileHandleForWriting
fh.write(writerText.textStorage!.string.data(using: .utf8)!)
fh.closeFile()
}

func toggle(isNight: Bool) {
let darkBG = NSColor(red:0.13, green:0.13, blue:0.13, alpha:1.0)
if isNight {


BIN
writeas/writeas View File


Loading…
Cancel
Save