diff --git a/Agni/Agni.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Agni/Agni.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index dbde7ba..2e5ae4c 100644 --- a/Agni/Agni.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Agni/Agni.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -7,7 +7,7 @@ "location" : "https://github.com/rryam/AgniKit", "state" : { "branch" : "main", - "revision" : "17559d0417e78b44f37acc081047a170bf028585" + "revision" : "36cb86d37fdc9ecb2d5558ae39467e78b0f82cd2" } } ], diff --git a/Agni/Agni/Agni.entitlements b/Agni/Agni/Agni.entitlements index f2ef3ae..625af03 100644 --- a/Agni/Agni/Agni.entitlements +++ b/Agni/Agni/Agni.entitlements @@ -2,9 +2,11 @@ - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-only - + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + com.apple.security.network.client + diff --git a/Agni/Agni/Components/MarkdownView.swift b/Agni/Agni/Components/MarkdownView.swift new file mode 100644 index 0000000..c406834 --- /dev/null +++ b/Agni/Agni/Components/MarkdownView.swift @@ -0,0 +1,34 @@ +import SwiftUI + +/// A view that renders basic Markdown content using SwiftUI Text. +/// +/// `MarkdownView` provides a lightweight way to display formatted Markdown text +/// using SwiftUI's built-in AttributedString markdown parsing. +/// +/// ## Usage +/// ```swift +/// MarkdownView("# Hello\nThis is **bold** and *italic* text") +/// ``` +struct MarkdownView: View { + /// The formatted content to be displayed + private let content: AttributedString + + /// Creates a new MarkdownView with the specified content. + /// + /// - Parameter content: A string containing Markdown-formatted text + init(_ content: String) { + do { + self.content = try AttributedString(markdown: content) + } catch { + print("Error parsing markdown: \(error)") + self.content = AttributedString(content) + } + } + + var body: some View { + Text(content) + .textSelection(.enabled) + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + } +} \ No newline at end of file diff --git a/Agni/Agni/Components/ResultView.swift b/Agni/Agni/Components/ResultView.swift index 61738d9..11e432e 100644 --- a/Agni/Agni/Components/ResultView.swift +++ b/Agni/Agni/Components/ResultView.swift @@ -15,7 +15,7 @@ struct ResultView: View { ScrollView { if selectedFormat == "markdown" { - // MarkdownView(content) + MarkdownView(content) } else { TextEditor(text: .constant(content)) .font(.system(.body, design: .monospaced)) diff --git a/Agni/Agni/Views/QuickScrapeView.swift b/Agni/Agni/Views/QuickScrapeView.swift index 0b0aca5..37c8149 100644 --- a/Agni/Agni/Views/QuickScrapeView.swift +++ b/Agni/Agni/Views/QuickScrapeView.swift @@ -1,4 +1,5 @@ import SwiftUI +import AgniKit struct QuickScrapeView: View { @State private var url = "" @@ -10,6 +11,32 @@ struct QuickScrapeView: View { @State private var waitTime: Double = 0 @State private var timeout: Double = 30 + private let agni = AgniKit(apiKey: "fc") + + private func performScrape() async { + do { + let includeTagsArray = includeTags.isEmpty ? nil : + includeTags.split(separator: ",").map(String.init) + let excludeTagsArray = excludeTags.isEmpty ? nil : + excludeTags.split(separator: ",").map(String.init) + + let response = try await agni.scrape( + url: url, + formats: formats, + onlyMainContent: onlyMainContent, + includeTags: includeTagsArray, + excludeTags: excludeTagsArray, + waitFor: Int(waitTime * 1000), + timeout: Int(timeout * 1000) + ) + + result = response.data.markdown ?? "No markdown content available" + + } catch { + result = "Error: \(error.localizedDescription)" + } + } + var body: some View { Form { Section("Input") { @@ -34,7 +61,7 @@ struct QuickScrapeView: View { Section("Actions") { Button("Scrape") { Task { - // await performScrape() + await performScrape() } } }