-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/#152 인스타그램 이미지 조회 문제 수정 #155
Merged
+763
−183
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e209baa
[feat] #152 SwiftSoupClient 로직 변경
ShapeKim98 1b20696
[chore] #152 이미지 user agent Request 제거
ShapeKim98 c2cfe66
[feat] #152 FeatureContentCard 모듈 생성
ShapeKim98 dedaed8
[feat] #152 ContentCard 기능 추가
ShapeKim98 73be64b
[feat] #152 CotnentList에 ContentCard 적용
ShapeKim98 ed9bb34
[fix] #152 ContentList 컨텐츠 삭제 반영 문제 수정
ShapeKim98 3febfb5
[feat] #152 CategpryDetail에 ContentCard 적용
ShapeKim98 fb0c910
[feat] #152 CategorySharing에 ContentCard 적용
ShapeKim98 3bb4158
[fix] #152 CategorySharing에서 컨텐츠 상세보기 링크 파싱 문제 수정
ShapeKim98 66ff07a
[feat] #152 PokitRoot에 ContentCard 적용
ShapeKim98 95aa852
[chore] #152 FeatureSetting에 FeatureContentCard 의존성 연결
ShapeKim98 3aa29e4
[feat] #152 SearchFeature에 ContentCard 적용
ShapeKim98 43af441
[feat] #152 FeatureRemind에 썸네일 url 조회 로직 추가
ShapeKim98 2931e25
[fix] #152 일부 컴포넌트의 썸네일 비율 수정
ShapeKim98 70b704f
[chore] #152 FeatureRemind에 FeatureContentCard 의존성 제거
ShapeKim98 0a593a0
[refactor] #152 SwiftSoupProvider 로직 수정
ShapeKim98 1375cc9
[fix] #152 피드백 반영
ShapeKim98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Projects/CoreKit/Sources/Data/Client/SwiftSoupClient/SwiftSoupProvider.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// SwiftSoupProvider.swift | ||
// CoreKit | ||
// | ||
// Created by 김도형 on 11/17/24. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftSoup | ||
|
||
final class SwiftSoupProvider { | ||
func parseOGTitle(_ url: URL) async throws -> String? { | ||
try await parseOGMeta(url: url, type: "og:title") | ||
} | ||
|
||
func parseOGImageURL(_ url: URL) async throws -> String? { | ||
try await parseOGMeta(url: url, type: "og:image") | ||
} | ||
|
||
func parseOGMeta(url: URL, type: String) async throws -> String? { | ||
let html = try String(contentsOf: url) | ||
let document = try SwiftSoup.parse(html) | ||
|
||
if let metaData = try document.select("meta[property=\(type)]").first()?.attr("content") { | ||
return metaData | ||
} else { | ||
var request = URLRequest(url: url) | ||
request.setValue( | ||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36", | ||
forHTTPHeaderField: "User-Agent" | ||
) | ||
|
||
let (data, _) = try await URLSession.shared.data(for: request) | ||
guard let html = String(data: data, encoding: .utf8) else { | ||
return nil | ||
} | ||
let document = try SwiftSoup.parse(html) | ||
let metaData = try document.select("meta[property=\(type)]").first()?.attr("content") | ||
|
||
return metaData | ||
} | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import Foundation | ||
|
||
import ComposableArchitecture | ||
import FeatureContentCard | ||
import Domain | ||
import CoreKit | ||
import DSKit | ||
|
@@ -51,16 +52,7 @@ public struct CategoryDetailFeature { | |
} | ||
return identifiedArray | ||
} | ||
var contents: IdentifiedArrayOf<BaseContentItem>? { | ||
guard let contentList = domain.contentList.data else { | ||
return nil | ||
} | ||
var identifiedArray = IdentifiedArrayOf<BaseContentItem>() | ||
contentList.forEach { content in | ||
identifiedArray.append(content) | ||
} | ||
return identifiedArray | ||
} | ||
var contents: IdentifiedArrayOf<ContentCardFeature.State> = [] | ||
Comment on lines
-54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. �굿굿! |
||
var kebobSelectedType: PokitDeleteBottomSheet.SheetType? | ||
var selectedContentItem: BaseContentItem? | ||
var shareSheetItem: BaseContentItem? = nil | ||
|
@@ -73,6 +65,7 @@ public struct CategoryDetailFeature { | |
var hasNext: Bool { | ||
domain.contentList.hasNext | ||
} | ||
var isLoading: Bool = true | ||
|
||
public init(category: BaseCategoryItem) { | ||
self.domain = .init(categpry: category) | ||
|
@@ -86,6 +79,7 @@ public struct CategoryDetailFeature { | |
case async(AsyncAction) | ||
case scope(ScopeAction) | ||
case delegate(DelegateAction) | ||
case contents(IdentifiedActionOf<ContentCardFeature>) | ||
|
||
@CasePathable | ||
public enum View: BindableAction, Equatable { | ||
|
@@ -121,10 +115,11 @@ public struct CategoryDetailFeature { | |
case 클립보드_감지 | ||
} | ||
|
||
public enum ScopeAction: Equatable { | ||
public enum ScopeAction { | ||
case categoryBottomSheet(PokitBottomSheet.Delegate) | ||
case categoryDeleteBottomSheet(PokitDeleteBottomSheet.Delegate) | ||
case filterBottomSheet(CategoryFilterSheet.Delegate) | ||
case contents(IdentifiedActionOf<ContentCardFeature>) | ||
} | ||
|
||
public enum DelegateAction: Equatable { | ||
|
@@ -163,13 +158,19 @@ public struct CategoryDetailFeature { | |
/// - Delegate | ||
case .delegate(let delegateAction): | ||
return handleDelegateAction(delegateAction, state: &state) | ||
|
||
case .contents(let contentsAction): | ||
return .send(.scope(.contents(contentsAction))) | ||
} | ||
} | ||
|
||
/// - Reducer body | ||
public var body: some ReducerOf<Self> { | ||
BindingReducer(action: \.view) | ||
Reduce(self.core) | ||
.forEach(\.contents, action: \.contents) { | ||
ContentCardFeature() | ||
} | ||
} | ||
} | ||
//MARK: - FeatureAction Effect | ||
|
@@ -191,7 +192,7 @@ private extension CategoryDetailFeature { | |
case .카테고리_선택했을때(let item): | ||
state.domain.category = item | ||
return .run { send in | ||
await send(.inner(.pagenation_초기화)) | ||
await send(.inner(.pagenation_초기화), animation: .pokitDissolve) | ||
await send(.async(.카테고리_내_컨텐츠_목록_조회_API)) | ||
await send(.inner(.카테고리_선택_시트_활성화(false))) | ||
} | ||
|
@@ -248,10 +249,17 @@ private extension CategoryDetailFeature { | |
|
||
case .카테고리_내_컨텐츠_목록_조회_API_반영(let contentList): | ||
state.domain.contentList = contentList | ||
|
||
var identifiedArray = IdentifiedArrayOf<ContentCardFeature.State>() | ||
contentList.data?.forEach { identifiedArray.append(.init(content: $0)) } | ||
state.contents = identifiedArray | ||
|
||
state.isLoading = false | ||
return .none | ||
|
||
case let .컨텐츠_삭제_API_반영(id): | ||
state.domain.contentList.data?.removeAll { $0.id == id } | ||
state.contents.removeAll { $0.content.id == id } | ||
state.domain.category.contentCount -= 1 | ||
state.selectedContentItem = nil | ||
state.isPokitDeleteSheetPresented = false | ||
|
@@ -264,11 +272,15 @@ private extension CategoryDetailFeature { | |
|
||
state.domain.contentList = contentList | ||
state.domain.contentList.data = list + newList | ||
newList.forEach { state.contents.append(.init(content: $0)) } | ||
|
||
return .none | ||
|
||
case .pagenation_초기화: | ||
state.domain.pageable.page = 0 | ||
state.domain.contentList.data = nil | ||
state.isLoading = true | ||
state.contents.removeAll() | ||
return .none | ||
} | ||
} | ||
|
@@ -459,6 +471,15 @@ private extension CategoryDetailFeature { | |
.send(.async(.카테고리_내_컨텐츠_목록_조회_API)) | ||
) | ||
} | ||
|
||
case let .contents(.element(id: _, action: .delegate(.컨텐츠_항목_눌렀을때(content)))): | ||
return .send(.delegate(.contentItemTapped(content))) | ||
case let .contents(.element(id: _, action: .delegate(.컨텐츠_항목_케밥_버튼_눌렀을때(content)))): | ||
state.kebobSelectedType = .링크삭제 | ||
state.selectedContentItem = content | ||
return .send(.inner(.카테고리_시트_활성화(true))) | ||
case .contents: | ||
return .none | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provider 분리하니까 훨낫네요 뷰에 저 코드들 있던것으로 기억하는데 잘 뺀듯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다