Support publishing posts
Adds a menu option and publishes whatever is in the editor, using the `writeas` command-line client.
This commit is contained in:
parent
71a7fa47eb
commit
378d335549
@ -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 */,
|
||||
);
|
||||
|
@ -42,5 +42,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
@IBAction func saveDocument(_ sender: AnyObject) {
|
||||
vc?.saveDocument()
|
||||
}
|
||||
|
||||
@IBAction func publishDoc(_ sender: Any) {
|
||||
vc?.publish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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
Executable file
BIN
writeas/writeas
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user