Skip to content

Commit

Permalink
🎨 Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tw93 committed Jan 17, 2024
1 parent 72b4774 commit 3f1b948
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 28 deletions.
56 changes: 32 additions & 24 deletions Mac/AppDelegate+URLRoutes.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// AppDelegate+URLRoutes.swift
// FSNotes
//
// Created by Jeff Hanbury on 13/04/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//

import Cocoa
import Foundation

Expand All @@ -8,20 +16,20 @@ extension AppDelegate {
case nvALT = "nvalt"
case file
}

enum MiaoYanRoutes: String {
case find
case new
case goto
}

enum NvALTRoutes: String {
case find
case blank = ""
case make
case goto
}

func application(_ application: NSApplication, open urls: [URL]) {
guard var url = urls.first,
let scheme = url.scheme
Expand Down Expand Up @@ -55,7 +63,7 @@ extension AppDelegate {
UserDefaultsManagement.isSingleMode = true
vc.restart()
}

func importNotes(urls: [URL]) {
guard let vc = ViewController.shared() else { return }

Expand Down Expand Up @@ -85,12 +93,12 @@ extension AppDelegate {
}
}
}

// MARK: - MiaoYan routes

func MiaoYanRouter(_ url: URL) {
guard let directive = url.host else { return }

switch directive {
case MiaoYanRoutes.find.rawValue:
RouteMiaoYanFind(url)
Expand All @@ -102,7 +110,7 @@ extension AppDelegate {
break
}
}

/// Handles URLs with the path /find/searchstring1%20searchstring2
func RouteMiaoYanFind(_ url: URL) {
let lastPath = url.lastPathComponent
Expand Down Expand Up @@ -163,7 +171,7 @@ extension AppDelegate {
}
}
}

