npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zborovna-api

v0.0.6

Published

Simple API for zborovna

Downloads

7

Readme

Zborovna API

This is an unofficial Zborovna API.

If you find bugs, have any questions or suggestions for features, please let me know and submit an issue.

Contents

Requirements

  • Node.js v14.0.0+
  • Zborovna Account

installation

npm i zborovna-api

Usage

const { Zborovna } = require("zborovna-api");

const zborovna = new Zborovna();

// This wil grant you access to all basic methods
zborovna.login("username", "password").then(user => {
    // ('user') is holding all methods for Documents and User
}).catch(error => {
    // Catch errors
});
// You can access all methods using ('zborovna') like this
(async () => {
  await zborovna.login("username", "password");
  const user = zborovna.user;
})();

Examples

Note: If your node.js version support top level await you don't need to use self invoking arrow function

Get first documents from document library

const { Zborovna } = require("zborovna-api");

const zborovna = new Zborovna();

(async () => {
  await zborovna.login("username", "password");

  // This will return parsed documents
  const documents = await zborovna.basePage();

  console.log(documents);
})();

Set files saving location

const { Zborovna } = require("zborovna-api");
const path = require("path");
const zborovna = new Zborovna();

(async () => {
  await zborovna.login("username", "password");

  const location = path.join(__dirname, "./files/");
  // This will set where your files should save
  zborovna.setLocation(location);

  console.log(zborovna.location);
})();

Get local file by id

This will give you local file instead of downloading from server.

const { Zborovna } = require("zborovna-api");

const zborovna = new Zborovna();

(async () => {
  await zborovna.login("username", "password");

  // Return an object with FileName & FileLocation & FileFormat
  const file = await zborovna.getLocalFile(id);

  console.log(file);
})();

Get File from server

This will download file from server, but if file already exist it will just return an object.

const { Zborovna } = require("zborovna-api");

const zborovna = new Zborovna();

(async () => {
  await zborovna.login("username", "password");

  // This will return an object with FileName & FileLocation & FileFormat
  // And also save your file to your file location
  const file = await zborovna.getServerFile(id);

  console.log(file);
})();

Get documents by query

const { Zborovna } = require("zborovna-api");

const zborovna = new Zborovna();

(async () => {
  await zborovna.login("username", "password");

  // This params are optional so you don't need to pass everything.
  // Note: Search is value is for searching document you want.
  const queryObject = { school, subject, year, post, filter, search, page };
  const documents = await zborovna.getDocumentsByQuery(queryObject);

  console.log(documents);
})();

Get user messages

const { Zborovna } = require("zborovna-api");

const zborovna = new Zborovna();

(async () => {
  await zborovna.login("username", "password");

  const messages = await zborovna.user.getMessages(/*Page number: default 0*/);
  const latestPage = messages.pageCount; // This will return last possible number for ('Page Number')

  console.log(messages);
})();

Get message context

const { Zborovna } = require("zborovna-api");

const zborovna = new Zborovna();

(async () => {
  await zborovna.login("username", "password");

  const messages = await zborovna.user.getMessages(/*Page number: default 0*/);
  // This will return context of first message
  const MessageCtx = await zborovna.user.getContextOfMessage(messages.data[0]);
  messages.data.forEach(async msg => {
    const MsgCtx = await zborovna.user.getContextOfMessage(msg);
    console.log(MsgCtx);
  });
})();

API

ParsedDocument

This object holds parsed data from server

interface parsedHTMLDocument {
  documentID: number;
  documentName: string;
  documentThumbnail: string;
  documentSubject: string;
  documentClassYear: string;
  documentAddition: string;
  pageCount: number;
}

GetMessages Interface

interface requestedMessages {
  currentPage: number;
  pageCount: number;
  messageCount: number;
  data: Array<parsedMessage>;
}

interface parsedMessage {
  name: string;
  type: string;
  subject: string;
  hasAttachment: boolean;
  messageURL: string;
  receivedAt: string;
}

Message Context Interface

interface messageCtx {
  from: string;
  userBlockURL: string;
  subject: string;
  date: string;
  messages: string | Array<iMessages>;
}

interface iMessages {
  profileImageURL: string;
  message: Array<string>;
  _raw: string;
}

queryObject

Note: I didn't make these key values it's based on original zborovna choose. Each value is specific and is used for representation.

These are possible value for each queryObject key.

School

schools = {
  zakladna_skola: 1,
  stredna_skola: 2,
  materska_skola: 3,
  umelecka_skola: 4,
  ine: 5,
  specialna_skola: 6,
};

Example

const school = 1; // Základná škola
const queryObject = { school, ...};
const documents = await zborovna.getDocumentsByQuery(queryObject);

Subject

General subjects

generalSubjects = {
    'r1'= 'Matematika',
    'r2'= 'Fyzika',
    'r3'= 'Slovenský jazyk a literatúra',
    'r4'= 'Geografia',
    'r5'= 'Hudobná výchova',
    'r7'= 'Biológia',
    'r8'= 'Dejepis',
    'r9'= 'Vlastiveda',
    'r10' = 'Informatická výchova',
    'r11' = 'Prírodoveda',
    'r12' = 'Etická výchova',
    'r13' = 'Náboženská výchova',
    'r14' = 'Pracovné vyučovanie',
    'r15' = 'Výtvarná výchova',
    'r16' = 'Telesná výchova',
    'r17' = 'Informatika',
    'r18' = 'Chémia',
    'r19' = 'Občianska náuka',
    'r20' = 'Svet práce',
    'r21' = 'Technika',
    'r22' = 'Výchova umením',
    'r23' = 'Anglický jazyk',
    'r24' = 'Nemecký jazyk',
    'r25' = 'Francúzsky jazyk',
    'r26' = 'Ruský jazyk',
    'r27' = 'Španielsky jazyk',
    'r28' = 'Triednictvo',
    'r29' = 'Všeobecné',
    'r30' = 'Špeciálna pedagogika',
    'r31' = 'Školský klub detí',
    'r32' = 'Maďarský jazyk a literatúra',
    'r34' = 'Obohatenie',
    'r35' = 'Dopravná výchova',
    'r36' = 'Taliansky jazyk',
    'r37' = 'Ekológia',
    'r38' = 'Prvouka',
    'r39' = 'Finančná Gramotnosť',
    'r40' = 'Rusínsky jazyk',
}

High school subjects

// This subjects are for high school
subjects = {
    's1' = 'Ekonomické predmety',
    's2' = 'Technické predmety',
    's3' = 'Spoločenské predmety',
    's4' = 'Predmety z oblasti služieb',
    's5' = 'Umelecké predmety',
    's6' = 'Zdravotnícke predmety',
    's7' = 'Poľnohospodárske a potravinárske predmety',
    's8' = 'Prírodné predmety',
}

Example

const subject = 'r10'; // Informatická výchova
const queryObject = { subject, ...};
const documents = await zborovna.getDocumentsByQuery(queryObject);

Posts

posts = {
    '1' = 'Dokument',
    '2' = 'Link',
    '3' = 'Galéria',
    '4' = 'Test',
}

Example

const post = 'r10'; // Dokument
const queryObject = { post, ...};
const documents = await zborovna.getDocumentsByQuery(queryObject);

Filter

filters = {
    'listing_kvalitne' = 'Kvalitné', // Default value
    'listing_najnovsie' = 'Všetky',
    'listing_autorske' = 'Autorské',
    'listing_najlepsie' = 'Najlepšie',
    'listing_archiv' = 'Stiahnuté',
    'listing_friends' = 'Obľúbenci',
    'listing_metodicke' = 'Metodické',
}

Example

const filter = 'listing_autorske'; // Autorské
const queryObject = { filter, ...};
const documents = await zborovna.getDocumentsByQuery(queryObject);