Skip to content

Commit

Permalink
Merge pull request #4 from SchwarzIT/remove-resources-bundle
Browse files Browse the repository at this point in the history
Removed resources bundle
  • Loading branch information
Asmeili authored Jun 26, 2023
2 parents 64ffafc + 9568b4d commit eea2027
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 170 deletions.
5 changes: 1 addition & 4 deletions NetworkDebugger.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "NetworkDebugger"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "A Swift package designed to view your App's networking activity with minimal setup."

s.homepage = "https://github.com/schwarzit/swift-network-debugger"
Expand All @@ -20,7 +20,4 @@ Pod::Spec.new do |s|
s.swift_version = "5.0"

s.source_files = "Sources/NetworkDebugger/**/*.{swift}"
s.resource_bundles = {
'NetworkDebugger' => ['Sources/NetworkDebugger/Resources/**/*']
}
end
5 changes: 1 addition & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ let package = Package(
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "NetworkDebugger",
dependencies: [],
resources: [
.process("Resources")
]
dependencies: []
),
.testTarget(
name: "NetworkDebuggerTests",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Install through the Swift Package Manager using Xcode.
### Cocoa Pods
Add to your `podfile` and install using `pod install`.
```ruby
pod 'NetworkDebugger', '1.0.1'
pod 'NetworkDebugger', '1.0.2'
```

## Setup
Expand Down
78 changes: 0 additions & 78 deletions Sources/NetworkDebugger/Extensions/Bundle+NetworkDebugger.swift

This file was deleted.

37 changes: 0 additions & 37 deletions Sources/NetworkDebugger/Resources/DataView.js

This file was deleted.

9 changes: 0 additions & 9 deletions Sources/NetworkDebugger/Resources/Highlightjs/Highlightjs.css

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!--
// DataView.html
// NetworkDebugger
//
// Created by Michael Artes on 28.02.23.
// Copyright © 2023 Schwarz IT KG.
// DataView.html.swift
//
//
// Created by Michael Artes on 26.06.23.
// Copyright © 2023 Schwarz IT KG.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,17 +17,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-->

<!DOCTYPE html>
<html>
<head>
<!-- Highlightjs 11.5.1 styles default.min.css -->
<style>{CSS}</style>
</head>
<body>
<pre>
<code id="code" style="font-size: 50px;">{CONTENT}</code>
</pre>
</body>
</html>
enum DataViewHtml {
static let source = #"""
<!DOCTYPE html>
<html>
<head>
<!-- Highlightjs 11.5.1 styles default.min.css -->
<style>{CSS}</style>
</head>
<body>
<pre>
<code id="code" style="font-size: 50px;">{CONTENT}</code>
</pre>
</body>
</html>
"""#
}
41 changes: 41 additions & 0 deletions Sources/NetworkDebugger/UI/Views/Models/DataView/DataView.js.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// DataView.js.swift
//
//
// Created by Michael Artes on 26.06.23.
// Copyright © 2023 Schwarz IT KG.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

enum DataViewJs {
static let source = #"""
function isJson(str) {
try { JSON.parse(str) }
catch(e) { return false; }
return true;
}
function makeJSONPretty() {
const code = document.getElementById("code");
const codeText = code.textContent;
if (!isJson(codeText)) return;
const codeJson = JSON.parse(codeText);
const prettyJson = JSON.stringify(codeJson, null, 4);
code.textContent = prettyJson;
}
makeJSONPretty();
hljs.highlightAll();
"""#
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,15 @@ struct DataView: View {
return prettyData
}

private func getFileContents(forResource: String, ofType: String) -> String {
let fileURL = Bundle.ndBundle.path(forResource: forResource, ofType: ofType)!
let fileManager = FileManager.default
let data = fileManager.contents(atPath: fileURL)!
let fileContents = String(data: data, encoding: .utf8)
return fileContents!
}

private func getHtmlContents() -> String {
let css = getFileContents(forResource: "Highlightjs", ofType: "css")
let html = getFileContents(forResource: "DataView", ofType: "html")
let css = HighlightjsCss.source
let html = DataViewHtml.source
return html.replacingOccurrences(of: "{CSS}", with: css)
}

private func getScriptContents() -> String {
let highlightjs = getFileContents(forResource: "Highlightjs", ofType: "js")
let dataView = getFileContents(forResource: "DataView", ofType: "js")
return highlightjs.appending("\n\(dataView)")
let highlightjs = HighlightjsJs.source
let dataViewJs = DataViewJs.source
return highlightjs.appending("\n\(dataViewJs)")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Hightlightjs.css.swift
//
//
// Created by Michael Artes on 26.06.23.
// See license in the LICENSE file of this directory.
//

enum HighlightjsCss {
static let source = #"""
/*!
Theme: Default
Description: Original highlight.js style
Author: (c) Ivan Sagalaev <[email protected]>
Maintainer: @highlightjs/core-team
Website: https://highlightjs.org/
License: see project LICENSE
Touched: 2021
*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}
"""#
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
/*!
Highlight.js v11.5.1 (git: b8f233c8e2)
(c) 2006-2022 Ivan Sagalaev and other contributors
License: BSD-3-Clause
*/
var hljs=function(){"use strict";var e={exports:{}};function n(e){
//
// Hightlightjs.js.swift
//
//
// Created by Michael Artes on 26.06.23.
// See license in the LICENSE file of this directory.
//

enum HighlightjsJs {
static let source = #"""
/*!
Highlight.js v11.5.1 (git: b8f233c8e2)
(c) 2006-2022 Ivan Sagalaev and other contributors
License: BSD-3-Clause
*/
var hljs=function(){"use strict";var e={exports:{}};function n(e){
return e instanceof Map?e.clear=e.delete=e.set=()=>{
throw Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=()=>{
throw Error("set is read-only")
Expand Down Expand Up @@ -1171,3 +1181,6 @@ var hljs=function(){"use strict";var e={exports:{}};function n(e){
const n=e.replace("grmr_","").replace("_","-");je.registerLanguage(n,Ue[e])}
return je}()
;"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs);

"""#
}

0 comments on commit eea2027

Please sign in to comment.