/// Handles URLs with the following paths:
/// - miaoyan://make/?title=URI-escaped-title&html=URI-escaped-HTML-data
/// - miaoyan://make/?title=URI-escaped-title&txt=URI-escaped-plain-text
Expand All @@ -174,17 +182,17 @@ extension AppDelegate {
func RouteMiaoYanNew(_ url: URL) {
var title = ""
var body = ""

if let titleParam = url["title"] {
title = titleParam
}

if let txtParam = url["txt"] {
body = txtParam
} else if let htmlParam = url["html"] {
body = htmlParam
}

guard ViewController.shared() != nil else {
newName = title
newContent = body
Expand All @@ -199,12 +207,12 @@ extension AppDelegate {

controller.createNote(name: name, content: content)
}

// MARK: - nvALT routes, for compatibility

func NvALTRouter(_ url: URL) {
guard let directive = url.host else { return }

switch directive {
case NvALTRoutes.find.rawValue:
RouteNvAltFind(url)
Expand All @@ -216,30 +224,30 @@ extension AppDelegate {
RouteNvAltBlank(url)
}
}

/// Handle URLs in the format nv://find/searchstring1%20searchstring2
///
/// Note: this route is identical to the corresponding MiaoYan route.
///
func RouteNvAltFind(_ url: URL) {
RouteMiaoYanFind(url)
}

func RouteNvAltGoto(_ url: URL) {
RouteMiaoYanGoto(url)
}

/// Handle URLs in the format nv://note%20title
///
/// Note: this route is an alias to the /find route above.
///
func RouteNvAltBlank(_ url: URL) {
let pathWithFind = url.absoluteString.replacingOccurrences(of: "://", with: "://find/")
guard let newURL = URL(string: pathWithFind) else { return }

RouteMiaoYanFind(newURL)
}

/// Handle URLs in the format:
///
/// - nv://make/?title=URI-escaped-title&html=URI-escaped-HTML-data&tags=URI-escaped-tag-string
Expand All @@ -251,23 +259,23 @@ extension AppDelegate {
func RouteNvAltMake(_ url: URL) {
var title = ""
var body = ""

if let titleParam = url["title"] {
title = titleParam
}

if let txtParam = url["txt"] {
body = txtParam
} else if let htmlParam = url["html"] {
body = htmlParam
}

if let tagsParam = url["tags"] {
body = body.appending("\n\nnvALT tags: \(tagsParam)")
}

guard let controller = ViewController.shared() else { return }

controller.createNote(name: title, content: body)
}
}
8 changes: 8 additions & 0 deletions Mac/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// AppDelegate.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 7/20/17.
// Copyright © 2017 Oleksandr Glushchenko. All rights reserved.
//

import AppCenter
import AppCenterAnalytics
import AppCenterCrashes
Expand Down
8 changes: 8 additions & 0 deletions Mac/Business/CodeBlock.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// CodeBlock.swift
// FSNotes
//
// Created by Олександр Глущенко on 8/28/19.
// Copyright © 2019 Oleksandr Glushchenko. All rights reserved.
//

import AppKit

class CodeBlock: NSTextBlock {
Expand Down
8 changes: 8 additions & 0 deletions Mac/Extensions/ImageAttachment+.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// ImageAttachment+.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 1/19/19.
// Copyright © 2019 Oleksandr Glushchenko. All rights reserved.
//

import AVKit
import Cocoa

Expand Down
10 changes: 9 additions & 1 deletion Mac/Extensions/NSFont+.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// NSFont+.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 8/26/17.
// Copyright © 2017 Oleksandr Glushchenko. All rights reserved.
//

import Cocoa

extension NSFont {
Expand All @@ -20,7 +28,7 @@ extension NSFont {
var lineHeightCustom: CGFloat {
CGFloat(ceilf(Float(ascender + abs(descender) + leading)))
}

static func italicFont() -> NSFont {
NSFontManager().convert(UserDefaultsManagement.noteFont, toHaveTrait: .italicFontMask)
}
Expand Down
8 changes: 8 additions & 0 deletions Mac/Extensions/NSImage+.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// NSImage+.swift
// FSNotesCore macOS
//
// Created by Oleksandr Glushchenko on 10/14/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//

import AppKit

public extension NSImage {
Expand Down
8 changes: 8 additions & 0 deletions Mac/Extensions/NSMutableAttributedString+.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// NSMutableAttributedString+.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 7/21/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//

import Foundation

#if os(iOS)
Expand Down
8 changes: 8 additions & 0 deletions Mac/Extensions/NSMutableAttributedString+Attachments.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// NSMutableAttributedString+Attachments.swift
// FSNotes
//
// Created by Олександр Глущенко on 10/3/19.
// Copyright © 2019 Oleksandr Glushchenko. All rights reserved.
//

import Foundation

extension NSMutableAttributedString {
Expand Down
8 changes: 8 additions & 0 deletions Mac/Extensions/NSTextAttachment+.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// NSTextAttachment+.swift
// FSNotes
//
// Created by Олександр Глущенко on 10/2/19.
// Copyright © 2019 Oleksandr Glushchenko. All rights reserved.
//

#if os(OSX)
import Cocoa
#else
Expand Down
8 changes: 8 additions & 0 deletions Mac/Extensions/String+.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// String+.swift
// FSNotes
//
// Created by Jeff Hanbury on 29/08/17.
// Copyright © 2017 Oleksandr Glushchenko. All rights reserved.
//

import CommonCrypto
import CryptoKit
import Foundation
Expand Down
8 changes: 8 additions & 0 deletions Mac/Extensions/URL+.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// URL+.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 3/22/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//

import Foundation

#if os(iOS)
Expand Down
8 changes: 8 additions & 0 deletions Mac/Helpers/FileSystemEventManager.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// FileSystemEventManager.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 7/13/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//

import Foundation

class FileSystemEventManager {
Expand Down
8 changes: 8 additions & 0 deletions Mac/Helpers/NotesTextProcessor.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// NotesTextStorage.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 12/26/17.
// Copyright © 2017 Oleksandr Glushchenko. All rights reserved.
//

import Highlightr

#if os(OSX)
Expand Down
8 changes: 8 additions & 0 deletions Mac/Helpers/TextFormatter.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// TextFormatter.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 3/6/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//

import Foundation

#if os(OSX)
Expand Down
8 changes: 8 additions & 0 deletions Mac/Helpers/UserDataService.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// UserDataService.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 1/30/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//

import Foundation

public class UserDataService {
Expand Down
8 changes: 8 additions & 0 deletions Mac/View/EditorScrollView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// EditorScrollView.swift
// FSNotes
//
// Created by Oleksandr Glushchenko on 10/7/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//

import Cocoa

class EditorScrollView: NSScrollView {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

- <a href="https://github.com/KristopherGBaker/libcmark_gfm" target="_blank">KristopherGBaker/libcmark_gfm</a>:适用于 cmark-gfm 的 Swift 兼容框架
- <a href="https://github.com/raspu/Highlightr" target="_blank">raspu/Highlightr</a>:语法高亮能力
- <a href="https://github.com/glushchenko/fsnotes" target="_blank">glushchenko/fsnotes</a>:妙言有部分初始化代码来源于此
- <a href="https://github.com/glushchenko/fsnotes" target="_blank">glushchenko/fsnotes</a>:妙言部分初始化代码来源于此项目,很感谢作者
- <a href="https://github.com/lxgw/LxgwWenKai" target="_blank">lxgw/LxgwWenKai</a>:一款漂亮的开源中文字体,妙言将其作为默认字体
- <a href="https://github.com/michaelhenry/Prettier.swift" target="_blank">michaelhenry/Prettier.swift</a>:妙言格式化能力升级成 Prettier 的思路来源
- <a href="https://github.com/hakimel/reveal.js" target="_blank">hakimel/reveal.js</a>:妙言 PPT 底层渲染依赖此框架
Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

- <a href="https://github.com/KristopherGBaker/libcmark_gfm" target="_blank">KristopherGBaker/libcmark_gfm</a>: Swift Compatible framework for cmark-gfm.
- <a href="https://github.com/raspu/Highlightr" target="_blank">raspu/Highlightr</a>: Syntax highlighting capability.
- <a href="https://github.com/glushchenko/fsnotes" target="_blank">glushchenko/fsnotes</a>: MiaoYan has part of the framework code from this project.
- <a href="https://github.com/glushchenko/fsnotes" target="_blank">glushchenko/fsnotes</a>: MiaoYan has part of the framework code from this project, Thank you very much to the author.
- <a href="https://github.com/lxgw/LxgwWenKai" target="_blank">lxgw/LxgwWenKai</a>: A beautiful open source chinese font, MiaoYan has made it the default font.
- <a href="https://github.com/michaelhenry/Prettier.swift" target="_blank">michaelhenry/Prettier.swift</a>:MiaoYan document auto typesetting is from Prettier.
- <a href="https://github.com/hakimel/reveal.js" target="_blank">hakimel/reveal.js</a>:An open source HTML presentation framework.
Expand Down
2 changes: 1 addition & 1 deletion README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

- <a href="https://github.com/KristopherGBaker/libcmark_gfm" target="_blank">KristopherGBaker/libcmark_gfm</a>: cmark-gfm 用の Swift 互換フレームワーク。
- <a href="https://github.com/raspu/Highlightr" target="_blank">raspu/Highlightr</a>: シンタックスハイライト機能。
- <a href="https://github.com/glushchenko/fsnotes" target="_blank">glushchenko/fsnotes</a>: MiaoYan はこのプロジェクトからフレームワークの一部のコードを持っています。
- <a href="https://github.com/glushchenko/fsnotes" target="_blank">glushchenko/fsnotes</a>: MiaoYan はこのプロジェクトからフレームワークの一部のコードを持っています, 著者に感謝します
- <a href="https://github.com/lxgw/LxgwWenKai" target="_blank">lxgw/LxgwWenKai</a>: 美しいオープンソースの中国語フォント、MiaoYan はこれをデフォルトのフォントにしました。
- <a href="https://github.com/michaelhenry/Prettier.swift" target="_blank">michaelhenry/Prettier.swift</a>:MiaoYan のドキュメント自動タイプセットは Prettier から来ています。
- <a href="https://github.com/hakimel/reveal.js" target="_blank">hakimel/reveal.js</a>:オープンソースの HTML プレゼンテーションフレームワーク。
Expand Down

0 comments on commit 3f1b948

Please sign in to comment.