Skip to content

feature/documents#25

Merged
tomhula merged 7 commits into
tomhula:mainfrom
Stevekk11:feature/documents
Apr 21, 2026
Merged

feature/documents#25
tomhula merged 7 commits into
tomhula:mainfrom
Stevekk11:feature/documents

Conversation

@Stevekk11
Copy link
Copy Markdown
Contributor

Add the ability to fetch and parse the school documents, subfolders, and files. Example usage:
runBlocking {
val client = JecnaClient()
client.login(username, password)
val visited = mutableSetOf()

        suspend fun walk(path: String, depth: Int = 0) {
            if (!visited.add(path)) return

            val page = client.getDocumentsPage(path)
            val indent = "  ".repeat(depth)

            println("${indent}PATH: ${page.path}")

            for (document: SchoolDocument in page.documents) {
                when (document) {
                    is DocumentFolder -> {
                        println("${indent}[DIRECTORY] ${document.label} -> ${document.path}")
                        walk(document.path, depth + 1)
                    }
                    is DocumentFile -> {
                        println("${indent}[FILE] ${document.label} -> ${document.downloadPath}")
                    }
                }
            }
        }
        walk("/dokumenty/")
    }

@Stevekk11 Stevekk11 changed the title Add documents. feature/documents Apr 8, 2026
Copy link
Copy Markdown
Contributor

@jzitnik-dev jzitnik-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also can't just ignore the .. page but in the DocumentsPage class add something like parentPath that would include the path of the parent folder, so then in the UI you can navigate back normally as expected without needing to explicitly track your path history.

Comment thread src/commonMain/kotlin/io/github/tomhula/jecnaapi/WebJecnaClient.kt
Comment thread src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/document/SchoolDocument.kt Outdated
@Stevekk11
Copy link
Copy Markdown
Contributor Author

Thanks for review, will fix tommorow.

@Stevekk11
Copy link
Copy Markdown
Contributor Author

Fixed it.

@tomhula
Copy link
Copy Markdown
Owner

tomhula commented Apr 9, 2026

Btw please write better commit names. Once you are making a PR, they aren't just your no-one-cares commit messages, but they are merged into the project.

Copy link
Copy Markdown
Contributor

@jzitnik-dev jzitnik-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like how the elements in the page are getting parsed twice using the select function for the parent folder, due to performance (select has to go thru all the elements in the page to see if it matches the css selector), but it makes the code look cleaner with the .mapNotNull { parseDocument(it) }.

The thing I personally hate is assuming the first folder will be the parent dir. Obv it would make sense but I think way better approach would be to go through all the files and folders just once, and instead of skipping the ".." (as you did before) just setting the parentPath in it yk. So you eliminate going through all the documents and folders twice and you also eliminate the possibility if the parent folder isn't the first folder in the HTML tree.

Copy link
Copy Markdown
Contributor

@jzitnik-dev jzitnik-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now

@Stevekk11
Copy link
Copy Markdown
Contributor Author

Ready to merge?

@tomhula
Copy link
Copy Markdown
Owner

tomhula commented Apr 13, 2026

I haven't reviewed the code yet, so no

@Stevekk11
Copy link
Copy Markdown
Contributor Author

Is Jakub a code reviewer or not? If no, it would make sense.

@tomhula
Copy link
Copy Markdown
Owner

tomhula commented Apr 13, 2026

No, but maybe he could be.

@jzitnik-dev
Copy link
Copy Markdown
Contributor

My review was just my personal opinion xd. Final word is on @tomhula.

@tomhula tomhula self-requested a review April 21, 2026 08:25
@tomhula tomhula merged commit e77b3fd into tomhula:main Apr 21, 2026
1 check passed
@Stevekk11 Stevekk11 deleted the feature/documents branch April 21, 2026 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants