diff --git a/.DS_Store b/.DS_Store index c8fe1962..cdb54b51 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Applications.txt b/Applications.txt index 95fb11c4..9286edc2 100644 --- a/Applications.txt +++ b/Applications.txt @@ -280,6 +280,13 @@ preLoadFile=true, version=1.04, }, + { + name="lib/internet.lua", + url="IgorTimofeev/OpenComputers/master/lib/internet.lua", + type="Library", + preLoadFile=true, + version=1.0, + }, { name="MineOS/System/OS/EFI.lua", url="IgorTimofeev/OpenComputers/master/MineOS/EFI.lua", @@ -589,7 +596,7 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/VK/Icon.pic", createShortcut="dock", - version=1.21, + version=1.22, resources={ { name="VKLogo.pic", @@ -967,14 +974,6 @@ createShortcut="desktop", version=1.01, }, - { - name="MineOS/Applications/Pastebin", - url="IgorTimofeev/OpenComputers/master/Applications/Pastebin/Pastebin.lua", - type="Application", - icon="IgorTimofeev/OpenComputers/master/Applications/Pastebin/Icon.pic", - createShortcut="desktop", - version=1.0, - }, { name="MineOS/Applications/Finder", url="IgorTimofeev/OpenComputers/master/Applications/Finder/Finder.lua", @@ -1150,15 +1149,15 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/Icon.pic", createShortcut="desktop", - version=1.0, + version=1.01, resources={ { name="Russian.lang", - url="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/Russian.lang", + url="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/Localization/Russian.lang", }, { name="English.lang", - url="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/English.lang", + url="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/Localization/English.lang", }, }, }, diff --git a/Applications/.DS_Store b/Applications/.DS_Store index 3812211d..da83ef6b 100644 Binary files a/Applications/.DS_Store and b/Applications/.DS_Store differ diff --git a/Applications/HoloEdit/English.lang b/Applications/HoloEdit/English.lang deleted file mode 100644 index 88b32467..00000000 --- a/Applications/HoloEdit/English.lang +++ /dev/null @@ -1,27 +0,0 @@ -badGPU = [ERROR] Your monitor/GPU doesn't support required resolution. -palette = [ Palette ] -control = [ Control ] -layer = [ Layer ] -level = Hologram level: -mainLevel = Main level: -quit = Exit: 'Q' or -developers = Developers: -contact = Contact -savingFile = Saving file... -loadingFile = Loading file... -attention = [ Attention ] -complete = [ Done! ] -exit = Quit -refresh = Refresh -fromUp = Top -fromFront = Front -fromSide = Side -upper = Upper -lower = Lower -clear = Clear -fill = Fill -toProjector = To projector -save = Save -load = Load -new = New file -enterFileName = Enter file name here: diff --git a/Applications/HoloEdit/HoloEdit.lua b/Applications/HoloEdit/HoloEdit.lua index 377b7a15..dec30a78 100644 --- a/Applications/HoloEdit/HoloEdit.lua +++ b/Applications/HoloEdit/HoloEdit.lua @@ -1,7 +1,9 @@ -- Hologram Editor -- by NEO, Totoro -- 10/14/2014, all right reserved =) +-- райтс, хуяйтс, резервед ЙОПТА +local MineOSCore = require("MineOSCore") local unicode = require('unicode') local event = require('event') local term = require('term') @@ -9,8 +11,7 @@ local fs = require('filesystem') local com = require('component') local gpu = com.gpu -local config = require("config") -local lang = config.readAll("MineOS/Applications/HoloEdit.app/Resources/" .. _OSLANGUAGE .. ".lang") +local lang = MineOSCore.getCurrentApplicationLocalization() -- Константы -- HOLOH = 32 diff --git a/Applications/HoloEdit/Localization/English.lang b/Applications/HoloEdit/Localization/English.lang new file mode 100644 index 00000000..fe0905bc --- /dev/null +++ b/Applications/HoloEdit/Localization/English.lang @@ -0,0 +1,29 @@ +{ + badGPU = "[ERROR] Your monitor/GPU doesn't support required resolution.", + palette = "[ Palette ]", + control = "[ Control ]", + layer = "[ Layer ]", + level = "Hologram level:", + mainLevel = "Main level:", + quit = "Exit: 'Q' or ", + developers = "Developers: ", + contact = "Contact", + savingFile = "Saving file...", + loadingFile = "Loading file...", + attention = "[ Attention ]", + complete = "[ Done! ]", + exit = "Quit", + refresh = "Refresh", + fromUp = "Top", + fromFront = "Front", + fromSide = "Side", + upper = "Upper", + lower = "Lower", + clear = "Clear", + fill = "Fill", + toProjector = "To projector", + save = "Save", + load = "Load", + new = "New file", + enterFileName = "Enter file name here:", +} diff --git a/Applications/HoloEdit/Localization/Russian.lang b/Applications/HoloEdit/Localization/Russian.lang new file mode 100644 index 00000000..5780c77f --- /dev/null +++ b/Applications/HoloEdit/Localization/Russian.lang @@ -0,0 +1,29 @@ +{ + badGPU = "[ОШИБКА] Ваш монитор/видеокарта не поддерживает требуемое разрешение.", + palette = "[ Палитра ]", + control = "[ Управление ]", + layer = "[ Слой ]", + level = "Уровень голограммы:", + mainLevel = "Направляющий уровень:", + quit = "Выход: 'Q' или ", + developers = "Разработчики: ", + contact = "Контакты:", + savingFile = "Сохраняю файл...", + loadingFile = "Загружаю файл...", + attention = "[ Внимание ]", + complete = "[ Файл сохранен! ]", + exit = "Выход", + refresh = "Обновить", + fromUp = "Сверху", + fromFront = "Спереди", + fromSide = "Сбоку", + upper = "Выше", + lower = "Ниже", + clear = "Очистить", + fill = "Залить", + toProjector = "На проектор", + save = "Сохранить", + load = "Загрузить", + new = "Новый файл", + enterFileName = "Введите сюда имя файла", +} diff --git a/Applications/HoloEdit/Russian.lang b/Applications/HoloEdit/Russian.lang deleted file mode 100644 index 29350b03..00000000 --- a/Applications/HoloEdit/Russian.lang +++ /dev/null @@ -1,27 +0,0 @@ -badGPU = [ОШИБКА] Ваш монитор/видеокарта не поддерживает требуемое разрешение. -palette = [ Палитра ] -control = [ Управление ] -layer = [ Слой ] -level = Уровень голограммы: -mainLevel = Направляющий уровень: -quit = Выход: 'Q' или -developers = Разработчики: -contact = Контакты: -savingFile = Сохраняю файл... -loadingFile = Загружаю файл... -attention = [ Внимание ] -complete = [ Файл сохранен! ] -exit = Выход -refresh = Обновить -fromUp = Сверху -fromFront = Спереди -fromSide = Сбоку -upper = Выше -lower = Ниже -clear = Очистить -fill = Залить -toProjector = На проектор -save = Сохранить -load = Загрузить -new = Новый файл -enterFileName = Введите сюда имя файла diff --git a/Applications/Pastebin/Pastebin.lua b/Applications/Pastebin/Pastebin.lua index 965a29db..c0e2a039 100644 --- a/Applications/Pastebin/Pastebin.lua +++ b/Applications/Pastebin/Pastebin.lua @@ -1,3 +1,4 @@ +require("advancedLua") local component = require("component") local event = require("event") local term = require("term") @@ -8,7 +9,6 @@ local shell = require("shell") local internet = require("internet") local context = require("context") local xml = require("xmlParser") -local config = require("config") local unixtime = require("unixtime") local SHA2 = require("SHA2") -- local computer = require("computer") @@ -332,7 +332,7 @@ end local function analyseConfig() if fs.exists(pathToConfig) then - local massiv = config.readAll(pathToConfig) + local massiv = table.fromFile(pathToConfig) username = massiv.username password = massiv.password massiv = nil @@ -340,8 +340,7 @@ local function analyseConfig() fs.makeDirectory(fs.path(pathToConfig)) local success = inputPassword() if not success then return false end - config.write(pathToConfig, "username", username) - config.write(pathToConfig, "password", password) + table.toFile(pathToConfig, {username = username, password = password}) end return true diff --git a/Applications/VK/IMG_3226.jpg b/Applications/VK/IMG_3226.jpg deleted file mode 100644 index 8137457c..00000000 Binary files a/Applications/VK/IMG_3226.jpg and /dev/null differ diff --git a/Applications/VK/IMG_3229.jpg b/Applications/VK/IMG_3229.jpg deleted file mode 100644 index 51a59c14..00000000 Binary files a/Applications/VK/IMG_3229.jpg and /dev/null differ diff --git a/Applications/VK/VK.lua b/Applications/VK/VK.lua index 1c4c5d1b..5e7b77c3 100644 --- a/Applications/VK/VK.lua +++ b/Applications/VK/VK.lua @@ -6,6 +6,7 @@ local json = require("json") local serialization = require("serialization") local event = require("event") local ecs = require("ECSAPI") +local internet = require("internet") local fs = require("filesystem") local buffer = require("doubleBuffering") local context = require("context") @@ -143,7 +144,7 @@ end --Банальный URL-запрос, декодирующийся через ЖУСОН в случае успеха, епты local function request(url) - local success, response = ecs.internetRequest(url) + local success, response = internet.request(url, true) if success then response = json:decode(response) end return success, response end diff --git a/lib/MineOSCore.lua b/lib/MineOSCore.lua index f7ca11cb..14722937 100755 --- a/lib/MineOSCore.lua +++ b/lib/MineOSCore.lua @@ -68,6 +68,43 @@ end ----------------------------------------------------------------------------------------------------------------------------------- +local function getFilenameAndFormat(path) + local fileName, format = string.match(path, "^(.+)(%..+)$") + return fileName or path, format and string.gsub(format, "/", "") or nil +end + +local function getFilePathAndName(path) + local filePath, fileName = string.math(path, "^(.+%/)(.+)$") + return filePath or "/", fileName or path +end + +function MineOSCore.getFileFormat(path) + local fileName, format = getFilenameAndFormat(path) + return format +end + +function MineOSCore.hideFileFormat(path) + local fileName, format = getFilenameAndFormat(path) + return fileName +end + +function MineOSCore.getFileName(path) + local filePath, fileName = getFilePathAndName(path) + return fileName +end + +function MineOSCore.getFilePath(path) + local filePath, fileName = getFilePathAndName(path) + return filePath +end + +function MineOSCore.isFileHidden(path) + if string.match(path, "^%..+$") then return true end + return false +end + +----------------------------------------------------------------------------------------------------------------------------------- + function MineOSCore.loadIcon(name, path) if not MineOSCore.icons[name] then MineOSCore.icons[name] = image.load(path) end return MineOSCore.icons[name] @@ -98,7 +135,8 @@ end --Отрисовка одной иконки function MineOSCore.drawIcon(x, y, path, showFileFormat, nameColor, name) - local fileFormat, icon = ecs.getFileFormat(path) + local fileFormat = MineOSCore.getFileFormat(path) + local icon if fs.isDirectory(path) then if fileFormat == ".app" then @@ -191,11 +229,11 @@ local function drawErrorWindow(path, programVersion, errorLine, reason, showSend -- Окошечко и всякая шняжка на нем local window = require("windows").empty(x, y, width, height, width, height) - window:addPanel("topBar", 1, 1, width, 3, colors.topBar) - window:addLabel("title", 1, 2, width, 1, colors.title, programName):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) - local windowActionButtons = window:addWindowActionButtons("windowActionButtons", 2, 2, false) - local sendToDeveloperButton = window:addAdaptiveButton("sendToDeveloperButton", 9, 1, 2, 1, 0x444444, 0xFFFFFF, 0x343434, 0xFFFFFF, MineOSCore.localization.sendFeedback) - local stackTextBox = window:addTextBox("stackTextBox", codeWidth + 1, 4, stackWidth, codeHeight, 0xFFFFFF, 0x000000, string.wrap(MineOSCore.parseErrorMessage(reason, 4), stackWidth - 2), 1, 1, 0) + window:addPanel(1, 1, width, 3, colors.topBar) + window:addLabel(1, 2, width, 1, colors.title, programName):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) + local windowActionButtons = window:addWindowActionButtons(2, 2, false) + local sendToDeveloperButton = window:addAdaptiveButton(9, 1, 2, 1, 0x444444, 0xFFFFFF, 0x343434, 0xFFFFFF, MineOSCore.localization.sendFeedback) + local stackTextBox = window:addTextBox(codeWidth + 1, 4, stackWidth, codeHeight, 0xFFFFFF, 0x000000, string.wrap(MineOSCore.parseErrorMessage(reason, 4), stackWidth - 2), 1, 1, 0) --Рисуем окошечко, чтобы кодику не было ОБИДНО --!!1 window:draw() diff --git a/lib/internet.lua b/lib/internet.lua new file mode 100755 index 00000000..9be97857 --- /dev/null +++ b/lib/internet.lua @@ -0,0 +1,57 @@ + +----------------------------------------- Libraries ----------------------------------------- + +local fs = require("filesystem") +local internetComponent = require("component").internet +local internet = {} + +----------------------------------------- Main methods ----------------------------------------- + +--Адекватный запрос к веб-серверу вместо стандартного Internet API, бросающего stderr, когда ему вздумается +function internet.request(url, readResponse) + local success, response = pcall(internetComponent, url) + + if readResponse then + if success then + local responseData = "" + while true do + local data, responseChunk = response.read() + if data then + responseData = responseData .. data + else + if responseChunk then + return false, responseChunk + else + return true, responseData + end + end + end + else + return false, reason + end + end +end + +--Загрузка файла с инета +function internet.downloadFile(url, path) + local success, response = internet.request(url, true) + if success then + fs.makeDirectory(fs.path(path) or "") + local file = io.open(path, "w") + file:write(response) + file:close() + else + error("Could not connect to to URL address \"" .. url .. "\", the reason is \"" .. response .. "\"") + return + end +end + + +------------------------------------------------------------------------------------------- + +return internet + + + + +