From 6d5c51d0e5b8df6c2797b8237e3a46a7b153e798 Mon Sep 17 00:00:00 2001 From: Iam Naughton Phier Date: Thu, 26 Mar 2015 18:15:38 +0200 Subject: [PATCH 01/36] indentation fix, start of changing font in editor --- editor/sahliedit.css | 143 +++++++++- editor/sahliedit.litcoffee | 538 ++++++++++++++++++------------------- editor/sahlieditor.html | 9 +- 3 files changed, 411 insertions(+), 279 deletions(-) diff --git a/editor/sahliedit.css b/editor/sahliedit.css index 3821a74..f9f3361 100644 --- a/editor/sahliedit.css +++ b/editor/sahliedit.css @@ -17,7 +17,7 @@ textarea { } pre { - font-family: 'TopazPlus a500a1000a2000','mOsOul',Monaco,monospace; + font-family: 'topaz500','mosoul',Monaco,monospace; font-size: 16; border: 2px inset #808080; } @@ -56,12 +56,14 @@ div ul li{ display: inline-block; } -# this does not actually change anything because the design is set by -# the jquery-ui bit. Altering in the script does work. Here for reference. +/* this does not actually change anything because the design is set by */ +/* the jquery-ui bit. Altering in the script does work. Here for reference. */ +/* .45box { width: 45%; display: inline-block; } +*/ div.groupbox p { margin: .25 ex; @@ -79,7 +81,7 @@ div.groupbox p { } #sahlioutput { - font-family: 'TopazPlus a500a1000a2000','mOsOul',Monaco,monospace; + font-family: 'microknight','P0t-nOodle',Monaco,monospace; font-size: 16; background: aliceblue; overflow-wrap: break-word; @@ -95,4 +97,135 @@ div.groupbox p { margin: 0px 0px 1ex; padding: 0px; -} \ No newline at end of file +} + +@font-face { + font-family: 'P0t-nOodle'; + src: url('fonts/P0T-NOoDLE_v1.0.woff2') format('woff2'); + src: url('fonts/P0T-NOoDLE_v1.0.woff') format('woff'); +} + +@font-face { + font-family: 'MicroKnight'; + src: url('fonts/MicroKnightPlus_v1.0.woff2') format('woff2'); + src: url('fonts/MicroKnightPlus_v1.0.woff') format('woff'); +} + +@font-face { + font-family: 'mOsOul'; + src: url('fonts/mOsOul_v1.0.woff2') format('woff2'); + src: url('fonts/mOsOul_v1.0.woff') format('woff'); +} + +@font-face { + font-family: 'Topaz1200'; + src: url('fonts/TopazPlusA1200.woff') format('woff2'); + src: url('fonts/TopazPlusA1200.woff') format('woff'); +} + +@font-face { + font-family: 'Topaz500'; + src: url('fonts/TopazPlusA500.woff2') format('woff2'); + src: url('fonts/TopazPlusA500.woff') format('woff'); +} + +@font-face { + font-family: 'blockzone'; + src: url('fonts/BlockZone.woff2') format('woff2'); + src: url('fonts/BlockZone.woff') format('woff'); +} + +.mosoul { + font-family: mOsOul; + text-align: left; +} + +.pot-noodle , .p0t-noodle { + font-family: 'P0t-nOodle'; + text-align: left; +} + +.topaz, .topaz500 { + font-family: 'Topaz500'; + text-align: left; +} + +.propaz, .topaz1200 { + font-family: 'Topaz1200'; + text-align: left; +} + +.microknight, .microknightplus { + font-family: 'MicroKnight'; + text-align: left; +} + +.blockzone, .pcansifont { + font-family: 'blockzone'; + text-align: left; +} +@font-face { + font-family: 'P0t-nOodle'; + src: url('../fonts/P0T-NOoDLE_v1.0.woff2') format('woff2'); + src: url('../fonts/P0T-NOoDLE_v1.0.woff') format('woff'); +} + +@font-face { + font-family: 'MicroKnight'; + src: url('../fonts/MicroKnightPlus_v1.0.woff2') format('woff2'); + src: url('../fonts/MicroKnightPlus_v1.0.woff') format('woff'); +} + +@font-face { + font-family: 'mOsOul'; + src: url('../fonts/mOsOul_v1.0.woff2') format('woff2'); + src: url('../fonts/mOsOul_v1.0.woff') format('woff'); +} + +@font-face { + font-family: 'Topaz1200'; + src: url('../fonts/TopazPlusA1200.woff') format('woff2'); + src: url('../fonts/TopazPlusA1200.woff') format('woff'); +} + +@font-face { + font-family: 'Topaz500'; + src: url('../fonts/TopazPlusA500.woff2') format('woff2'); + src: url('../fonts/TopazPlusA500.woff') format('woff'); +} + +@font-face { + font-family: 'blockzone'; + src: url('../fonts/BlockZone.woff2') format('woff2'); + src: url('../fonts/BlockZone.woff') format('woff'); +} + +.mosoul { + font-family: mOsOul; + text-align: left; +} + +.pot-noodle , .p0t-noodle { + font-family: 'P0t-nOodle'; + text-align: left; +} + +.topaz, .topaz500 { + font-family: 'Topaz500'; + text-align: left; +} + +.propaz, .topaz1200 { + font-family: 'Topaz1200'; + text-align: left; +} + +.microknight, .microknightplus { + font-family: 'MicroKnight'; + text-align: left; +} + +.blockzone, .pcansifont { + font-family: 'blockzone'; + text-align: left; +} diff --git a/editor/sahliedit.litcoffee b/editor/sahliedit.litcoffee index 412b89c..7341dae 100644 --- a/editor/sahliedit.litcoffee +++ b/editor/sahliedit.litcoffee @@ -41,37 +41,39 @@ Create buttos to choose between the New and Load functionalities Also hide the editor until needed, and initialize some elements. $(-> - $("#newsahli") - .button { disabled: false} - .click -> newsahli() - ) + $("#newsahli") + .button { disabled: false} + .click -> newsahli() + ) $(-> - $("#loadsahli") - .button { disabled: false} - .click -> loadsahli() - ) + $("#loadsahli") + .button { disabled: false} + .click -> loadsahli() + ) + $(-> - $(".hidden").hide() - $("#entryamiga").button {icons: {primary:"ui-icon-gear"}} - .click -> - stuff = $(@).children() - if @.value == "1" - stuff[1].textContent = 'Ansi' - @.value = "0" - else - stuff[1].textContent = 'Ascii' - @.value = "1" - $(".45box").css {width:'45%',display:'inline-block'} - $(".groupbox p").css {margin:"0 0 .25em 0"} - $(".colorbox").change => - sahlicolor() - - $("#entryfilepick").change -> - if @.files[0]? then $("#entryfile").val @.files[0].name - $("#entryfile").click -> - $("#entryfilepick").click() + $(".hidden").hide() + $("#entryamiga").button {icons: {primary:"ui-icon-gear"}} + .click -> + stuff = $(@).children() + if @.value == "1" + stuff[1].textContent = 'Ansi' + @.value = "0" + else + stuff[1].textContent = 'Ascii' + @.value = "1" + $(".45box").css {width:'45%',display:'inline-block'} + $(".groupbox p").css {margin:"0 0 .25em 0"} + $(".colorbox").change -> + sahlicolor() + $("#entryfont").change -> + $('pre').css 'font-family',$('#entryfont').val() + $("#entryfilepick").change -> + if @.files[0]? then $("#entryfile").val @.files[0].name + $("#entryfile").click -> + $("#entryfilepick").click() ) The sahli file definition format is as follows: @@ -85,331 +87,327 @@ The three remaining lines are informational and optional. The slide format is currently unused, but consists of a background picture, a html template, and a css file. - class emptyfiledef - constructor: -> - @file = "" - @name = "" - @amiga = true - @filetype = 'plain' - @width = "" - @author = "" - @font = "Propaz" - @color = [ 255,255,255,255 ] - @bg = [ 0,0,0,0 ] - @line1 = "" - @line2 = "" - @text = "" + class Emptyfiledef + constructor: -> + @file = "" + @name = "" + @amiga = true + @filetype = 'plain' + @width = "" + @author = "" + @font = "Propaz" + @color = [ 255,255,255,255 ] + @bg = [ 0,0,0,0 ] + @line1 = "" + @line2 = "" + @text = "" class Sahli - constructor: -> - @emptyfiledef = new emptyfiledef - @emptyslidesdef = { - "background": "", - "template": "", - "css": "" - } - @empty = { - "location": "", - "slides": @emptyslidesdef, - "filedata": [ ] - } + constructor: -> + @emptyfiledef = new Emptyfiledef + @emptyslidesdef = { + "background": "", + "template": "", + "css": "" + } + @empty = { + "location": "", + "slides": @emptyslidesdef, + "filedata": [ ] + } - loader: -> - $.ajax { - url: '../list.sahli', - dataType: "json", - success: (result) => - @data = result - @.edit() - } + loader: -> + $.ajax { + url: '../list.sahli', + dataType: "json", + success: (result) => + @data = result + @.edit() + } Editor functionality: Close the new/load buttons - unneeded now. list, and allow dragon-droppings for sorting. Doubleclick to edit, or use edit button. - edit: -> - $('#buttonbox').hide() - $('#dirlocation').change (event) => - @data.location = event.target.value - $('#listsave').button {icons: {primary:"ui-icon-disk"}} - .click => - $('#sahlioutput').text dumpjson @data - $('#dumparea').show 100 - console.log dumpjson @data - $('#listlist').button {icons: {primary:"ui-icon-folder-open"}} - .click -> - getfilelist() - $('#listappend').button {icons: {primary:"ui-icon-1-n"}} - .click (event) => - newentry = new emptyfiledef - @data.filedata.push newentry - @buildlist @data - $('#listdisplay').button {icons: {primary:"ui-icon-refresh"}} - .click => - @buildlist @data + edit: -> + $('#buttonbox').hide() + $('#dirlocation').change (event) => + @data.location = event.target.value + $('#listsave').button {icons: {primary:"ui-icon-disk"}} + .click => + $('#sahlioutput').text dumpjson @data + $('#dumparea').show 100 + console.log dumpjson @data + $('#listlist').button {icons: {primary:"ui-icon-folder-open"}} + .click -> + getfilelist() + $('#listappend').button {icons: {primary:"ui-icon-1-n"}} + .click (event) => + newentry = new Emptyfiledef + @data.filedata.push newentry + @buildlist @data + $('#listdisplay').button {icons: {primary:"ui-icon-refresh"}} + .click => + @buildlist @data - $('#closespan').click -> - $(@parentElement.parentElement).hide() - $('#sahlioutput').text '' + $('#closespan').click -> + $(@parentElement.parentElement).hide() + $('#sahlioutput').text '' You need to save the order, and extract these in that order; moving around does not alter the array. Alternately, _have_ it alter the array. - @buildlist @data + @buildlist @data - buildlist: (data) -> - $('#list').show 100 - $('#list ol li').remove() - console.log i.author for i in @data.filedata - x = 0 - $('#dirlocation').val @data.location - $('#sortlist').append @.additem item,x++ for item in @data.filedata - $('#sortlist').sortable - start: (event,ui) -> - ui.item.data {startpos:ui.item.index()} - stop: (event,ui) => - s = ui.item.data().startpos - e = ui.item.index() - @data.filedata = @.rearrangearray s,e,@data.filedata - console.log name.author,name.name,name.file for name in @data.filedata - console.log '---' - @buildlist @data + buildlist: (data) -> + $('#list').show 100 + $('#list ol li').remove() + console.log i.author for i in @data.filedata + x = 0 + $('#dirlocation').val @data.location + $('#sortlist').append @.additem item,x++ for item in @data.filedata + $('#sortlist').sortable + start: (event,ui) -> + ui.item.data {startpos:ui.item.index()} + stop: (event,ui) => + s = ui.item.data().startpos + e = ui.item.index() + @data.filedata = @.rearrangearray s,e,@data.filedata + console.log name.author,name.name,name.file for name in @data.filedata + console.log '---' + @buildlist @data Given a start and and end position, pop the array element at start off and insert it into the array at end position. A la the draggon-dropping. - rearrangearray: (startpos,endpos,a) -> - moving = a[startpos] - alen = a.length - tarr = a[0...startpos].concat a[startpos+1..-1] - tarr[0...endpos].concat [moving].concat tarr[endpos..-1] + rearrangearray: (startpos,endpos,a) -> + moving = a[startpos] + alen = a.length + tarr = a[0...startpos].concat a[startpos+1..-1] + tarr[0...endpos].concat [moving].concat tarr[endpos..-1] - additem: (item,pos) -> - entry = @genentryline item,pos - entry.dblclick => - @editline item,pos + additem: (item,pos) -> + entry = @genentryline item,pos + entry.dblclick => + @editline item,pos - genentryline: (item,pos) -> - arrows = "" - amigastatus = ansiorascii booltoint item.amiga - delbutton = $("delete") - .click (event) => - pos = event.currentTarget.id.replace "del-","" - @data.filedata.splice pos,1 - @buildlist @data - entry = $("
  • #{arrows}#{amigastatus} | #{item.author} : #{item.name} : #{item.file}
  • ") - entry.append delbutton + genentryline: (item,pos) -> + arrows = "" + amigastatus = ansiorascii booltoint item.amiga + delbutton = $("delete") + .click (event) => + pos = event.currentTarget.id.replace "del-","" + @data.filedata.splice pos,1 + @buildlist @data + entry = $("
  • #{arrows}#{amigastatus} | #{item.author} : #{item.name} : #{item.file}
  • ") + entry.append delbutton - save: -> - pos = $("#entryindex").val() - entry = @data.filedata[pos] - entry.name = $("#entryname").val() - entry.author = $("#entryauthor").val() - entry.amiga = statustobool $("#entryamiga").children()[1].textContent - console.log $("#entryamiga").children()[1].textContent,entry.amiga,entry.author - entry.color = colortoarray $("#entrycolor").val() - entry.bg = colortoarray $("#entrybg").val() - entry.width = $("#entrywidth").val() - entry.line1 = $("#entryline1").val() - entry.line2 = $("#entryline2").val() - entry.text = $("#entrytext").val() - entry.file = $("#entryfile").val() - entry.filetype = $("#entryfiletype").val() - @buildlist @data + save: -> + pos = $("#entryindex").val() + entry = @data.filedata[pos] + entry.name = $("#entryname").val() + entry.author = $("#entryauthor").val() + entry.amiga = statustobool $("#entryamiga").children()[1].textContent + console.log $("#entryamiga").children()[1].textContent,entry.amiga,entry.author + entry.color = colortoarray $("#entrycolor").val() + entry.bg = colortoarray $("#entrybg").val() + entry.width = $("#entrywidth").val() + entry.line1 = $("#entryline1").val() + entry.line2 = $("#entryline2").val() + entry.text = $("#entrytext").val() + entry.file = $("#entryfile").val() + entry.filetype = $("#entryfiletype").val() + @buildlist @data - editline: (data,pos) -> - $("#formica").dialog { - width:'800', - modal: false, - title:"Entry #{data.file} ", - buttons: [{ - text: "Cancel", - icons: {primary: 'ui-icon-trash'}, - click: -> - $(@).dialog "close" - },{ - text: "Save", - icons: {primary: 'ui-icon-disk'}, - click: (event) => - event.preventDefault() - @save() - event.currentTarget.previousElementSibling.click() + editline: (data,pos) -> + $("#formica").dialog { + width:'800', + modal: false, + title:"Entry #{data.file} ", + buttons: [{ + text: "Cancel", + icons: {primary: 'ui-icon-trash'}, + click: -> + $(@).dialog "close" + },{ + text: "Save", + icons: {primary: 'ui-icon-disk'}, + click: (event) => + event.preventDefault() + @save() + event.currentTarget.previousElementSibling.click() + }] + } - }] - } - - data.amiga = booltoint data.amiga - - fcol = colortoname arraytocolor data.color - bcol = colortoname arraytocolor data.bg - - $("#entryindex").val pos - $("#entryname").val data.name - $("#entryauthor").val data.author - $("#entryfiletpye").val data.filetype - $("#entryfiletype").children()[resolvefiletype data.filetype].selected = true - $("#entryamiga").val data.amiga - $("#entryamiga").children()[1].textContent = ansiorascii data.amiga - $("#entryfont").val data.font - $("#entrycolor").val fcol - $("#entrycolor").children()[colorindex fcol ].selected = true - $("#entrybg").val bcol - $("#entrybg").children()[colorindex bcol ].selected = true - $("#entrywidth").val data.width - $("#entryline1").val data.line1 - $("#entryline2").val data.line2 - $("#entrytext").val data.text - $("#entryfile").val data.file - sahlicolor() + data.amiga = booltoint data.amiga + fcol = colortoname arraytocolor data.color + bcol = colortoname arraytocolor data.bg + $("#entryindex").val pos + $("#entryname").val data.name + $("#entryauthor").val data.author + $("#entryfiletpye").val data.filetype + $("#entryfiletype").children()[resolvefiletype data.filetype].selected = true + $("#entryamiga").val data.amiga + $("#entryamiga").children()[1].textContent = ansiorascii data.amiga + $("#entryfont").val data.font + $("#entrycolor").val fcol + $("#entrycolor").children()[colorindex fcol ].selected = true + $("#entrybg").val bcol + $("#entrybg").children()[colorindex bcol ].selected = true + $("#entrywidth").val data.width + $("#entryline1").val data.line1 + $("#entryline2").val data.line2 + $("#entrytext").val data.text + $("#entryfile").val data.file + sahlicolor() A Helper function to dump json out of an object as text: dumpjson = (obj) -> - JSON.stringify obj,null,"\t" + JSON.stringify obj,null,"\t" Boolean / integer Helpers booltoint = (bool) -> - bool + 1 - 1 + bool + 1 - 1 inttobool = (intstr) -> - (intstr == 1).toString() + (intstr == 1).toString() statustobool = (status) -> - if status is 'Ascii' then true else false + if status is 'Ascii' then true else false Resolve filetype offset in array: resolvefiletype = (filetype) -> - options = { - "plain":0 - "ansi":1 - "xbin":2 - "ice":3 - "adf":4 - "avatar":5 - "bin":6 - "idf":7 - "pcboard":8 - "tundra":9 - } - options[filetype] + options = { + "plain":0 + "ansi":1 + "xbin":2 + "ice":3 + "adf":4 + "avatar":5 + "bin":6 + "idf":7 + "pcboard":8 + "tundra":9 + } + options[filetype] Resolve ansi or ascii status ansiorascii = (status) -> - if status is 0 then "Ansi" else "Ascii" + if status is 0 then "Ansi" else "Ascii" Color conversion from array to color item: -This decimal to hex conversion only handles 00-FF but it's fine for this purpose; -we actually _want_ that limitation in the output. +This decimal to hex conversion only handles 00-FF but it's fine for this +purpose; we actually _want_ that limitation in the output. dec2hex = (num) -> - "#{('000'+num.toString 16).slice -2}" + "#{('000'+num.toString 16).slice -2}" hex2dec = (num) -> - parseInt num,16 + parseInt num,16 arraytocolor = (array) -> - c = (dec2hex x for x in array)[0..2].join '' - "##{c}" + c = (dec2hex x for x in array)[0..2].join '' + "##{c}" colortoarray = (color) -> - color = color.slice(1) - c1 = [ color[0..1], color[2..3], color[4..5] ] - x = (hex2dec i for i in c1) - x.push 255 - x + color = color.slice(1) + c1 = [ color[0..1], color[2..3], color[4..5] ] + x = (hex2dec i for i in c1) + x.push 255 + x Need a way to convert the array back to the color name. colortoname = (color) -> - names = { - "#E0E0E0":"Light Grey" - "#A0A0E0":"Light Blue" - "#9AFE2E":"Light Green" - "#FF0000":"Red" - "#FF8000":"Orange" - "#FFFF00":"Yellow" - "#00F000":"Green" - "#2EFEF7":"Cyan" - "#002EF7":"Blue" - "#0B0B3B":"Navy" - "#FF00FF":"Magenta" - "#8000FF":"Purple" - "#0A2A0A":"Dark Green" - "#3B3B3B":"Dark Grey" - "#FFFFFF":"White" - "#000000":"Black" - } - color = color.toUpperCase() - colorname = names[color] - bw = if hex2dec(color.slice(1)) > 8421504 then 'White' else "Black" - ret = if colorname? then colorname else bw + names = { + "#E0E0E0":"Light Grey" + "#A0A0E0":"Light Blue" + "#9AFE2E":"Light Green" + "#FF0000":"Red" + "#FF8000":"Orange" + "#FFFF00":"Yellow" + "#00F000":"Green" + "#2EFEF7":"Cyan" + "#002EF7":"Blue" + "#0B0B3B":"Navy" + "#FF00FF":"Magenta" + "#8000FF":"Purple" + "#0A2A0A":"Dark Green" + "#3B3B3B":"Dark Grey" + "#FFFFFF":"White" + "#000000":"Black" + } + color = color.toUpperCase() + colorname = names[color] + bw = if hex2dec(color.slice(1)) > 8421504 then 'White' else "Black" + ret = if colorname? then colorname else bw Similarly, need to be able to get the color index. colorindex = (colorname) -> - names = { - "Light Grey":0 - "Light Blue":1 - "Light Green":2 - "Red":3 - "Orange":4 - "Yellow":5 - "Green":6 - "Cyan":7 - "Blue":8 - "Navy":9 - "Magenta":10 - "Purple":11 - "Dark Green":12 - "Dark Grey":13 - "White":14 - "Black":15 - } - names[colorname] + names = { + "Light Grey":0 + "Light Blue":1 + "Light Green":2 + "Red":3 + "Orange":4 + "Yellow":5 + "Green":6 + "Cyan":7 + "Blue":8 + "Navy":9 + "Magenta":10 + "Purple":11 + "Dark Green":12 + "Dark Grey":13 + "White":14 + "Black":15 + } + names[colorname] -A function for changing the fore and background colors of the sahli ascii example +A function for changing the fore and background colors of the sahli ascii +example sahlicolor = -> - fg = $('#entrycolor').val() - bg = $('#entrybg').val() - console.log 'sahlicolor',fg,bg - $('#sahliascii').css {'color':fg,'background':bg} + fg = $('#entrycolor').val() + bg = $('#entrybg').val() + console.log 'sahlicolor',fg,bg + $('#sahliascii').css {'color':fg,'background':bg} -Function for loading the filelist from the specified directory on the server/filesystem. +Function for loading the filelist from the specified directory on the +server/filesystem. getfilelist = -> - location = $("#dirlocation").val() - $.get("../#{location}", (listing) -> - console.log listing - ) - - - + location = $("#dirlocation").val() + $.get("../#{location}", (listing) -> + console.log listing + ) When clicking 'New' we want to make a brand new Sahli, and then clear out the buttons and create the editor bit as blank. newsahli = -> - sahli = new Sahli - sahli.data = sahli.empty - newentry = new emptyfiledef - sahli.data.filedata.push newentry - sahli.edit() + sahli = new Sahli + sahli.data = sahli.empty + newentry = new Emptyfiledef + sahli.data.filedata.push newentry + sahli.edit() And when clicking 'load' we want to load the existing sahli file. loadsahli = -> - sahli = new Sahli - sahli.loader 'list.sahli' + sahli = new Sahli + sahli.loader 'list.sahli' diff --git a/editor/sahlieditor.html b/editor/sahlieditor.html index 547f106..e007301 100644 --- a/editor/sahlieditor.html +++ b/editor/sahlieditor.html @@ -138,10 +138,11 @@
    -   ________________________,  ._____,
    -  |  ___|___    |  |   |   |  |_____|
    -  |_____  |  _  |      |   |__|   |
    -    |_____|_____|___|__|______|___|
    +ABCDEFGHIJKLMNOPQRSTUVWXYZ><~`'"^&eXmPl
    +abcdefghijklmnopqrstuvwxyz1234567890?+@
    +* |  ___)___    7  I   |   |  \-~=#/  $
    +: |_____  | {~} !      |   \__[   : #~%
    +;   (_____j__"__l___|__|______]___; 0Oo
     							
    From aeb76cefc0c7f83178a95c2a8cba6a0fb9002a0d Mon Sep 17 00:00:00 2001 From: Iam Naughton Phier Date: Fri, 27 Mar 2015 14:40:28 +0200 Subject: [PATCH 02/36] change from literate to straight coffeescript - was getting lots of linting errors due to tabulation - probably better this way, though I still like literate's concept - all seems to work but need to triple check everything --- editor/sahliedit.coffee | 426 ++++++++++++++++++++++++++++++++++++++++ editor/sahliedit.js | 165 ++++++++++++++-- 2 files changed, 572 insertions(+), 19 deletions(-) create mode 100644 editor/sahliedit.coffee diff --git a/editor/sahliedit.coffee b/editor/sahliedit.coffee new file mode 100644 index 0000000..cac3e62 --- /dev/null +++ b/editor/sahliedit.coffee @@ -0,0 +1,426 @@ +### +Sahli Editor +============ + +Editor for Sahli files. + +- open existing file +- create new item + * get filename from dir + * insert SAUCE data if available + * use SAUCE data to find font + * allow Amiga choices + * colorpicker +- edit existing item +- remove item +- clear whole file +- copy/clone +- move items around +- sort items +- output to screen (copy into file) + * run from node - save filename dialog + +*** +It should be noted that this does not do bounds checking, and it would be very +possible to overflow this by using a debugger and such. As the purpose of this +is limited, and this should NOT be put on a live website, I feel that is ok for +now. Perhaps I will fix it after Revision. + +*** + +== Create Initial crappage +We need to make a screen that has a few things in it for starters +Title, load existing, and new file options. + +Silliness for checking that this works. +### + +$(-> $("h1").hide().slideDown(500)) + +### +Create buttons to choose between the New and Load functionalities +(As we aren't going to ever load a file _and_ do a new file.) +(If someone wants to do that, they can restart with F5 or something.) +Also hide the editor until needed, and initialize some elements. +### +$(-> + $("#newsahli") + .button { disabled: false} + .click -> newsahli() + ) + +$(-> + $("#loadsahli") + .button { disabled: false} + .click -> loadsahli() + ) +$(-> + $(".hidden").hide() + $("#entryamiga").button {icons: {primary:"ui-icon-gear"}} + .click -> + stuff = $(@).children() + if @.value == "1" + stuff[1].textContent = 'Ansi' + @.value = "0" + else + stuff[1].textContent = 'Ascii' + @.value = "1" + $(".45box").css {width:'45%',display:'inline-block'} + $(".groupbox p").css {margin:"0 0 .25em 0"} + $(".colorbox").change -> + sahlicolor() + + $("#entryfilepick").change -> + if @.files[0]? then $("#entryfile").val @.files[0].name + $("#entryfile").click -> + $("#entryfilepick").click() +) + +### +The sahli file definition format is as follows: +"file" - the actual filename on disk, "name" - the title of the piece, +the boolean 'amiga' indicates if it is ansi or ascii (True = ascii), +width is the width (widest point of the file), author the author of the piece, +the color and bg items define the color for amiga ascii, and the font +defines the font similarly. For PC ansi, this should be 'ansifont.' +The three remaining lines are informational and optional. + +The slide format is currently unused, but consists of a background picture, +a html template, and a css file. +### +class Emptyfiledef + constructor: -> + @file = "" + @name = "" + @amiga = true + @filetype = 'plain' + @width = "" + @author = "" + @font = "Propaz" + @color = [ 255,255,255,255 ] + @bg = [ 0,0,0,0 ] + @line1 = "" + @line2 = "" + @text = "" + + +class Sahli + constructor: -> + @emptyfiledef = new Emptyfiledef + @emptyslidesdef = { + "background": "", + "template": "", + "css": "" + } + @empty = { + "location": "", + "slides": @emptyslidesdef, + "filedata": [ ] + } + + loader: -> + $.ajax { + url: '../list.sahli', + dataType: "json", + success: (result) => + @data = result + @.edit() + } + + edit: -> + $('#buttonbox').hide() + $('#dirlocation').change (event) => + @data.location = event.target.value + $('#listsave').button {icons: {primary:"ui-icon-disk"}} + .click => + $('#sahlioutput').text dumpjson @data + $('#dumparea').show 100 + console.log dumpjson @data + $('#listlist').button {icons: {primary:"ui-icon-folder-open"}} + .click -> + getfilelist() + $('#listappend').button {icons: {primary:"ui-icon-1-n"}} + .click (event) => + newentry = new Emptyfiledef + @data.filedata.push newentry + @buildlist @data + $('#listdisplay').button {icons: {primary:"ui-icon-refresh"}} + .click => + @buildlist @data + $('#closespan').click -> + $(@parentElement.parentElement).hide() + $('#sahlioutput').text '' + @buildlist @data + + buildlist: (data) -> + $('#list').show 100 + $('#list ol li').remove() + console.log i.author for i in @data.filedata + x = 0 + $('#dirlocation').val @data.location + $('#sortlist').append @.additem item,x++ for item in @data.filedata + $('#sortlist').sortable + start: (event,ui) -> + ui.item.data + startpos:ui.item.index() + stop: (event,ui) => + a = 2 + s = ui.item.data().startpos + e = ui.item.index() + @data.filedata = @.rearrangearray s,e,@data.filedata + @buildlist @data + console.log name.author,name.name,name.file for name in @data.filedata + console.log '---' + + harry: (potter) -> + console.log "yer a lizzard, harry" + + + rearrangearray: (startpos,endpos,a) -> + moving = a[startpos] + alen = a.length + tarr = a[0...startpos].concat a[startpos+1..-1] + tarr[0...endpos].concat [moving].concat tarr[endpos..-1] + + + additem: (item,pos) -> + entry = @genentryline item,pos + entry.dblclick => + @editline item,pos + + genentryline: (item,pos) -> + arrows = "" + amigastatus = ansiorascii booltoint item.amiga + delbutton = $("delete") + .click (event) => + pos = event.currentTarget.id.replace "del-","" + @data.filedata.splice pos,1 + @buildlist @data + whichone = "
  • #{arrows}#{amigastatus} |" + whichone += " #{item.author} : #{item.name} : #{item.file}
  • " + entry = $(whichone) + entry.append delbutton + + save: -> + pos = $("#entryindex").val() + entry = @data.filedata[pos] + entry.name = $("#entryname").val() + entry.author = $("#entryauthor").val() + entry.amiga = statustobool $("#entryamiga").children()[1].textContent + console.log $("#entryamiga").children()[1].textContent + console.log entry.amiga,entry.author + entry.color = colortoarray $("#entrycolor").val() + entry.bg = colortoarray $("#entrybg").val() + entry.width = $("#entrywidth").val() + entry.line1 = $("#entryline1").val() + entry.line2 = $("#entryline2").val() + entry.text = $("#entrytext").val() + entry.file = $("#entryfile").val() + entry.filetype = $("#entryfiletype").val() + @buildlist @data + + editline: (data,pos) -> + $("#formica").dialog { + width:'800', + modal: false, + title:"Entry #{data.file} ", + buttons: [{ + text: "Cancel", + icons: {primary: 'ui-icon-trash'}, + click: -> + $(@).dialog "close" + },{ + text: "Save", + icons: {primary: 'ui-icon-disk'}, + click: (event) => + event.preventDefault() + @save() + event.currentTarget.previousElementSibling.click() + }] + } + data.amiga = booltoint data.amiga + + fcol = colortoname arraytocolor data.color + bcol = colortoname arraytocolor data.bg + + $("#entryindex").val pos + $("#entryname").val data.name + $("#entryauthor").val data.author + $("#entryfiletpye").val data.filetype + $("#entryfiletype").children()[resolvefiletype data.filetype].selected =true + $("#entryamiga").val data.amiga + $("#entryamiga").children()[1].textContent = ansiorascii data.amiga + $("#entryfont").val data.font + $("#entrycolor").val fcol + $("#entrycolor").children()[colorindex fcol ].selected = true + $("#entrybg").val bcol + $("#entrybg").children()[colorindex bcol ].selected = true + $("#entrywidth").val data.width + $("#entryline1").val data.line1 + $("#entryline2").val data.line2 + $("#entrytext").val data.text + $("#entryfile").val data.file + sahlicolor() + +### +A Helper function to dump json out of an object as text: +### +dumpjson = (obj) -> + JSON.stringify obj,null,"\t" + +### + Boolean / integer Helpers +### + +booltoint = (bool) -> + bool + 1 - 1 + +inttobool = (intstr) -> + (intstr == 1).toString() + +statustobool = (status) -> + if status is 'Ascii' then true else false + +### +Resolve filetype offset in array: +### + +resolvefiletype = (filetype) -> + options = { + "plain":0 + "ansi":1 + "xbin":2 + "ice":3 + "adf":4 + "avatar":5 + "bin":6 + "idf":7 + "pcboard":8 + "tundra":9 + } + options[filetype] + +### +Resolve ansi or ascii status +### + +ansiorascii = (status) -> + if status is 0 then "Ansi" else "Ascii" + +### +Color conversion from array to color item: + +This decimal to hex conversion only handles 00-FF but it's fine for this + purpose; we actually _want_ that limitation in the output. +### + +dec2hex = (num) -> + "#{('000'+num.toString 16).slice -2}" + +hex2dec = (num) -> + parseInt num,16 + +arraytocolor = (array) -> + c = (dec2hex x for x in array)[0..2].join '' + "##{c}" + +colortoarray = (color) -> + color = color.slice(1) + c1 = [ color[0..1], color[2..3], color[4..5] ] + x = (hex2dec i for i in c1) + x.push 255 + x + +### +Need a way to convert the array back to the color name. +### + +colortoname = (color) -> + names = { + "#E0E0E0":"Light Grey" + "#A0A0E0":"Light Blue" + "#9AFE2E":"Light Green" + "#FF0000":"Red" + "#FF8000":"Orange" + "#FFFF00":"Yellow" + "#00F000":"Green" + "#2EFEF7":"Cyan" + "#002EF7":"Blue" + "#0B0B3B":"Navy" + "#FF00FF":"Magenta" + "#8000FF":"Purple" + "#0A2A0A":"Dark Green" + "#3B3B3B":"Dark Grey" + "#FFFFFF":"White" + "#000000":"Black" + } + color = color.toUpperCase() + colorname = names[color] + bw = if hex2dec(color.slice(1)) > 8421504 then 'White' else "Black" + ret = if colorname? then colorname else bw +### +Similarly, need to be able to get the color index. +### + +colorindex = (colorname) -> + names = { + "Light Grey":0 + "Light Blue":1 + "Light Green":2 + "Red":3 + "Orange":4 + "Yellow":5 + "Green":6 + "Cyan":7 + "Blue":8 + "Navy":9 + "Magenta":10 + "Purple":11 + "Dark Green":12 + "Dark Grey":13 + "White":14 + "Black":15 + } + names[colorname] + +### +A function for changing the fore and background colors of the sahli ascii +example +### + +sahlicolor = -> + fg = $('#entrycolor').val() + bg = $('#entrybg').val() + console.log 'sahlicolor',fg,bg + $('#sahliascii').css {'color':fg,'background':bg} + +### +Function for loading the filelist from the specified directory on the +server/filesystem. +### + +getfilelist = -> + location = $("#dirlocation").val() + $.get("../#{location}", (listing) -> + console.log listing + ) + +### +When clicking 'New' we want to make a brand new Sahli, and then clear out +the buttons and create the editor bit as blank. +### + +newsahli = -> + sahli = new Sahli + sahli.data = sahli.empty + newentry = new Emptyfiledef + sahli.data.filedata.push newentry + sahli.edit() + +### +And when clicking 'load' we want to load the existing sahli file. +### + +loadsahli = -> + sahli = new Sahli + sahli.loader 'list.sahli' diff --git a/editor/sahliedit.js b/editor/sahliedit.js index 678a60e..74a57d5 100644 --- a/editor/sahliedit.js +++ b/editor/sahliedit.js @@ -1,11 +1,57 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.9.0 + +/* +Sahli Editor +============ + +Editor for Sahli files. + +- open existing file +- create new item + * get filename from dir + * insert SAUCE data if available + * use SAUCE data to find font + * allow Amiga choices + * colorpicker +- edit existing item +- remove item +- clear whole file +- copy/clone +- move items around +- sort items +- output to screen (copy into file) + * run from node - save filename dialog + +*** +It should be noted that this does not do bounds checking, and it would be very +possible to overflow this by using a debugger and such. As the purpose of this +is limited, and this should NOT be put on a live website, I feel that is ok for +now. Perhaps I will fix it after Revision. + +*** + +== Create Initial crappage +We need to make a screen that has a few things in it for starters +Title, load existing, and new file options. + +Silliness for checking that this works. + */ + (function() { - var Sahli, ansiorascii, arraytocolor, booltoint, colorindex, colortoarray, colortoname, dec2hex, dumpjson, emptyfiledef, getfilelist, hex2dec, inttobool, loadsahli, newsahli, resolvefiletype, sahlicolor, statustobool; + var Emptyfiledef, Sahli, ansiorascii, arraytocolor, booltoint, colorindex, colortoarray, colortoname, dec2hex, dumpjson, getfilelist, hex2dec, inttobool, loadsahli, newsahli, resolvefiletype, sahlicolor, statustobool; $(function() { return $("h1").hide().slideDown(500); }); + + /* + Create buttons to choose between the New and Load functionalities + (As we aren't going to ever load a file _and_ do a new file.) + (If someone wants to do that, they can restart with F5 or something.) + Also hide the editor until needed, and initialize some elements. + */ + $(function() { return $("#newsahli").button({ disabled: false @@ -46,11 +92,9 @@ $(".groupbox p").css({ margin: "0 0 .25em 0" }); - $(".colorbox").change((function(_this) { - return function() { - return sahlicolor(); - }; - })(this)); + $(".colorbox").change(function() { + return sahlicolor(); + }); $("#entryfilepick").change(function() { if (this.files[0] != null) { return $("#entryfile").val(this.files[0].name); @@ -61,8 +105,22 @@ }); }); - emptyfiledef = (function() { - function emptyfiledef() { + + /* + The sahli file definition format is as follows: + "file" - the actual filename on disk, "name" - the title of the piece, + the boolean 'amiga' indicates if it is ansi or ascii (True = ascii), + width is the width (widest point of the file), author the author of the piece, + the color and bg items define the color for amiga ascii, and the font + defines the font similarly. For PC ansi, this should be 'ansifont.' + The three remaining lines are informational and optional. + + The slide format is currently unused, but consists of a background picture, + a html template, and a css file. + */ + + Emptyfiledef = (function() { + function Emptyfiledef() { this.file = ""; this.name = ""; this.amiga = true; @@ -77,13 +135,13 @@ this.text = ""; } - return emptyfiledef; + return Emptyfiledef; })(); Sahli = (function() { function Sahli() { - this.emptyfiledef = new emptyfiledef; + this.emptyfiledef = new Emptyfiledef; this.emptyslidesdef = { "background": "", "template": "", @@ -141,7 +199,7 @@ }).click((function(_this) { return function(event) { var newentry; - newentry = new emptyfiledef; + newentry = new Emptyfiledef; _this.data.filedata.push(newentry); return _this.buildlist(_this.data); }; @@ -186,22 +244,27 @@ }, stop: (function(_this) { return function(event, ui) { - var e, name, s, _k, _len2, _ref2; + var a, e, name, s, _k, _len2, _ref2; + a = 2; s = ui.item.data().startpos; e = ui.item.index(); _this.data.filedata = _this.rearrangearray(s, e, _this.data.filedata); + _this.buildlist(_this.data); _ref2 = _this.data.filedata; for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { name = _ref2[_k]; console.log(name.author, name.name, name.file); } - console.log('---'); - return _this.buildlist(_this.data); + return console.log('---'); }; })(this) }); }; + Sahli.prototype.harry = function(potter) { + return console.log("yer a lizzard, harry"); + }; + Sahli.prototype.rearrangearray = function(startpos, endpos, a) { var alen, moving, tarr; moving = a[startpos]; @@ -221,7 +284,7 @@ }; Sahli.prototype.genentryline = function(item, pos) { - var amigastatus, arrows, delbutton, entry; + var amigastatus, arrows, delbutton, entry, whichone; arrows = ""; amigastatus = ansiorascii(booltoint(item.amiga)); delbutton = $("delete").click((function(_this) { @@ -231,7 +294,9 @@ return _this.buildlist(_this.data); }; })(this)); - entry = $("
  • " + arrows + amigastatus + " | " + item.author + " : " + item.name + " : " + item.file + "
  • "); + whichone = "
  • " + arrows + amigastatus + " |"; + whichone += " " + item.author + " : " + item.name + " : " + item.file + "
  • "; + entry = $(whichone); return entry.append(delbutton); }; @@ -242,7 +307,8 @@ entry.name = $("#entryname").val(); entry.author = $("#entryauthor").val(); entry.amiga = statustobool($("#entryamiga").children()[1].textContent); - console.log($("#entryamiga").children()[1].textContent, entry.amiga, entry.author); + console.log($("#entryamiga").children()[1].textContent); + console.log(entry.amiga, entry.author); entry.color = colortoarray($("#entrycolor").val()); entry.bg = colortoarray($("#entrybg").val()); entry.width = $("#entrywidth").val(); @@ -311,10 +377,20 @@ })(); + + /* + A Helper function to dump json out of an object as text: + */ + dumpjson = function(obj) { return JSON.stringify(obj, null, "\t"); }; + + /* + Boolean / integer Helpers + */ + booltoint = function(bool) { return bool + 1 - 1; }; @@ -331,6 +407,11 @@ } }; + + /* + Resolve filetype offset in array: + */ + resolvefiletype = function(filetype) { var options; options = { @@ -348,6 +429,11 @@ return options[filetype]; }; + + /* + Resolve ansi or ascii status + */ + ansiorascii = function(status) { if (status === 0) { return "Ansi"; @@ -356,6 +442,14 @@ } }; + + /* + Color conversion from array to color item: + + This decimal to hex conversion only handles 00-FF but it's fine for this + purpose; we actually _want_ that limitation in the output. + */ + dec2hex = function(num) { return "" + (('000' + num.toString(16)).slice(-2)); }; @@ -395,6 +489,11 @@ return x; }; + + /* + Need a way to convert the array back to the color name. + */ + colortoname = function(color) { var bw, colorname, names, ret; names = { @@ -421,6 +520,11 @@ return ret = colorname != null ? colorname : bw; }; + + /* + Similarly, need to be able to get the color index. + */ + colorindex = function(colorname) { var names; names = { @@ -444,6 +548,12 @@ return names[colorname]; }; + + /* + A function for changing the fore and background colors of the sahli ascii + example + */ + sahlicolor = function() { var bg, fg; fg = $('#entrycolor').val(); @@ -455,6 +565,12 @@ }); }; + + /* + Function for loading the filelist from the specified directory on the + server/filesystem. + */ + getfilelist = function() { var location; location = $("#dirlocation").val(); @@ -463,15 +579,26 @@ }); }; + + /* + When clicking 'New' we want to make a brand new Sahli, and then clear out + the buttons and create the editor bit as blank. + */ + newsahli = function() { var newentry, sahli; sahli = new Sahli; sahli.data = sahli.empty; - newentry = new emptyfiledef; + newentry = new Emptyfiledef; sahli.data.filedata.push(newentry); return sahli.edit(); }; + + /* + And when clicking 'load' we want to load the existing sahli file. + */ + loadsahli = function() { var sahli; sahli = new Sahli; From fc8693be0bcb80a367b8069b10f92819b2b849d2 Mon Sep 17 00:00:00 2001 From: Iam Naughton Phier Date: Fri, 27 Mar 2015 14:42:02 +0200 Subject: [PATCH 03/36] Removed cakefile as it is unused in this setup (and too complex) --- Cakefile | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 Cakefile diff --git a/Cakefile b/Cakefile deleted file mode 100644 index 2443240..0000000 --- a/Cakefile +++ /dev/null @@ -1,47 +0,0 @@ -fs = require 'fs' -option '-o', '--output [dir]', 'dir for compiled code' - -task 'watch', 'watch current dir', (options) -> - {spawn} = require 'child_process' - args = ['-w','-c'] - if options.output - args = args.concat ['./'] - - process.chdir __originalDirname - coffee = spawn 'coffee', args - coffee.stderr.on 'data', (data) -> - process.stderr.write data.toString() - coffee.stdout.on 'data', (data) -> - console.log data.toString() - -source = [ - '16col/imgtxtmode.coffee', - '16col/ansi.coffee', - '16col/bin.coffee', - '16col/idf.coffee', - '16col/adf.coffee', - '16col/sauce.coffee', - '16col/tundra.coffee', - '16col/pcboard.coffee', - '16col/avatar.coffee', - '16col/xbin.coffee', - '16col/pallette.coffee', - '16col/fonts.coffee', -] - -task 'build', 'Build merged file for production', (options) -> - {exec} = require 'child_process' - content = [] - - for file, index in source then do (file, index) -> - fs.readFile file, 'utf8', (err, fileContents) -> - throw err if err - content[index] = fileContents - if index == source.length - 1 - coffee = content.join('\n') - fs.writeFile 'textmode.coffee', coffee, 'utf8', (err) -> - throw err if err - command = 'coffee --compile textmode.coffee' - exec command, (err, stdout, stderr) -> - throw err if err - console.log stdout + stderr \ No newline at end of file From 16207fc2aef27c2333fa85a2b645a99652e4fd3d Mon Sep 17 00:00:00 2001 From: Iam Naughton Phier Date: Fri, 27 Mar 2015 15:05:45 +0200 Subject: [PATCH 04/36] avoid confusion over which is "documentation" and which is code --- editor/{sahliedit.litcoffee => sahliedit.doclit} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename editor/{sahliedit.litcoffee => sahliedit.doclit} (100%) diff --git a/editor/sahliedit.litcoffee b/editor/sahliedit.doclit similarity index 100% rename from editor/sahliedit.litcoffee rename to editor/sahliedit.doclit From f8134f41d26bd2ae2bdfab37d34506ea1580da6a Mon Sep 17 00:00:00 2001 From: Iam Naughton Phier Date: Fri, 27 Mar 2015 18:10:58 +0200 Subject: [PATCH 05/36] Fix: Font Picker now shows font chosen and saves font. --- editor/sahliedit.coffee | 17 +++++++++-------- editor/sahliedit.js | 29 ++++++++++++++--------------- editor/sahlieditor.html | 12 ++++++------ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/editor/sahliedit.coffee b/editor/sahliedit.coffee index cac3e62..14a4122 100644 --- a/editor/sahliedit.coffee +++ b/editor/sahliedit.coffee @@ -65,10 +65,16 @@ $(-> else stuff[1].textContent = 'Ascii' @.value = "1" - $(".45box").css {width:'45%',display:'inline-block'} + $(".45box").css {width:'40ex',display:'inline-block'} $(".groupbox p").css {margin:"0 0 .25em 0"} $(".colorbox").change -> sahlicolor() + $("#entryfont").change -> + font = $("#entryfont").val() + if font == "ansifont" + font = "BlockZone" + $('pre').css 'font-family',font + $("#entryfilepick").change -> if @.files[0]? then $("#entryfile").val @.files[0].name @@ -135,7 +141,6 @@ class Sahli .click => $('#sahlioutput').text dumpjson @data $('#dumparea').show 100 - console.log dumpjson @data $('#listlist').button {icons: {primary:"ui-icon-folder-open"}} .click -> getfilelist() @@ -169,12 +174,6 @@ class Sahli e = ui.item.index() @data.filedata = @.rearrangearray s,e,@data.filedata @buildlist @data - console.log name.author,name.name,name.file for name in @data.filedata - console.log '---' - - harry: (potter) -> - console.log "yer a lizzard, harry" - rearrangearray: (startpos,endpos,a) -> moving = a[startpos] @@ -215,6 +214,7 @@ class Sahli entry.line1 = $("#entryline1").val() entry.line2 = $("#entryline2").val() entry.text = $("#entrytext").val() + entry.font = $("#entryfont").val() entry.file = $("#entryfile").val() entry.filetype = $("#entryfiletype").val() @buildlist @data @@ -397,6 +397,7 @@ sahlicolor = -> ### Function for loading the filelist from the specified directory on the server/filesystem. +Needs to be made into an actual real thing. ### getfilelist = -> diff --git a/editor/sahliedit.js b/editor/sahliedit.js index 74a57d5..02d3ce1 100644 --- a/editor/sahliedit.js +++ b/editor/sahliedit.js @@ -86,7 +86,7 @@ Silliness for checking that this works. } }); $(".45box").css({ - width: '45%', + width: '40ex', display: 'inline-block' }); $(".groupbox p").css({ @@ -95,6 +95,14 @@ Silliness for checking that this works. $(".colorbox").change(function() { return sahlicolor(); }); + $("#entryfont").change(function() { + var font; + font = $("#entryfont").val(); + if (font === "ansifont") { + font = "BlockZone"; + } + return $('pre').css('font-family', font); + }); $("#entryfilepick").change(function() { if (this.files[0] != null) { return $("#entryfile").val(this.files[0].name); @@ -181,8 +189,7 @@ Silliness for checking that this works. }).click((function(_this) { return function() { $('#sahlioutput').text(dumpjson(_this.data)); - $('#dumparea').show(100); - return console.log(dumpjson(_this.data)); + return $('#dumparea').show(100); }; })(this)); $('#listlist').button({ @@ -244,27 +251,17 @@ Silliness for checking that this works. }, stop: (function(_this) { return function(event, ui) { - var a, e, name, s, _k, _len2, _ref2; + var a, e, s; a = 2; s = ui.item.data().startpos; e = ui.item.index(); _this.data.filedata = _this.rearrangearray(s, e, _this.data.filedata); - _this.buildlist(_this.data); - _ref2 = _this.data.filedata; - for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { - name = _ref2[_k]; - console.log(name.author, name.name, name.file); - } - return console.log('---'); + return _this.buildlist(_this.data); }; })(this) }); }; - Sahli.prototype.harry = function(potter) { - return console.log("yer a lizzard, harry"); - }; - Sahli.prototype.rearrangearray = function(startpos, endpos, a) { var alen, moving, tarr; moving = a[startpos]; @@ -315,6 +312,7 @@ Silliness for checking that this works. entry.line1 = $("#entryline1").val(); entry.line2 = $("#entryline2").val(); entry.text = $("#entrytext").val(); + entry.font = $("#entryfont").val(); entry.file = $("#entryfile").val(); entry.filetype = $("#entryfiletype").val(); return this.buildlist(this.data); @@ -569,6 +567,7 @@ Silliness for checking that this works. /* Function for loading the filelist from the specified directory on the server/filesystem. + Needs to be made into an actual real thing. */ getfilelist = function() { diff --git a/editor/sahlieditor.html b/editor/sahlieditor.html index e007301..3c9bd68 100644 --- a/editor/sahlieditor.html +++ b/editor/sahlieditor.html @@ -83,12 +83,12 @@
  • From 54b59b6344e03f6150a2c6d9b4f71acf37fcbff4 Mon Sep 17 00:00:00 2001 From: moqui Date: Tue, 27 Sep 2016 15:21:44 +0200 Subject: [PATCH 06/36] function to move to previous entry --- index.html | 1 + sahli.coffee | 23 +++++++++++++++++++++++ sahli.js | 49 ++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 62 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 0c9660b..3334d87 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,7 @@
    • F Fullscreen
    • Space Next Picture
    • +
    • P Previous Picture
    • S Start or Reverse scrolling
    • X Begin scrolling downward
    • W Begin scrolling upward
    • diff --git a/sahli.coffee b/sahli.coffee index a4cf8a0..477ed8a 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -146,6 +146,27 @@ class @Sahli $('body').stop() @loadinfopanel i + @prevpic = => + viewbox = $('div#sahliviewer') + viewbox.children().remove() + $('#panel').empty() + @scroll_direction = 1 + @scroll_speed = 5 + filedata = @filedata + i = @currentpic-2 + if i < 0 + i = i + filedata.length + filedata[i].pic = $('
      ' + filedata[i].file + '
      ') + viewbox.append filedata[i].pic + @loadpic filedata[i], filedata[i].pic + @currentpic = i + 1 + if @currentpic > filedata.length - 1 + @currentpic = 0 + $('#panel').hide() + $('#outbox').show() + $('body').stop() + @loadinfopanel i + @togglefullscreen = -> docElm = document.documentElement if @fullscreen @@ -315,6 +336,8 @@ class @Sahli switch ev.which when @keycode ' ' @nextpic() + when @keycode 'p' + @prevpic() when @keycode 'f' @togglefullscreen() when @keycode 's' diff --git a/sahli.js b/sahli.js index 4dd5734..d3f2c48 100644 --- a/sahli.js +++ b/sahli.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 /* .___________________________________, ___ @@ -172,6 +172,31 @@ l__________/__________|___|______l__________j_____j return Sahli.loadinfopanel(i); }; + Sahli.prevpic = function() { + var filedata, i, viewbox; + viewbox = $('div#sahliviewer'); + viewbox.children().remove(); + $('#panel').empty(); + Sahli.scroll_direction = 1; + Sahli.scroll_speed = 5; + filedata = Sahli.filedata; + i = Sahli.currentpic - 2; + if (i < 0) { + i = i + filedata.length; + } + filedata[i].pic = $('
      ' + filedata[i].file + '
      '); + viewbox.append(filedata[i].pic); + Sahli.loadpic(filedata[i], filedata[i].pic); + Sahli.currentpic = i + 1; + if (Sahli.currentpic > filedata.length - 1) { + Sahli.currentpic = 0; + } + $('#panel').hide(); + $('#outbox').show(); + $('body').stop(); + return Sahli.loadinfopanel(i); + }; + Sahli.togglefullscreen = function() { var docElm; docElm = document.documentElement; @@ -281,7 +306,7 @@ l__________/__________|___|______l__________j_____j }; Sahli.panelmode = function() { - var canvs, ct, drawcol, level, newheight, newwidth, numcols, numpanels, outer, panelratio, panelslotheight, panelsperslot, pic, picdpercol, screenratio, wh, ww, x, _i, _j, _len, _len1, _results; + var canvs, ct, drawcol, j, k, len, len1, level, newheight, newwidth, numcols, numpanels, outer, panelratio, panelslotheight, panelsperslot, pic, picdpercol, results, screenratio, wh, ww, x; $('#panel').toggle(); canvs = $('canvas'); $('.scrolly').width(this.origwidth); @@ -309,9 +334,9 @@ l__________/__________|___|______l__________j_____j drawcol = 1; ct = 0; outer.append(this.createpanel(1, newwidth - 6)); - _results = []; - for (_i = 0, _len = canvs.length; _i < _len; _i++) { - pic = canvs[_i]; + results = []; + for (j = 0, len = canvs.length; j < len; j++) { + pic = canvs[j]; $("#column" + drawcol).append(pic); level += 1; ct += 1; @@ -319,19 +344,19 @@ l__________/__________|___|______l__________j_____j level = 0; drawcol = drawcol + 1; if (ct < numpanels) { - _results.push(outer.append(this.createpanel(drawcol, newwidth - 6))); + results.push(outer.append(this.createpanel(drawcol, newwidth - 6))); } else { - _results.push(void 0); + results.push(void 0); } } else { - _results.push(void 0); + results.push(void 0); } } - return _results; + return results; } else { $('#outbox').show(); - for (_j = 0, _len1 = canvs.length; _j < _len1; _j++) { - pic = canvs[_j]; + for (k = 0, len1 = canvs.length; k < len1; k++) { + pic = canvs[k]; $('.scrolly').append(pic); } canvs.width(this.origwidth); @@ -374,6 +399,8 @@ l__________/__________|___|______l__________j_____j switch (ev.which) { case _this.keycode(' '): return _this.nextpic(); + case _this.keycode('p'): + return _this.prevpic(); case _this.keycode('f'): return _this.togglefullscreen(); case _this.keycode('s'): From d3cf696ae4c718e9bb1603bda9f36bf4417642cc Mon Sep 17 00:00:00 2001 From: Sir Garbagetruck Date: Tue, 27 Sep 2016 22:00:46 +0300 Subject: [PATCH 07/36] add 'previous picture' on P. --- sahli.coffee | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/sahli.coffee b/sahli.coffee index 477ed8a..9b2bb39 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -147,25 +147,11 @@ class @Sahli @loadinfopanel i @prevpic = => - viewbox = $('div#sahliviewer') - viewbox.children().remove() - $('#panel').empty() - @scroll_direction = 1 - @scroll_speed = 5 - filedata = @filedata i = @currentpic-2 if i < 0 - i = i + filedata.length - filedata[i].pic = $('
      ' + filedata[i].file + '
      ') - viewbox.append filedata[i].pic - @loadpic filedata[i], filedata[i].pic - @currentpic = i + 1 - if @currentpic > filedata.length - 1 - @currentpic = 0 - $('#panel').hide() - $('#outbox').show() - $('body').stop() - @loadinfopanel i + i = i + @filedata.length + @currentpic = i + @nextpic() @togglefullscreen = -> docElm = document.documentElement From 1d6e8636cafea3bcb0be5767edacbfa8908d795f Mon Sep 17 00:00:00 2001 From: Sir Garbagetruck Date: Tue, 27 Sep 2016 22:14:08 +0300 Subject: [PATCH 08/36] 72 point huge ass "NOT SUPPORTED ON WINDOWS+FIREFOX" warnings. - probably won't get read by someone ): --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b64e94..8ff3cb9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ l__________/__________|___|______l__________j_____j Ansi/Ansi Viewer in Ecmascript - Coded by Sir Garbagetruck / Accession 2013 + Coded by Sir Garbagetruck / Accession 2013+ Uses fonts by DMG, http:trueschool.se Uses SixteenColors textmode js library for rendering (well, my optimized version...) @@ -63,6 +63,34 @@ This works just fine if you use remote urls for the files. EVERY PERSON ALIVE, DEAD, OR IMAGINARY, INCLUDING THE NONEXISTENT. *** +Mr Doob (who I want to call Trace (: ) has a good page +explaining how to do this and alternatives here: + +https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally + +As you can see from that, as of right now (September 2016) +if you're using Firefox, you should be EXTREMELY CAREFUL and be +100% SURE YOU CHANGE THE SETTING BACK! + +** ESPECIALLY ON WINDOWS FOR CRYING OUT LOUD ** + +Look if you're using Windows and Firefox to use this, and _YOU_ +don't set the setting back, YOU ARE GOING TO GET FUCKED. + +BECAUSE OF THIS: I DO NOT RECCOMEND, OR SUPPORT, RUNNING THIS +ON WINDOWS AND FIREFOX. It works. I do not RECCOMEND it or +support it. Someone is going to come back and fuck me over +because of their stupidity and choice of OS. Fuck that. + +I may be able to turn this into a chrome app at some point, which +will eliminate that issue. Possibly also a Firefox solution, but: +As of today: I do not support this on Windows + Firefox. That is +100% at your own risk, because of the possibility you will forget +to set the setting back. + +It's just plain safer to install this on your webserver at the +party place in a directory and use _that._ + This product is licensed under the WTFPL. See: http://www.wtfpl.net for details, or just get the license: @@ -98,3 +126,8 @@ Azzarro/Madwizards. - More examples came from 16colors archive. When the final Sahli ver. B comes out, I'll select some test files and put those credits in here too. + +- Thanks to M0qui for submitting a patch for 'backwards' +(in case you accidentally hit space. Which we c64 sceners +never do, because that would be the NEXT demopart, and +you'd have to reload (: ) From 50d2afd6d8340283dc004ded2fe2b3746afa4f06 Mon Sep 17 00:00:00 2001 From: Sir Garbagetruck Date: Tue, 27 Sep 2016 22:22:01 +0300 Subject: [PATCH 09/36] Move P further down help - one shouldn't be going backward - with preload stuff, it could be better, then a 'pick' mode should be there - and that's not really what this is for. This is for running a compo - compos go ONE WAY - yes it's good to have it as an emergency. It's a good change. --- index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 3334d87..e070433 100644 --- a/index.html +++ b/index.html @@ -36,12 +36,13 @@
      • F Fullscreen
      • Space Next Picture
      • -
      • P Previous Picture
      • S Start or Reverse scrolling
      • X Begin scrolling downward
      • W Begin scrolling upward
      • A Stop scrolling
      • +
      • P Previous Picture
      • +
      • T Jump to Top of picture (resets zoom)
      • B Jump to Bottom
      • 12345 Alter scrollspeed (fast -> slow)
      • From a31e4dcd9ff0c00560bad9f6f071c5444c9b524f Mon Sep 17 00:00:00 2001 From: Sir Garbagetruck Date: Tue, 27 Sep 2016 22:22:26 +0300 Subject: [PATCH 10/36] make note that we should try to get this as an app - should fix some of the issues with local files. --- todo.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/todo.txt b/todo.txt index f26a2e7..f29534b 100644 --- a/todo.txt +++ b/todo.txt @@ -7,3 +7,4 @@ (C) SAHLI ansi & ascii for load page (C) redo load page (not popup, info) (B) Preload +(C) Chrome app From 26af6681cea582ac53404dc4c5597ec70e8e0801 Mon Sep 17 00:00:00 2001 From: Sir Garbagetruck Date: Tue, 27 Sep 2016 22:41:26 +0300 Subject: [PATCH 11/36] Giant warning goes away, it works without f*cking with settings. - I wonder why it works and if that means something is b0rked in firefox --- README.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8ff3cb9..c171394 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ idea... * Android tablets ARE considered modern; Ipad/Iphone too. * I haven't tested on MorphOS yet. +For Chrome/Chromium: + To use with _local_ files you need to run your browser in "developer" mode, that means: @@ -68,19 +70,15 @@ explaining how to do this and alternatives here: https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally -As you can see from that, as of right now (September 2016) -if you're using Firefox, you should be EXTREMELY CAREFUL and be -100% SURE YOU CHANGE THE SETTING BACK! +Firefox (and Icecat, possibly other Firefox codebased browsers) +seem to work today (Sept 2016) _without_ making any changes, so +you can use it 'out of the box.' M0qui was able to, and I tested, +and so the big 72-point "not supported on Windows+Firefox" warning +goes away. -** ESPECIALLY ON WINDOWS FOR CRYING OUT LOUD ** - -Look if you're using Windows and Firefox to use this, and _YOU_ -don't set the setting back, YOU ARE GOING TO GET FUCKED. - -BECAUSE OF THIS: I DO NOT RECCOMEND, OR SUPPORT, RUNNING THIS -ON WINDOWS AND FIREFOX. It works. I do not RECCOMEND it or -support it. Someone is going to come back and fuck me over -because of their stupidity and choice of OS. Fuck that. +Again, DON'T FREAKING TURN OFF JAVASCRIPT SECURITY AND FORGET TO +TURN IT BACK ON. DON'T. NOT JUST ON WINDOWS. BUT ESPECIALLY ON +WINDOWS. I may be able to turn this into a chrome app at some point, which will eliminate that issue. Possibly also a Firefox solution, but: From 847615943324376dac07cb6c5dc74a3cfef3dc59 Mon Sep 17 00:00:00 2001 From: Sir Garbagetruck Date: Tue, 27 Sep 2016 22:42:25 +0300 Subject: [PATCH 12/36] Oh yes, we need these files for people who aren't compiling themselves. --- editor/sahliedit.js | 48 ++++++++++++++++++++++----------------------- sahli.js | 25 +++++------------------ 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/editor/sahliedit.js b/editor/sahliedit.js index 678a60e..45237d7 100644 --- a/editor/sahliedit.js +++ b/editor/sahliedit.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.11.0 (function() { var Sahli, ansiorascii, arraytocolor, booltoint, colorindex, colortoarray, colortoname, dec2hex, dumpjson, emptyfiledef, getfilelist, hex2dec, inttobool, loadsahli, newsahli, resolvefiletype, sahlicolor, statustobool; @@ -163,19 +163,19 @@ }; Sahli.prototype.buildlist = function(data) { - var i, item, x, _i, _j, _len, _len1, _ref, _ref1; + var i, item, j, k, len, len1, ref, ref1, x; $('#list').show(100); $('#list ol li').remove(); - _ref = this.data.filedata; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - i = _ref[_i]; + ref = this.data.filedata; + for (j = 0, len = ref.length; j < len; j++) { + i = ref[j]; console.log(i.author); } x = 0; $('#dirlocation').val(this.data.location); - _ref1 = this.data.filedata; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - item = _ref1[_j]; + ref1 = this.data.filedata; + for (k = 0, len1 = ref1.length; k < len1; k++) { + item = ref1[k]; $('#sortlist').append(this.additem(item, x++)); } return $('#sortlist').sortable({ @@ -186,13 +186,13 @@ }, stop: (function(_this) { return function(event, ui) { - var e, name, s, _k, _len2, _ref2; + var e, l, len2, name, ref2, s; s = ui.item.data().startpos; e = ui.item.index(); _this.data.filedata = _this.rearrangearray(s, e, _this.data.filedata); - _ref2 = _this.data.filedata; - for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { - name = _ref2[_k]; + ref2 = _this.data.filedata; + for (l = 0, len2 = ref2.length; l < len2; l++) { + name = ref2[l]; console.log(name.author, name.name, name.file); } console.log('---'); @@ -367,13 +367,13 @@ arraytocolor = function(array) { var c, x; c = ((function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = array.length; _i < _len; _i++) { - x = array[_i]; - _results.push(dec2hex(x)); + var j, len, results; + results = []; + for (j = 0, len = array.length; j < len; j++) { + x = array[j]; + results.push(dec2hex(x)); } - return _results; + return results; })()).slice(0, 3).join(''); return "#" + c; }; @@ -383,13 +383,13 @@ color = color.slice(1); c1 = [color.slice(0, 2), color.slice(2, 4), color.slice(4, 6)]; x = (function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = c1.length; _i < _len; _i++) { - i = c1[_i]; - _results.push(hex2dec(i)); + var j, len, results; + results = []; + for (j = 0, len = c1.length; j < len; j++) { + i = c1[j]; + results.push(hex2dec(i)); } - return _results; + return results; })(); x.push(255); return x; diff --git a/sahli.js b/sahli.js index d3f2c48..a80b989 100644 --- a/sahli.js +++ b/sahli.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.3 +// Generated by CoffeeScript 1.11.0 /* .___________________________________, ___ @@ -173,28 +173,13 @@ l__________/__________|___|______l__________j_____j }; Sahli.prevpic = function() { - var filedata, i, viewbox; - viewbox = $('div#sahliviewer'); - viewbox.children().remove(); - $('#panel').empty(); - Sahli.scroll_direction = 1; - Sahli.scroll_speed = 5; - filedata = Sahli.filedata; + var i; i = Sahli.currentpic - 2; if (i < 0) { - i = i + filedata.length; + i = i + Sahli.filedata.length; } - filedata[i].pic = $('
        ' + filedata[i].file + '
        '); - viewbox.append(filedata[i].pic); - Sahli.loadpic(filedata[i], filedata[i].pic); - Sahli.currentpic = i + 1; - if (Sahli.currentpic > filedata.length - 1) { - Sahli.currentpic = 0; - } - $('#panel').hide(); - $('#outbox').show(); - $('body').stop(); - return Sahli.loadinfopanel(i); + Sahli.currentpic = i; + return Sahli.nextpic(); }; Sahli.togglefullscreen = function() { From 4f884d9caccbdaaf9bb28d25b68c3910041bf015 Mon Sep 17 00:00:00 2001 From: m0qui Date: Sat, 18 Mar 2017 19:27:43 +0100 Subject: [PATCH 13/36] Added generic picture support --- index.html | 2 +- sahli.coffee | 18 ++++++++++++++++-- sahli.css | 1 + sahli.js | 23 ++++++++++++++++++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index e070433..d7dc837 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ diff --git a/sahli.coffee b/sahli.coffee index 9b2bb39..891d5b1 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -39,6 +39,8 @@ class @Sahli @loadhugeansi picdata, inserthere when 'tundra' @loadhugeansi picdata, inserthere + when 'image' + @loadpicture picdata, inserthere else @loadplain picdata, inserthere @@ -78,6 +80,18 @@ class @Sahli req.open 'GET', fname, true req.send null + @loadpicture = (picdata, inserthere) -> + fname = @location + '/' + picdata.file + pdiv = $('
        ') + pdiv.addClass 'scrolly' + pdiv.width picdata.width + pdiv.css 'display', 'inline-block' + pimg = $('') + pdiv.append pimg + inserthere.after pdiv + $('body').scrollTop 0 + @origwidth = picdata.width + @loadhugeansi = (picdata, inserthere) -> fname = @location + '/' + picdata.file pdiv = $('
        ') @@ -97,7 +111,7 @@ class @Sahli @origwidth = canvwidth @origheight = calcheight pdiv.width canvwidth - ), 30, 'bits': '8' + ), 30, {'bits': '8', "font": picdata.font} @loadavatar = (picdata, inserthere) -> console.log 'avatar', picdata, inserthere @@ -237,7 +251,7 @@ class @Sahli zoomee.width newwidth $('canvas').width newwidth else - if zoomee.width() != @origwidth + if ''+zoomee.width() != ''+@origwidth zoomee.width @origwidth $('canvas').width '100%' else diff --git a/sahli.css b/sahli.css index b0a213a..7e13eb6 100644 --- a/sahli.css +++ b/sahli.css @@ -35,6 +35,7 @@ body { h6 { color: transparent; background-color: transparent; + display: none; } .help { diff --git a/sahli.js b/sahli.js index a80b989..7c81f8d 100644 --- a/sahli.js +++ b/sahli.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.11.0 +// Generated by CoffeeScript 1.9.3 /* .___________________________________, ___ @@ -40,6 +40,8 @@ l__________/__________|___|______l__________j_____j return this.loadhugeansi(picdata, inserthere); case 'tundra': return this.loadhugeansi(picdata, inserthere); + case 'image': + return this.loadpicture(picdata, inserthere); default: return this.loadplain(picdata, inserthere); } @@ -87,6 +89,20 @@ l__________/__________|___|______l__________j_____j return req.send(null); }; + Sahli.loadpicture = function(picdata, inserthere) { + var fname, pdiv, pimg; + fname = this.location + '/' + picdata.file; + pdiv = $('
        '); + pdiv.addClass('scrolly'); + pdiv.width(picdata.width); + pdiv.css('display', 'inline-block'); + pimg = $(''); + pdiv.append(pimg); + inserthere.after(pdiv); + $('body').scrollTop(0); + return this.origwidth = picdata.width; + }; + Sahli.loadhugeansi = function(picdata, inserthere) { var calcheight, canvwidth, fname, pdiv; fname = this.location + '/' + picdata.file; @@ -111,7 +127,8 @@ l__________/__________|___|______l__________j_____j return pdiv.width(canvwidth); }; })(this)), 30, { - 'bits': '8' + 'bits': '8', + "font": picdata.font }); }; @@ -280,7 +297,7 @@ l__________/__________|___|______l__________j_____j zoomee.width(newwidth); return $('canvas').width(newwidth); } else { - if (zoomee.width() !== this.origwidth) { + if ('' + zoomee.width() !== '' + this.origwidth) { zoomee.width(this.origwidth); return $('canvas').width('100%'); } else { From df6a50ad7bed3a221ed51ea38791fe764f74a95b Mon Sep 17 00:00:00 2001 From: m0qui Date: Sun, 19 Mar 2017 14:58:15 +0100 Subject: [PATCH 14/36] Revert "Added generic picture support" This reverts commit 4f884d9caccbdaaf9bb28d25b68c3910041bf015. --- index.html | 2 +- sahli.coffee | 18 ++---------------- sahli.css | 1 - sahli.js | 23 +++-------------------- 4 files changed, 6 insertions(+), 38 deletions(-) diff --git a/index.html b/index.html index d7dc837..e070433 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ diff --git a/sahli.coffee b/sahli.coffee index 891d5b1..9b2bb39 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -39,8 +39,6 @@ class @Sahli @loadhugeansi picdata, inserthere when 'tundra' @loadhugeansi picdata, inserthere - when 'image' - @loadpicture picdata, inserthere else @loadplain picdata, inserthere @@ -80,18 +78,6 @@ class @Sahli req.open 'GET', fname, true req.send null - @loadpicture = (picdata, inserthere) -> - fname = @location + '/' + picdata.file - pdiv = $('
        ') - pdiv.addClass 'scrolly' - pdiv.width picdata.width - pdiv.css 'display', 'inline-block' - pimg = $('') - pdiv.append pimg - inserthere.after pdiv - $('body').scrollTop 0 - @origwidth = picdata.width - @loadhugeansi = (picdata, inserthere) -> fname = @location + '/' + picdata.file pdiv = $('
        ') @@ -111,7 +97,7 @@ class @Sahli @origwidth = canvwidth @origheight = calcheight pdiv.width canvwidth - ), 30, {'bits': '8', "font": picdata.font} + ), 30, 'bits': '8' @loadavatar = (picdata, inserthere) -> console.log 'avatar', picdata, inserthere @@ -251,7 +237,7 @@ class @Sahli zoomee.width newwidth $('canvas').width newwidth else - if ''+zoomee.width() != ''+@origwidth + if zoomee.width() != @origwidth zoomee.width @origwidth $('canvas').width '100%' else diff --git a/sahli.css b/sahli.css index 7e13eb6..b0a213a 100644 --- a/sahli.css +++ b/sahli.css @@ -35,7 +35,6 @@ body { h6 { color: transparent; background-color: transparent; - display: none; } .help { diff --git a/sahli.js b/sahli.js index 7c81f8d..a80b989 100644 --- a/sahli.js +++ b/sahli.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.3 +// Generated by CoffeeScript 1.11.0 /* .___________________________________, ___ @@ -40,8 +40,6 @@ l__________/__________|___|______l__________j_____j return this.loadhugeansi(picdata, inserthere); case 'tundra': return this.loadhugeansi(picdata, inserthere); - case 'image': - return this.loadpicture(picdata, inserthere); default: return this.loadplain(picdata, inserthere); } @@ -89,20 +87,6 @@ l__________/__________|___|______l__________j_____j return req.send(null); }; - Sahli.loadpicture = function(picdata, inserthere) { - var fname, pdiv, pimg; - fname = this.location + '/' + picdata.file; - pdiv = $('
        '); - pdiv.addClass('scrolly'); - pdiv.width(picdata.width); - pdiv.css('display', 'inline-block'); - pimg = $(''); - pdiv.append(pimg); - inserthere.after(pdiv); - $('body').scrollTop(0); - return this.origwidth = picdata.width; - }; - Sahli.loadhugeansi = function(picdata, inserthere) { var calcheight, canvwidth, fname, pdiv; fname = this.location + '/' + picdata.file; @@ -127,8 +111,7 @@ l__________/__________|___|______l__________j_____j return pdiv.width(canvwidth); }; })(this)), 30, { - 'bits': '8', - "font": picdata.font + 'bits': '8' }); }; @@ -297,7 +280,7 @@ l__________/__________|___|______l__________j_____j zoomee.width(newwidth); return $('canvas').width(newwidth); } else { - if ('' + zoomee.width() !== '' + this.origwidth) { + if (zoomee.width() !== this.origwidth) { zoomee.width(this.origwidth); return $('canvas').width('100%'); } else { From 4bee0d69d33dd3febccbefecc6a184caf9b0a70e Mon Sep 17 00:00:00 2001 From: m0qui Date: Mon, 20 Mar 2017 09:02:41 +0100 Subject: [PATCH 15/36] Added generic picture support with best fit option --- index.html | 1 + list.sahli | 50 ++++++++++++++++++++++++++++ sahli.coffee | 33 ++++++++++++++++-- sahli.css | 12 +++++++ sahli.js | 40 ++++++++++++++++++++-- testshow/AD - Green Beam.scaled.png | Bin 0 -> 16722 bytes testshow/om-boss.png | Bin 0 -> 3153 bytes 7 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 testshow/AD - Green Beam.scaled.png create mode 100644 testshow/om-boss.png diff --git a/index.html b/index.html index e070433..233d273 100644 --- a/index.html +++ b/index.html @@ -47,6 +47,7 @@
      • B Jump to Bottom
      • 12345 Alter scrollspeed (fast -> slow)
      • Z Zoom full width
      • +
      • Q Best fit for images
      • ER Zoom in steps larger/smaller
      • C "panel" view toggle
      • UpDownPageupPagedown Move about by line/page
      • diff --git a/list.sahli b/list.sahli index e394280..5e6ceb5 100644 --- a/list.sahli +++ b/list.sahli @@ -14,6 +14,56 @@ "filedata": [ + { + "file": "AD - Green Beam.scaled.png", + "name": "Green Beam", + "amiga": false, + "filetype": "image", + "width": "1600", + "author": "AD", + "font": "Propaz", + "color": [ + 0, + 0, + 0, + 255 + ], + "bg": [ + 255, + 255, + 255, + 255 + ], + "line1": "", + "line2": "", + "text": "" + }, + + { + "file": "om-boss.png", + "name": "Green Beam", + "amiga": false, + "filetype": "image", + "width": "640", + "author": "AD", + "font": "Propaz", + "color": [ + 0, + 0, + 0, + 255 + ], + "bg": [ + 255, + 255, + 255, + 255 + ], + "line1": "", + "line2": "", + "text": "" + }, + { "file": "spaceflight.asc", diff --git a/sahli.coffee b/sahli.coffee index 9b2bb39..f1f313b 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -39,6 +39,8 @@ class @Sahli @loadhugeansi picdata, inserthere when 'tundra' @loadhugeansi picdata, inserthere + when 'image' + @loadpicture picdata, inserthere else @loadplain picdata, inserthere @@ -78,6 +80,29 @@ class @Sahli req.open 'GET', fname, true req.send null + @loadpicture = (picdata, inserthere) -> + fname = @location + '/' + picdata.file + pdiv = $('
        ') + pdiv.addClass 'scrolly' + pdiv.width picdata.width + pdiv.css 'display', 'inline-block' + pimg = $('') + pimg.addClass 'fullwidth' + pdiv.append pimg + inserthere.after pdiv + $('h6').hide() + $('body').scrollTop 0 + @origwidth = picdata.width + + @bestfit = => + if $('div.scrolly').hasClass('bestfit') + $('div.scrolly').removeClass 'bestfit' + $('div.scrolly').width @origwidth + else + $('h6').hide() + $('div.scrolly').addClass 'bestfit' + $('div.scrolly').width(""); + @loadhugeansi = (picdata, inserthere) -> fname = @location + '/' + picdata.file pdiv = $('
        ') @@ -97,7 +122,7 @@ class @Sahli @origwidth = canvwidth @origheight = calcheight pdiv.width canvwidth - ), 30, 'bits': '8' + ), 30, {'bits': '8', "font": picdata.font} @loadavatar = (picdata, inserthere) -> console.log 'avatar', picdata, inserthere @@ -137,6 +162,7 @@ class @Sahli filedata = @filedata filedata[i].pic = $('
        ' + filedata[i].file + '
        ') viewbox.append filedata[i].pic + $('h6').show() @loadpic filedata[i], filedata[i].pic @currentpic += 1 if @currentpic > filedata.length - 1 @@ -237,7 +263,7 @@ class @Sahli zoomee.width newwidth $('canvas').width newwidth else - if zoomee.width() != @origwidth + if parseInt( zoomee.width(), 10 ) != parseInt( @origwidth, 10) zoomee.width @origwidth $('canvas').width '100%' else @@ -342,6 +368,8 @@ class @Sahli @zoom 100 when @keycode 'r' @zoom -100 + when @keycode 'q' + @bestfit() when @keycode 'w' @changescrolldirection -1 when @keycode 'x' @@ -351,6 +379,7 @@ class @Sahli when @keycode 'i' $('div.infobox').toggle() when @keycode 'v' + $('h6').show() $('h6').height( (window.innerHeight - $('.scrolly').height()) / 2 ) when @keycode '1' @changespeed 1 diff --git a/sahli.css b/sahli.css index b0a213a..2429eae 100644 --- a/sahli.css +++ b/sahli.css @@ -52,6 +52,18 @@ h6 { width: 33%; } +.fullwidth { + width: 100%; +} + +.bestfit { + padding: 0; + display: block; + margin: 0 auto; + max-width: 100%; + max-height: 100%; +} + .keylist { border: inset lightgrey; background-color: white; diff --git a/sahli.js b/sahli.js index a80b989..7872b6d 100644 --- a/sahli.js +++ b/sahli.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.11.0 +// Generated by CoffeeScript 1.9.3 /* .___________________________________, ___ @@ -40,6 +40,8 @@ l__________/__________|___|______l__________j_____j return this.loadhugeansi(picdata, inserthere); case 'tundra': return this.loadhugeansi(picdata, inserthere); + case 'image': + return this.loadpicture(picdata, inserthere); default: return this.loadplain(picdata, inserthere); } @@ -87,6 +89,33 @@ l__________/__________|___|______l__________j_____j return req.send(null); }; + Sahli.loadpicture = function(picdata, inserthere) { + var fname, pdiv, pimg; + fname = this.location + '/' + picdata.file; + pdiv = $('
        '); + pdiv.addClass('scrolly'); + pdiv.width(picdata.width); + pdiv.css('display', 'inline-block'); + pimg = $(''); + pimg.addClass('fullwidth'); + pdiv.append(pimg); + inserthere.after(pdiv); + $('h6').hide(); + $('body').scrollTop(0); + return this.origwidth = picdata.width; + }; + + Sahli.bestfit = function() { + if ($('div.scrolly').hasClass('bestfit')) { + $('div.scrolly').removeClass('bestfit'); + return $('div.scrolly').width(Sahli.origwidth); + } else { + $('h6').hide(); + $('div.scrolly').addClass('bestfit'); + return $('div.scrolly').width(""); + } + }; + Sahli.loadhugeansi = function(picdata, inserthere) { var calcheight, canvwidth, fname, pdiv; fname = this.location + '/' + picdata.file; @@ -111,7 +140,8 @@ l__________/__________|___|______l__________j_____j return pdiv.width(canvwidth); }; })(this)), 30, { - 'bits': '8' + 'bits': '8', + "font": picdata.font }); }; @@ -161,6 +191,7 @@ l__________/__________|___|______l__________j_____j filedata = Sahli.filedata; filedata[i].pic = $('
        ' + filedata[i].file + '
        '); viewbox.append(filedata[i].pic); + $('h6').show(); Sahli.loadpic(filedata[i], filedata[i].pic); Sahli.currentpic += 1; if (Sahli.currentpic > filedata.length - 1) { @@ -280,7 +311,7 @@ l__________/__________|___|______l__________j_____j zoomee.width(newwidth); return $('canvas').width(newwidth); } else { - if (zoomee.width() !== this.origwidth) { + if (parseInt(zoomee.width(), 10) !== parseInt(this.origwidth, 10)) { zoomee.width(this.origwidth); return $('canvas').width('100%'); } else { @@ -404,6 +435,8 @@ l__________/__________|___|______l__________j_____j return _this.zoom(100); case _this.keycode('r'): return _this.zoom(-100); + case _this.keycode('q'): + return _this.bestfit(); case _this.keycode('w'): return _this.changescrolldirection(-1); case _this.keycode('x'): @@ -413,6 +446,7 @@ l__________/__________|___|______l__________j_____j case _this.keycode('i'): return $('div.infobox').toggle(); case _this.keycode('v'): + $('h6').show(); return $('h6').height((window.innerHeight - $('.scrolly').height()) / 2); case _this.keycode('1'): return _this.changespeed(1); diff --git a/testshow/AD - Green Beam.scaled.png b/testshow/AD - Green Beam.scaled.png new file mode 100644 index 0000000000000000000000000000000000000000..fbecb25f9bea7fe1f6a26564d1e213bb094d1ce3 GIT binary patch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$|s4iNgFkP#;g2@}iw%mvXBxa|uUsRXlzo zRT&S2}J>G0f>ji85F+EDmP0m@$4kd4}2$!dx??8V15Pj z*W0y!kgtb{uM1!>^kytr-cZ0d=O~e>9;dPT4FB-Sgt#OReO~>N3Y2Vb8h;@2wm;s@ zUGG8-PFMkV#$SwFfg_%P71qBWd{~Xq0*|8rl~mQUn|{B}jNBpp?d`%4+4c`2-A!z| zF3Bd$koL}P5Am5N;FK-Cz-arzra=(0U+34rf5sy(xtsu|p|0puA|d!_(kwTeor~|g z;`3R;*t{?YIU+Y*lmyRMK^`bTh@xA{o?;q)-Rr$!H@RSkiLqZ{Wv>Z6_oZ;3O!AeE9gvO}{L-<=7 zIDB>Rx7iawu%CYp8_CT{>XdY$Bs7|Jb9xfdy^3PKU+P%$wsHXXiYw&C()S>+gviA= zMQGT8osS95MT7-?xKgEwZ_8V+RmSBM)oX7tS&w^c{>=pXsp;LVh3=W#9Z^z^wj+Yz z;d{Rz{@=!7%P*}Ryi1HLAdJOE-Y&uA+12#rYWL<_-QE^zRY@7<>N8D47~fJ^sjl z6_EDp{{kSP;Fmwz3P;HY7cXt*1>jv1pmK3wF;)NL-~U+Ix!l*OXo-10$NZ`KC_zU= z1{B#5iR{e(@7wg*vwDWy-ms>3mYid_^X1ixMK@kSPaIL|qlft6Fn>fDiBQ+sQ$_vL mg8-RqA+UcwmKcZEC>nC_9jPBf(~uJdD9AjPE|xTU`~LvsZGC|N literal 0 HcmV?d00001 diff --git a/testshow/om-boss.png b/testshow/om-boss.png new file mode 100644 index 0000000000000000000000000000000000000000..e3abd45d77f1fefb01990f9921494133afa88b41 GIT binary patch literal 3153 zcmXX|c_36>8^8C?jBPNZ>{;f`k}YFN*&Eq+*-FYxA4O%&@>+^JEy|db*OC^pWGP#+ zg)rq!wzQxuVM+;^5{azenZECjnRD(v_dLt*`8`XLi<7mGfV2PvK|;1R7OoJ416#}m z7z37nM}#S0;c;3v=4Rp0ol&sk54G_Mhamh`?hl4;-j)O}c_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!wiw$;llgBNfNbHK3_rUvZWLixdM;fA`Wjpc&16%0GM zBbq$6U0S6@ww+@Tdo8m74IpS3)2JQDkb(t<lwjeUb`hN2p+B%id^Y` zte3l<1|zeXYW+*>cCR5PlT|FxyH2@x>%!ED5}OY7FPglC9y3b!SOis+l5uVoz6ZNbEHz91Xs zdlmNL9$vLmH$SJ;3x&Q&@i$)E!jUlJq(f_Nly@-m<<6gC4|$V#)C0M73r}%&JGvY9 zo8%SZ-;LOPkC$Y%BF48;k6$Y*tzL{@X6~Rvo5FJuRyWNaR-AIe4^DT(YwD~%DeX(q zu{!y^r@#~gH=+`Uq)uHcE6&(YjTB{5VV{o6AsxO)9{1&mYr fL!i06!fWyk_mAXsQ5Oz@;UBWKbh4<}M?3dlSEEvS literal 0 HcmV?d00001 From 99f6dc1504c84ba35d11196c54d8cda8ffb8be19 Mon Sep 17 00:00:00 2001 From: m0qui Date: Sat, 8 Apr 2017 12:19:26 +0200 Subject: [PATCH 16/36] Bestfit mode only enabled for filetype:image --- sahli.coffee | 16 +++++++++------- sahli.js | 17 ++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/sahli.coffee b/sahli.coffee index f1f313b..f2f688a 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -84,6 +84,7 @@ class @Sahli fname = @location + '/' + picdata.file pdiv = $('
        ') pdiv.addClass 'scrolly' + pdiv.addClass 'image' pdiv.width picdata.width pdiv.css 'display', 'inline-block' pimg = $('') @@ -95,13 +96,14 @@ class @Sahli @origwidth = picdata.width @bestfit = => - if $('div.scrolly').hasClass('bestfit') - $('div.scrolly').removeClass 'bestfit' - $('div.scrolly').width @origwidth - else - $('h6').hide() - $('div.scrolly').addClass 'bestfit' - $('div.scrolly').width(""); + if $('div.scrolly').hasClass('image') + if $('div.scrolly').hasClass('bestfit') + $('div.scrolly').removeClass 'bestfit' + $('div.scrolly').width @origwidth + else + $('h6').hide() + $('div.scrolly').addClass 'bestfit' + $('div.scrolly').width(""); @loadhugeansi = (picdata, inserthere) -> fname = @location + '/' + picdata.file diff --git a/sahli.js b/sahli.js index 7872b6d..0d7fc7c 100644 --- a/sahli.js +++ b/sahli.js @@ -94,6 +94,7 @@ l__________/__________|___|______l__________j_____j fname = this.location + '/' + picdata.file; pdiv = $('
        '); pdiv.addClass('scrolly'); + pdiv.addClass('image'); pdiv.width(picdata.width); pdiv.css('display', 'inline-block'); pimg = $(''); @@ -106,13 +107,15 @@ l__________/__________|___|______l__________j_____j }; Sahli.bestfit = function() { - if ($('div.scrolly').hasClass('bestfit')) { - $('div.scrolly').removeClass('bestfit'); - return $('div.scrolly').width(Sahli.origwidth); - } else { - $('h6').hide(); - $('div.scrolly').addClass('bestfit'); - return $('div.scrolly').width(""); + if ($('div.scrolly').hasClass('image')) { + if ($('div.scrolly').hasClass('bestfit')) { + $('div.scrolly').removeClass('bestfit'); + return $('div.scrolly').width(Sahli.origwidth); + } else { + $('h6').hide(); + $('div.scrolly').addClass('bestfit'); + return $('div.scrolly').width(""); + } } }; From a01c9ca3b7b38a95e137725c664f024fcc7aead9 Mon Sep 17 00:00:00 2001 From: m0qui Date: Sat, 8 Apr 2017 13:12:36 +0200 Subject: [PATCH 17/36] Bestfit mode now actually working --- sahli.coffee | 19 +++++++++++++++---- sahli.js | 23 +++++++++++++++++------ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/sahli.coffee b/sahli.coffee index f2f688a..1f58292 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -94,16 +94,27 @@ class @Sahli $('h6').hide() $('body').scrollTop 0 @origwidth = picdata.width + @origheight = picdata.height @bestfit = => + viewbox = $('div#sahliviewer') if $('div.scrolly').hasClass('image') - if $('div.scrolly').hasClass('bestfit') - $('div.scrolly').removeClass 'bestfit' + if $('div.scrolly').hasClass('bestfitMode') + $('div.scrolly').removeClass 'bestfitMode' + $('div.scrolly').addClass 'fullwidthMode' $('div.scrolly').width @origwidth + $('div.scrolly').height("") + $('img.bestfit').addClass 'fullwidth' + $('img.bestfit').removeClass 'bestfit' else $('h6').hide() - $('div.scrolly').addClass 'bestfit' - $('div.scrolly').width(""); + $('div.scrolly').addClass 'bestfitMode' + $('div.scrolly').removeClass 'fullwidthMode' + $('div.scrolly').width window.innerWidth + $('div.scrolly').height window.innerHeight + $('img.fullwidth').addClass 'bestfit' + $('img.fullwidth').removeClass 'fullwidth' + ##$('div.scrolly').width(""); @loadhugeansi = (picdata, inserthere) -> fname = @location + '/' + picdata.file diff --git a/sahli.js b/sahli.js index 0d7fc7c..8d34ee5 100644 --- a/sahli.js +++ b/sahli.js @@ -103,18 +103,29 @@ l__________/__________|___|______l__________j_____j inserthere.after(pdiv); $('h6').hide(); $('body').scrollTop(0); - return this.origwidth = picdata.width; + this.origwidth = picdata.width; + return this.origheight = picdata.height; }; Sahli.bestfit = function() { + var viewbox; + viewbox = $('div#sahliviewer'); if ($('div.scrolly').hasClass('image')) { - if ($('div.scrolly').hasClass('bestfit')) { - $('div.scrolly').removeClass('bestfit'); - return $('div.scrolly').width(Sahli.origwidth); + if ($('div.scrolly').hasClass('bestfitMode')) { + $('div.scrolly').removeClass('bestfitMode'); + $('div.scrolly').addClass('fullwidthMode'); + $('div.scrolly').width(Sahli.origwidth); + $('div.scrolly').height(""); + $('img.bestfit').addClass('fullwidth'); + return $('img.bestfit').removeClass('bestfit'); } else { $('h6').hide(); - $('div.scrolly').addClass('bestfit'); - return $('div.scrolly').width(""); + $('div.scrolly').addClass('bestfitMode'); + $('div.scrolly').removeClass('fullwidthMode'); + $('div.scrolly').width(window.innerWidth); + $('div.scrolly').height(window.innerHeight); + $('img.fullwidth').addClass('bestfit'); + return $('img.fullwidth').removeClass('fullwidth'); } } }; From b9363d5ec95185deb0e7d8aa427cf014222c0013 Mon Sep 17 00:00:00 2001 From: m0qui Date: Sat, 8 Apr 2017 13:23:06 +0200 Subject: [PATCH 18/36] Bestfit mode default for filetype:image --- sahli.coffee | 5 +++-- sahli.js | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sahli.coffee b/sahli.coffee index 1f58292..35b76bb 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -85,7 +85,7 @@ class @Sahli pdiv = $('
        ') pdiv.addClass 'scrolly' pdiv.addClass 'image' - pdiv.width picdata.width + pdiv.width window.innerWidth pdiv.css 'display', 'inline-block' pimg = $('') pimg.addClass 'fullwidth' @@ -95,6 +95,7 @@ class @Sahli $('body').scrollTop 0 @origwidth = picdata.width @origheight = picdata.height + @bestfit() @bestfit = => viewbox = $('div#sahliviewer') @@ -102,7 +103,7 @@ class @Sahli if $('div.scrolly').hasClass('bestfitMode') $('div.scrolly').removeClass 'bestfitMode' $('div.scrolly').addClass 'fullwidthMode' - $('div.scrolly').width @origwidth + $('div.scrolly').width window.innerWidth $('div.scrolly').height("") $('img.bestfit').addClass 'fullwidth' $('img.bestfit').removeClass 'bestfit' diff --git a/sahli.js b/sahli.js index 8d34ee5..6e4725c 100644 --- a/sahli.js +++ b/sahli.js @@ -95,7 +95,7 @@ l__________/__________|___|______l__________j_____j pdiv = $('
        '); pdiv.addClass('scrolly'); pdiv.addClass('image'); - pdiv.width(picdata.width); + pdiv.width(window.innerWidth); pdiv.css('display', 'inline-block'); pimg = $(''); pimg.addClass('fullwidth'); @@ -104,7 +104,8 @@ l__________/__________|___|______l__________j_____j $('h6').hide(); $('body').scrollTop(0); this.origwidth = picdata.width; - return this.origheight = picdata.height; + this.origheight = picdata.height; + return this.bestfit(); }; Sahli.bestfit = function() { @@ -114,7 +115,7 @@ l__________/__________|___|______l__________j_____j if ($('div.scrolly').hasClass('bestfitMode')) { $('div.scrolly').removeClass('bestfitMode'); $('div.scrolly').addClass('fullwidthMode'); - $('div.scrolly').width(Sahli.origwidth); + $('div.scrolly').width(window.innerWidth); $('div.scrolly').height(""); $('img.bestfit').addClass('fullwidth'); return $('img.bestfit').removeClass('bestfit'); From 68fb3c4b5aac29723a72ae82bea0e6689f8affe5 Mon Sep 17 00:00:00 2001 From: m0qui Date: Sat, 8 Apr 2017 14:48:13 +0200 Subject: [PATCH 19/36] Hide mouse cursor --- sahli.coffee | 3 +-- sahli.js | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sahli.coffee b/sahli.coffee index 35b76bb..0aa9357 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -14,6 +14,7 @@ l__________/__________|___|______l__________j_____j class @Sahli constructor: () -> + $('body').css('cursor', 'none'); # I don't think we actually are going to have one, as we don't # need instance variables (things used outside the function) @@ -98,7 +99,6 @@ class @Sahli @bestfit() @bestfit = => - viewbox = $('div#sahliviewer') if $('div.scrolly').hasClass('image') if $('div.scrolly').hasClass('bestfitMode') $('div.scrolly').removeClass 'bestfitMode' @@ -115,7 +115,6 @@ class @Sahli $('div.scrolly').height window.innerHeight $('img.fullwidth').addClass 'bestfit' $('img.fullwidth').removeClass 'fullwidth' - ##$('div.scrolly').width(""); @loadhugeansi = (picdata, inserthere) -> fname = @location + '/' + picdata.file diff --git a/sahli.js b/sahli.js index 6e4725c..30a3e25 100644 --- a/sahli.js +++ b/sahli.js @@ -16,7 +16,9 @@ l__________/__________|___|______l__________j_____j (function() { this.Sahli = (function() { - function Sahli() {} + function Sahli() { + $('body').css('cursor', 'none'); + } Sahli.loadpic = function(picdata, inserthere) { switch (picdata.filetype) { @@ -109,8 +111,6 @@ l__________/__________|___|______l__________j_____j }; Sahli.bestfit = function() { - var viewbox; - viewbox = $('div#sahliviewer'); if ($('div.scrolly').hasClass('image')) { if ($('div.scrolly').hasClass('bestfitMode')) { $('div.scrolly').removeClass('bestfitMode'); From 8f01863d39b8cae4f0d92d812e5b1a483d9f5ac4 Mon Sep 17 00:00:00 2001 From: wtf Date: Mon, 26 Mar 2018 10:08:35 +0200 Subject: [PATCH 20/36] Fix spacing in amiga/plain mode (aka
        )
        
        ---
         sahli.css | 4 ++++
         1 file changed, 4 insertions(+)
        
        diff --git a/sahli.css b/sahli.css
        index 2429eae..65a6496 100644
        --- a/sahli.css
        +++ b/sahli.css
        @@ -10,6 +10,10 @@ body {
             border: none;
         }
         
        +pre {
        +    line-height: 100%;
        +}
        +
         #top {
             border: 1px solid green;
             color: green;
        
        From 80a92fc0c07662ab41ad086e6503a7445b469927 Mon Sep 17 00:00:00 2001
        From: m0qui 
        Date: Mon, 26 Mar 2018 21:41:49 +0200
        Subject: [PATCH 21/36] Added feature to increase/decrease font size in
         Amiga/plain mode
        
        ---
         index.html   |  1 +
         list.sahli   | 52 +++-------------------------------------------------
         sahli.coffee | 15 ++++++++++++---
         sahli.js     | 17 ++++++++++++++---
         4 files changed, 30 insertions(+), 55 deletions(-)
        
        diff --git a/index.html b/index.html
        index 233d273..63b9fa1 100644
        --- a/index.html
        +++ b/index.html
        @@ -49,6 +49,7 @@
                 
      • Z Zoom full width
      • Q Best fit for images
      • ER Zoom in steps larger/smaller
      • +
      • 89 Incease/decrease font size by 2 (Amiga/plain mode)
      • C "panel" view toggle
      • UpDownPageupPagedown Move about by line/page
      • HomeEnd Move to top/bottom (no zoom reset)
      • diff --git a/list.sahli b/list.sahli index 5e6ceb5..0a19dfc 100644 --- a/list.sahli +++ b/list.sahli @@ -67,97 +67,51 @@ { "file": "spaceflight.asc", - "name": "Spaceflight", - "amiga": true, - "filetype": "plain", - "width": "80", - "author": "Urs", - "font": "pot-noodle", - "color": [ - 255, - 128, - 0, - 255 - ], - "bg": [ - 0, - 0, - 0, - 255 - ], - "line1": "Orange on Dark Grey", - "line2": "Test for plain files", - "text": "" - }, - { - "file": "az0!-revi510n.txt", - "name": "Revision", - "amiga": true, - "filetype": "plain", - "width": "80", - "author": "Azzarro/Madwizards", - - "font": "Propaz", - - "color": [ - + "font": "mosoul", + "color": [ 0, - 240, - 0, - 255 - ], - "bg": [ - 255, - 0, - 0, - 255 - ], - "line1": "Azzaro Returns", - "line2": "Revision ansi/ascii compo 2013", - - "text": "Color test as well as Microknight test." - + "text": "Color test as well as mOsOul test." }, { "file": "dS!-JUFV.txt", diff --git a/sahli.coffee b/sahli.coffee index 0aa9357..043bc09 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -52,6 +52,7 @@ class @Sahli buf = $('') buf.css {'margin':'0 auto'} ptxt = $('
        ')
        +    ptxt.addClass 'plaintext'
             color = @calccolor(picdata.color)
             bgcolor = @calccolor(picdata.bg)
             pdiv.addClass 'scrolly'
        @@ -61,9 +62,9 @@ class @Sahli
               'background-color': bgcolor
               'margin': 'auto'
               'display': 'inline-block'
        -    ptxt.width picdata.width * 8
        -    @origwidth = ptxt.width
        -    pdiv.width ptxt.width
        +    #ptxt.width picdata.width * 8
        +    #@origwidth = ptxt.width
        +    #pdiv.width ptxt.width
             pdiv.prepend buf.clone()
             pdiv.append ptxt
             pdiv.append buf
        @@ -81,6 +82,10 @@ class @Sahli
             req.open 'GET', fname, true
             req.send null
         
        +  @increaseFont = (node, increaseBy=5) ->
        +    current_size = parseInt($(node).css("font-size"));
        +    $(node).css("font-size", current_size + increaseBy);
        +
           @loadpicture = (picdata, inserthere) ->
             fname = @location + '/' + picdata.file
             pdiv = $('
        ') @@ -407,6 +412,10 @@ class @Sahli @scroll_speed = 4 when @keycode '5' @changespeed 5 + when @keycode '8' + @increaseFont($('pre'), -2) + when @keycode '9' + @increaseFont($('pre'), 2) when 40 # down @moveline 1 when 38 # up diff --git a/sahli.js b/sahli.js index 30a3e25..45def1d 100644 --- a/sahli.js +++ b/sahli.js @@ -59,6 +59,7 @@ l__________/__________|___|______l__________j_____j 'margin': '0 auto' }); ptxt = $('
        ');
        +      ptxt.addClass('plaintext');
               color = this.calccolor(picdata.color);
               bgcolor = this.calccolor(picdata.bg);
               pdiv.addClass('scrolly');
        @@ -69,9 +70,6 @@ l__________/__________|___|______l__________j_____j
                 'margin': 'auto',
                 'display': 'inline-block'
               });
        -      ptxt.width(picdata.width * 8);
        -      this.origwidth = ptxt.width;
        -      pdiv.width(ptxt.width);
               pdiv.prepend(buf.clone());
               pdiv.append(ptxt);
               pdiv.append(buf);
        @@ -91,6 +89,15 @@ l__________/__________|___|______l__________j_____j
               return req.send(null);
             };
         
        +    Sahli.increaseFont = function(node, increaseBy) {
        +      var current_size;
        +      if (increaseBy == null) {
        +        increaseBy = 5;
        +      }
        +      current_size = parseInt($(node).css("font-size"));
        +      return $(node).css("font-size", current_size + increaseBy);
        +    };
        +
             Sahli.loadpicture = function(picdata, inserthere) {
               var fname, pdiv, pimg;
               fname = this.location + '/' + picdata.file;
        @@ -476,6 +483,10 @@ l__________/__________|___|______l__________j_____j
                       return _this.scroll_speed = 4;
                     case _this.keycode('5'):
                       return _this.changespeed(5);
        +            case _this.keycode('8'):
        +              return _this.increaseFont($('pre'), -2);
        +            case _this.keycode('9'):
        +              return _this.increaseFont($('pre'), 2);
                     case 40:
                       return _this.moveline(1);
                     case 38:
        
        From 5e05d0fbb871bc350b187a8ad65f73829dc04d8d Mon Sep 17 00:00:00 2001
        From: m0qui 
        Date: Mon, 26 Mar 2018 21:54:03 +0200
        Subject: [PATCH 22/36] Added feature to increase/decrease font size in
         Amiga/plain mode
        
        ---
         index.html   |  1 +
         list.sahli   | 52 +++-------------------------------------------------
         sahli.coffee | 15 ++++++++++++---
         sahli.js     | 17 ++++++++++++++---
         4 files changed, 30 insertions(+), 55 deletions(-)
        
        diff --git a/index.html b/index.html
        index 233d273..63b9fa1 100644
        --- a/index.html
        +++ b/index.html
        @@ -49,6 +49,7 @@
                 
      • Z Zoom full width
      • Q Best fit for images
      • ER Zoom in steps larger/smaller
      • +
      • 89 Incease/decrease font size by 2 (Amiga/plain mode)
      • C "panel" view toggle
      • UpDownPageupPagedown Move about by line/page
      • HomeEnd Move to top/bottom (no zoom reset)
      • diff --git a/list.sahli b/list.sahli index 5e6ceb5..0a19dfc 100644 --- a/list.sahli +++ b/list.sahli @@ -67,97 +67,51 @@ { "file": "spaceflight.asc", - "name": "Spaceflight", - "amiga": true, - "filetype": "plain", - "width": "80", - "author": "Urs", - "font": "pot-noodle", - "color": [ - 255, - 128, - 0, - 255 - ], - "bg": [ - 0, - 0, - 0, - 255 - ], - "line1": "Orange on Dark Grey", - "line2": "Test for plain files", - "text": "" - }, - { - "file": "az0!-revi510n.txt", - "name": "Revision", - "amiga": true, - "filetype": "plain", - "width": "80", - "author": "Azzarro/Madwizards", - - "font": "Propaz", - - "color": [ - + "font": "mosoul", + "color": [ 0, - 240, - 0, - 255 - ], - "bg": [ - 255, - 0, - 0, - 255 - ], - "line1": "Azzaro Returns", - "line2": "Revision ansi/ascii compo 2013", - - "text": "Color test as well as Microknight test." - + "text": "Color test as well as mOsOul test." }, { "file": "dS!-JUFV.txt", diff --git a/sahli.coffee b/sahli.coffee index 0aa9357..043bc09 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -52,6 +52,7 @@ class @Sahli buf = $('') buf.css {'margin':'0 auto'} ptxt = $('
        ')
        +    ptxt.addClass 'plaintext'
             color = @calccolor(picdata.color)
             bgcolor = @calccolor(picdata.bg)
             pdiv.addClass 'scrolly'
        @@ -61,9 +62,9 @@ class @Sahli
               'background-color': bgcolor
               'margin': 'auto'
               'display': 'inline-block'
        -    ptxt.width picdata.width * 8
        -    @origwidth = ptxt.width
        -    pdiv.width ptxt.width
        +    #ptxt.width picdata.width * 8
        +    #@origwidth = ptxt.width
        +    #pdiv.width ptxt.width
             pdiv.prepend buf.clone()
             pdiv.append ptxt
             pdiv.append buf
        @@ -81,6 +82,10 @@ class @Sahli
             req.open 'GET', fname, true
             req.send null
         
        +  @increaseFont = (node, increaseBy=5) ->
        +    current_size = parseInt($(node).css("font-size"));
        +    $(node).css("font-size", current_size + increaseBy);
        +
           @loadpicture = (picdata, inserthere) ->
             fname = @location + '/' + picdata.file
             pdiv = $('
        ') @@ -407,6 +412,10 @@ class @Sahli @scroll_speed = 4 when @keycode '5' @changespeed 5 + when @keycode '8' + @increaseFont($('pre'), -2) + when @keycode '9' + @increaseFont($('pre'), 2) when 40 # down @moveline 1 when 38 # up diff --git a/sahli.js b/sahli.js index 30a3e25..45def1d 100644 --- a/sahli.js +++ b/sahli.js @@ -59,6 +59,7 @@ l__________/__________|___|______l__________j_____j 'margin': '0 auto' }); ptxt = $('
        ');
        +      ptxt.addClass('plaintext');
               color = this.calccolor(picdata.color);
               bgcolor = this.calccolor(picdata.bg);
               pdiv.addClass('scrolly');
        @@ -69,9 +70,6 @@ l__________/__________|___|______l__________j_____j
                 'margin': 'auto',
                 'display': 'inline-block'
               });
        -      ptxt.width(picdata.width * 8);
        -      this.origwidth = ptxt.width;
        -      pdiv.width(ptxt.width);
               pdiv.prepend(buf.clone());
               pdiv.append(ptxt);
               pdiv.append(buf);
        @@ -91,6 +89,15 @@ l__________/__________|___|______l__________j_____j
               return req.send(null);
             };
         
        +    Sahli.increaseFont = function(node, increaseBy) {
        +      var current_size;
        +      if (increaseBy == null) {
        +        increaseBy = 5;
        +      }
        +      current_size = parseInt($(node).css("font-size"));
        +      return $(node).css("font-size", current_size + increaseBy);
        +    };
        +
             Sahli.loadpicture = function(picdata, inserthere) {
               var fname, pdiv, pimg;
               fname = this.location + '/' + picdata.file;
        @@ -476,6 +483,10 @@ l__________/__________|___|______l__________j_____j
                       return _this.scroll_speed = 4;
                     case _this.keycode('5'):
                       return _this.changespeed(5);
        +            case _this.keycode('8'):
        +              return _this.increaseFont($('pre'), -2);
        +            case _this.keycode('9'):
        +              return _this.increaseFont($('pre'), 2);
                     case 40:
                       return _this.moveline(1);
                     case 38:
        
        From 8fd83c30405ffc09fe25b80a93d290ed78749e6b Mon Sep 17 00:00:00 2001
        From: m0qui 
        Date: Mon, 26 Mar 2018 22:09:44 +0200
        Subject: [PATCH 23/36] Canvas mode for Amiga/plain mode
        
        ---
         sahli.coffee | 2 ++
         sahli.js     | 2 ++
         2 files changed, 4 insertions(+)
        
        diff --git a/sahli.coffee b/sahli.coffee
        index 043bc09..2bc1dba 100644
        --- a/sahli.coffee
        +++ b/sahli.coffee
        @@ -416,6 +416,8 @@ class @Sahli
                   @increaseFont($('pre'), -2)
                 when @keycode '9'
                   @increaseFont($('pre'), 2)
        +        when @keycode '0'
        +          $('pre').css("font-size", "2.5vw");
                 when 40 # down
                   @moveline 1
                 when 38 # up
        diff --git a/sahli.js b/sahli.js
        index 45def1d..f391a42 100644
        --- a/sahli.js
        +++ b/sahli.js
        @@ -487,6 +487,8 @@ l__________/__________|___|______l__________j_____j
                       return _this.increaseFont($('pre'), -2);
                     case _this.keycode('9'):
                       return _this.increaseFont($('pre'), 2);
        +            case _this.keycode('0'):
        +              return $('pre').css("font-size", "2.5vw");
                     case 40:
                       return _this.moveline(1);
                     case 38:
        
        From 8212f2c679e4a61eaa116147f6823a2db672c8d4 Mon Sep 17 00:00:00 2001
        From: m0qui 
        Date: Mon, 26 Mar 2018 22:14:29 +0200
        Subject: [PATCH 24/36] Canvas mode for Amiga/plain mode
        
        ---
         index.html   | 2 +-
         sahli.coffee | 2 ++
         sahli.js     | 2 ++
         3 files changed, 5 insertions(+), 1 deletion(-)
        
        diff --git a/index.html b/index.html
        index 63b9fa1..af8265c 100644
        --- a/index.html
        +++ b/index.html
        @@ -49,7 +49,7 @@
                 
      • Z Zoom full width
      • Q Best fit for images
      • ER Zoom in steps larger/smaller
      • -
      • 89 Incease/decrease font size by 2 (Amiga/plain mode)
      • +
      • 89 Incease/decrease font size by 2 (Amiga/plain mode), 0 for full width
      • C "panel" view toggle
      • UpDownPageupPagedown Move about by line/page
      • HomeEnd Move to top/bottom (no zoom reset)
      • diff --git a/sahli.coffee b/sahli.coffee index 043bc09..2bc1dba 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -416,6 +416,8 @@ class @Sahli @increaseFont($('pre'), -2) when @keycode '9' @increaseFont($('pre'), 2) + when @keycode '0' + $('pre').css("font-size", "2.5vw"); when 40 # down @moveline 1 when 38 # up diff --git a/sahli.js b/sahli.js index 45def1d..f391a42 100644 --- a/sahli.js +++ b/sahli.js @@ -487,6 +487,8 @@ l__________/__________|___|______l__________j_____j return _this.increaseFont($('pre'), -2); case _this.keycode('9'): return _this.increaseFont($('pre'), 2); + case _this.keycode('0'): + return $('pre').css("font-size", "2.5vw"); case 40: return _this.moveline(1); case 38: From 7843f2953de8d7566c66b974facab945f3bc5076 Mon Sep 17 00:00:00 2001 From: m0qui Date: Tue, 27 Mar 2018 00:13:57 +0200 Subject: [PATCH 25/36] Clean up: z works on images, ascii & ansi; e/r works on ascii & ansi; t work on images, ascii & ansi --- index.html | 2 -- sahli.coffee | 39 +++++++++++++++++++++++++++++++-------- sahli.css | 4 ++-- sahli.js | 48 ++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 73 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index af8265c..e070433 100644 --- a/index.html +++ b/index.html @@ -47,9 +47,7 @@
      • B Jump to Bottom
      • 12345 Alter scrollspeed (fast -> slow)
      • Z Zoom full width
      • -
      • Q Best fit for images
      • ER Zoom in steps larger/smaller
      • -
      • 89 Incease/decrease font size by 2 (Amiga/plain mode), 0 for full width
      • C "panel" view toggle
      • UpDownPageupPagedown Move about by line/page
      • HomeEnd Move to top/bottom (no zoom reset)
      • diff --git a/sahli.coffee b/sahli.coffee index 2bc1dba..34af56e 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -103,6 +103,33 @@ class @Sahli @origheight = picdata.height @bestfit() + @fullwidthplain = => + if ($('pre').css("font-size") == "16px") + $('pre').css("font-size", "2.5vw"); + else + $('pre').css("font-size", "16px"); + + @togglefullwidthmode = => + if ($('pre').hasClass('plaintext')) + @fullwidthplain() + else + if $('div.scrolly').hasClass('image') + @bestfit() + else + @zoom() + + @zoomin = => + if ($('pre').hasClass('plaintext')) + @increaseFont($('pre'), 2) + else + @zoom(100); + + @zoomout = => + if ($('pre').hasClass('plaintext')) + @increaseFont($('pre'), -2) + else + @zoom(-100); + @bestfit = => if $('div.scrolly').hasClass('image') if $('div.scrolly').hasClass('bestfitMode') @@ -374,20 +401,18 @@ class @Sahli @setscroll() when @keycode 't' $('body').scrollTop 0 - @zoom 0 + @togglefullwidthmode() when @keycode 'b' $('body').scrollTop $('body').height() when @keycode 'a' $('body').stop() @scroll_direction = - @scroll_direction when @keycode 'z' - @zoom() + @togglefullwidthmode() when @keycode 'e' - @zoom 100 + @zoomin() when @keycode 'r' - @zoom -100 - when @keycode 'q' - @bestfit() + @zoomout() when @keycode 'w' @changescrolldirection -1 when @keycode 'x' @@ -416,8 +441,6 @@ class @Sahli @increaseFont($('pre'), -2) when @keycode '9' @increaseFont($('pre'), 2) - when @keycode '0' - $('pre').css("font-size", "2.5vw"); when 40 # down @moveline 1 when 38 # up diff --git a/sahli.css b/sahli.css index 65a6496..a47845b 100644 --- a/sahli.css +++ b/sahli.css @@ -44,7 +44,7 @@ h6 { .help { position: fixed; top: 1em; - left: 33%; + left: 25%; text-align: left; background-color: lightgrey; border: outset darkgray; @@ -53,7 +53,7 @@ h6 { border-radius: 8px; font-family: topaz1200,mOsOul, Consolas, monospace; opacity: .85; - width: 33%; + width: 50%; } .fullwidth { diff --git a/sahli.js b/sahli.js index f391a42..8168d21 100644 --- a/sahli.js +++ b/sahli.js @@ -117,6 +117,42 @@ l__________/__________|___|______l__________j_____j return this.bestfit(); }; + Sahli.fullwidthplain = function() { + if ($('pre').css("font-size") === "16px") { + return $('pre').css("font-size", "2.5vw"); + } else { + return $('pre').css("font-size", "16px"); + } + }; + + Sahli.togglefullwidthmode = function() { + if ($('pre').hasClass('plaintext')) { + return Sahli.fullwidthplain(); + } else { + if ($('div.scrolly').hasClass('image')) { + return Sahli.bestfit(); + } else { + return Sahli.zoom(); + } + } + }; + + Sahli.zoomin = function() { + if ($('pre').hasClass('plaintext')) { + return Sahli.increaseFont($('pre'), 2); + } else { + return Sahli.zoom(100); + } + }; + + Sahli.zoomout = function() { + if ($('pre').hasClass('plaintext')) { + return Sahli.increaseFont($('pre'), -2); + } else { + return Sahli.zoom(-100); + } + }; + Sahli.bestfit = function() { if ($('div.scrolly').hasClass('image')) { if ($('div.scrolly').hasClass('bestfitMode')) { @@ -445,20 +481,18 @@ l__________/__________|___|______l__________j_____j return _this.setscroll(); case _this.keycode('t'): $('body').scrollTop(0); - return _this.zoom(0); + return _this.togglefullwidthmode(); case _this.keycode('b'): return $('body').scrollTop($('body').height()); case _this.keycode('a'): $('body').stop(); return _this.scroll_direction = -_this.scroll_direction; case _this.keycode('z'): - return _this.zoom(); + return _this.togglefullwidthmode(); case _this.keycode('e'): - return _this.zoom(100); + return _this.zoomin(); case _this.keycode('r'): - return _this.zoom(-100); - case _this.keycode('q'): - return _this.bestfit(); + return _this.zoomout(); case _this.keycode('w'): return _this.changescrolldirection(-1); case _this.keycode('x'): @@ -487,8 +521,6 @@ l__________/__________|___|______l__________j_____j return _this.increaseFont($('pre'), -2); case _this.keycode('9'): return _this.increaseFont($('pre'), 2); - case _this.keycode('0'): - return $('pre').css("font-size", "2.5vw"); case 40: return _this.moveline(1); case 38: From 4c50e001ef4196d36ef2dc0cb1b745ac79f83a5e Mon Sep 17 00:00:00 2001 From: m0qui Date: Tue, 27 Mar 2018 00:17:18 +0200 Subject: [PATCH 26/36] Clean up: z works on images, ascii & ansi; e/r works on ascii & ansi; t work on images, ascii & ansi --- index.html | 2 -- sahli.coffee | 39 +++++++++++++++++++++++++++++++-------- sahli.css | 4 ++-- sahli.js | 48 ++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 73 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index 63b9fa1..e070433 100644 --- a/index.html +++ b/index.html @@ -47,9 +47,7 @@
      • B Jump to Bottom
      • 12345 Alter scrollspeed (fast -> slow)
      • Z Zoom full width
      • -
      • Q Best fit for images
      • ER Zoom in steps larger/smaller
      • -
      • 89 Incease/decrease font size by 2 (Amiga/plain mode)
      • C "panel" view toggle
      • UpDownPageupPagedown Move about by line/page
      • HomeEnd Move to top/bottom (no zoom reset)
      • diff --git a/sahli.coffee b/sahli.coffee index 2bc1dba..34af56e 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -103,6 +103,33 @@ class @Sahli @origheight = picdata.height @bestfit() + @fullwidthplain = => + if ($('pre').css("font-size") == "16px") + $('pre').css("font-size", "2.5vw"); + else + $('pre').css("font-size", "16px"); + + @togglefullwidthmode = => + if ($('pre').hasClass('plaintext')) + @fullwidthplain() + else + if $('div.scrolly').hasClass('image') + @bestfit() + else + @zoom() + + @zoomin = => + if ($('pre').hasClass('plaintext')) + @increaseFont($('pre'), 2) + else + @zoom(100); + + @zoomout = => + if ($('pre').hasClass('plaintext')) + @increaseFont($('pre'), -2) + else + @zoom(-100); + @bestfit = => if $('div.scrolly').hasClass('image') if $('div.scrolly').hasClass('bestfitMode') @@ -374,20 +401,18 @@ class @Sahli @setscroll() when @keycode 't' $('body').scrollTop 0 - @zoom 0 + @togglefullwidthmode() when @keycode 'b' $('body').scrollTop $('body').height() when @keycode 'a' $('body').stop() @scroll_direction = - @scroll_direction when @keycode 'z' - @zoom() + @togglefullwidthmode() when @keycode 'e' - @zoom 100 + @zoomin() when @keycode 'r' - @zoom -100 - when @keycode 'q' - @bestfit() + @zoomout() when @keycode 'w' @changescrolldirection -1 when @keycode 'x' @@ -416,8 +441,6 @@ class @Sahli @increaseFont($('pre'), -2) when @keycode '9' @increaseFont($('pre'), 2) - when @keycode '0' - $('pre').css("font-size", "2.5vw"); when 40 # down @moveline 1 when 38 # up diff --git a/sahli.css b/sahli.css index 65a6496..a47845b 100644 --- a/sahli.css +++ b/sahli.css @@ -44,7 +44,7 @@ h6 { .help { position: fixed; top: 1em; - left: 33%; + left: 25%; text-align: left; background-color: lightgrey; border: outset darkgray; @@ -53,7 +53,7 @@ h6 { border-radius: 8px; font-family: topaz1200,mOsOul, Consolas, monospace; opacity: .85; - width: 33%; + width: 50%; } .fullwidth { diff --git a/sahli.js b/sahli.js index f391a42..8168d21 100644 --- a/sahli.js +++ b/sahli.js @@ -117,6 +117,42 @@ l__________/__________|___|______l__________j_____j return this.bestfit(); }; + Sahli.fullwidthplain = function() { + if ($('pre').css("font-size") === "16px") { + return $('pre').css("font-size", "2.5vw"); + } else { + return $('pre').css("font-size", "16px"); + } + }; + + Sahli.togglefullwidthmode = function() { + if ($('pre').hasClass('plaintext')) { + return Sahli.fullwidthplain(); + } else { + if ($('div.scrolly').hasClass('image')) { + return Sahli.bestfit(); + } else { + return Sahli.zoom(); + } + } + }; + + Sahli.zoomin = function() { + if ($('pre').hasClass('plaintext')) { + return Sahli.increaseFont($('pre'), 2); + } else { + return Sahli.zoom(100); + } + }; + + Sahli.zoomout = function() { + if ($('pre').hasClass('plaintext')) { + return Sahli.increaseFont($('pre'), -2); + } else { + return Sahli.zoom(-100); + } + }; + Sahli.bestfit = function() { if ($('div.scrolly').hasClass('image')) { if ($('div.scrolly').hasClass('bestfitMode')) { @@ -445,20 +481,18 @@ l__________/__________|___|______l__________j_____j return _this.setscroll(); case _this.keycode('t'): $('body').scrollTop(0); - return _this.zoom(0); + return _this.togglefullwidthmode(); case _this.keycode('b'): return $('body').scrollTop($('body').height()); case _this.keycode('a'): $('body').stop(); return _this.scroll_direction = -_this.scroll_direction; case _this.keycode('z'): - return _this.zoom(); + return _this.togglefullwidthmode(); case _this.keycode('e'): - return _this.zoom(100); + return _this.zoomin(); case _this.keycode('r'): - return _this.zoom(-100); - case _this.keycode('q'): - return _this.bestfit(); + return _this.zoomout(); case _this.keycode('w'): return _this.changescrolldirection(-1); case _this.keycode('x'): @@ -487,8 +521,6 @@ l__________/__________|___|______l__________j_____j return _this.increaseFont($('pre'), -2); case _this.keycode('9'): return _this.increaseFont($('pre'), 2); - case _this.keycode('0'): - return $('pre').css("font-size", "2.5vw"); case 40: return _this.moveline(1); case 38: From d7c908a0335cac86e3465e330c4d86093895612e Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Thu, 9 Apr 2020 14:12:24 +0300 Subject: [PATCH 27/36] Add .gitignore; move old javascript editor thing out of the way - prepare for python editor --- .gitignore | 179 ++++++++++++++++++ {editor => editor-old-js}/jquery-2.1.0.min.js | 0 .../jquery-ui-dot-luv.css | 0 {editor => editor-old-js}/jquery-ui.min.js | 0 {editor => editor-old-js}/sahliedit.css | 0 {editor => editor-old-js}/sahliedit.js | 0 {editor => editor-old-js}/sahliedit.litcoffee | 0 {editor => editor-old-js}/sahlieditor.html | 0 8 files changed, 179 insertions(+) create mode 100644 .gitignore rename {editor => editor-old-js}/jquery-2.1.0.min.js (100%) rename {editor => editor-old-js}/jquery-ui-dot-luv.css (100%) rename {editor => editor-old-js}/jquery-ui.min.js (100%) rename {editor => editor-old-js}/sahliedit.css (100%) rename {editor => editor-old-js}/sahliedit.js (100%) rename {editor => editor-old-js}/sahliedit.litcoffee (100%) rename {editor => editor-old-js}/sahlieditor.html (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..277afac --- /dev/null +++ b/.gitignore @@ -0,0 +1,179 @@ +# Created by https://www.gitignore.io/api/git,emacs,python,coffeescript +# Edit at https://www.gitignore.io/?templates=git,emacs,python,coffeescript + +### CoffeeScript ### +*.js + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +#project settings +sahli-venv/* +*.wp* diff --git a/editor/jquery-2.1.0.min.js b/editor-old-js/jquery-2.1.0.min.js similarity index 100% rename from editor/jquery-2.1.0.min.js rename to editor-old-js/jquery-2.1.0.min.js diff --git a/editor/jquery-ui-dot-luv.css b/editor-old-js/jquery-ui-dot-luv.css similarity index 100% rename from editor/jquery-ui-dot-luv.css rename to editor-old-js/jquery-ui-dot-luv.css diff --git a/editor/jquery-ui.min.js b/editor-old-js/jquery-ui.min.js similarity index 100% rename from editor/jquery-ui.min.js rename to editor-old-js/jquery-ui.min.js diff --git a/editor/sahliedit.css b/editor-old-js/sahliedit.css similarity index 100% rename from editor/sahliedit.css rename to editor-old-js/sahliedit.css diff --git a/editor/sahliedit.js b/editor-old-js/sahliedit.js similarity index 100% rename from editor/sahliedit.js rename to editor-old-js/sahliedit.js diff --git a/editor/sahliedit.litcoffee b/editor-old-js/sahliedit.litcoffee similarity index 100% rename from editor/sahliedit.litcoffee rename to editor-old-js/sahliedit.litcoffee diff --git a/editor/sahlieditor.html b/editor-old-js/sahlieditor.html similarity index 100% rename from editor/sahlieditor.html rename to editor-old-js/sahlieditor.html From ec1905d37f98e6860bf9be8dfe4951c8df58c8c4 Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Thu, 9 Apr 2020 14:14:02 +0300 Subject: [PATCH 28/36] Create new python editor directory (and prepare for modules) --- sahli-editor-python/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sahli-editor-python/__init__.py diff --git a/sahli-editor-python/__init__.py b/sahli-editor-python/__init__.py new file mode 100644 index 0000000..e69de29 From 97d1b1ebe5756cd79b2ae05c7425ec8de40142fc Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Thu, 9 Apr 2020 18:50:40 +0300 Subject: [PATCH 29/36] Start of the editor - class structure works, but is odd. - I should not commit this publicly until I do a few python classes. --- editor.py | 27 +++++++ .../__init__.py | 0 sahliEditorPython/sahlifile.py | 78 +++++++++++++++++++ setup.py | 15 ++++ 4 files changed, 120 insertions(+) create mode 100644 editor.py rename {sahli-editor-python => sahliEditorPython}/__init__.py (100%) create mode 100644 sahliEditorPython/sahlifile.py create mode 100644 setup.py diff --git a/editor.py b/editor.py new file mode 100644 index 0000000..6fc2ce9 --- /dev/null +++ b/editor.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# coding:utf-8 +""" + Author: Sir Garbagetruck -- + Purpose: make editing the list.sahli file easier + Created: 2020/04/09 +""" + +import json +import argparse +import sahliEditorPython + + +def main(args): + """maintain a list.sahli file""" + if args.new: + mysahli = sahliEditorPython.sahlifile() + else: + mysahli = sahliEditorPython.sahlifile(args.filename) + a = 5 + + +if __name__ == '__main__': + ap = argparse.ArgumentParser() + ap.add_argument('-f', '--filename', default='list.sahli') + ap.add_argument('-n', '--new', action='store_true') + main(ap.parse_args()) diff --git a/sahli-editor-python/__init__.py b/sahliEditorPython/__init__.py similarity index 100% rename from sahli-editor-python/__init__.py rename to sahliEditorPython/__init__.py diff --git a/sahliEditorPython/sahlifile.py b/sahliEditorPython/sahlifile.py new file mode 100644 index 0000000..8d366bc --- /dev/null +++ b/sahliEditorPython/sahlifile.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# coding:utf-8 +""" + Author: Sir Garbagetruck -- + Purpose: base class for Sahli file + Created: 2020/04/09 +""" + +import json +######################################################################## + + +class sahlifile: + """the Sahli file structure and classes to futz with""" + + # ---------------------------------------------------------------------- + def __init__(self, filename): + """Constructor""" + self.valid_filetypes = [ + "plain", + "ansi", + "xbin", + "ice", + "adf", + "avatar", + "bin", + "idf", + "pcboard", + "tundra" + ] + self.valid_fonts = [ + 'Propaz', 'ansifont', 'mOsOul', 'Microknight', 'p0t-nOodle' + ] + if filename is not None: + with open(filename) as f: + self.sahli = json.load(f) + else: + location = self.blank_location() + slides = self.blank_slides() + filedata = [ + self.blank_filedata() + ] + self.sahli = { + 'location': location, + 'slides': slides, + 'filedata': filedata + } + + def blank_slides(self): + """blank slide structure""" + slides = { + 'background': '', + 'template': '', + 'css': '' + } + + def blank_location(self): + "blank location structure" + return '' + + def blank_filedata(self): + """Blank filedata structure""" + + filedata = { + 'file': '', + 'name': '', + 'amiga': False, + 'filetype': 'image', + 'width': '', + 'author': '', + 'font': 'Propaz', + 'color': [0, 0, 0, 255], + 'bg': [255, 255, 255, 255], + 'line1': '', + 'line2': '', + 'text': '' + } + return filedata diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..fe18ef9 --- /dev/null +++ b/setup.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +# coding:utf-8 +""" + Author: Sir Garbagetruck -- + Purpose: setup script for Sahli editor tools + Created: 2020/04/09 +""" + +from setuptools import setup, find_packages + +setup( + name="SahliEditor", + version="0.1", + packages=find_packages() +) From 6e5c28c9c42c0d8799ac4427380a12483fa2982f Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Thu, 9 Apr 2020 19:59:12 +0300 Subject: [PATCH 30/36] Refactoring the way we create blank files. --- editor.py | 44 +++++++++++++++++++++++-- sahliEditorPython/sahlifile.py | 59 +++++++++++++++++++++++++++++++--- 2 files changed, 96 insertions(+), 7 deletions(-) diff --git a/editor.py b/editor.py index 6fc2ce9..2ddfa05 100644 --- a/editor.py +++ b/editor.py @@ -8,15 +8,51 @@ import json import argparse -import sahliEditorPython +import os +from sahliEditorPython import sahlifile as SF + + +def getfilesindir(directory): + """return the files in a directory as an array""" + for root, dirs, files, rootfd in os.fwalk(directory): + return files + +# ---------------------------------------------------------------------- + + +def getfilenames(filedata): + """return the file names from a sahli filedata array""" + f = [] + for i in filedata: + f.append(i['file']) + return f + + +def getdata(filedata, name): + """get the filedata entry where file = name""" + for i in filedata: + if i['file'] == name: + return i + return [] def main(args): """maintain a list.sahli file""" if args.new: - mysahli = sahliEditorPython.sahlifile() + mysahli = SF.sahlifile(None) else: - mysahli = sahliEditorPython.sahlifile(args.filename) + mysahli = SF.sahlifile(args.filename) + mysahli.sahli['location'] = args.directory + files = getfilesindir(args.directory) + filedata = mysahli.sahli['filedata'] + filedatanames = getfilenames(filedata) + newdata = [] + for i in files: + if i in filedatanames: + print('found! {}'.format(i)) + newdata.append(getdata(filedata, i)) + else: + print('not found! {}'.format(i)) a = 5 @@ -24,4 +60,6 @@ if __name__ == '__main__': ap = argparse.ArgumentParser() ap.add_argument('-f', '--filename', default='list.sahli') ap.add_argument('-n', '--new', action='store_true') + ap.add_argument('-d', '--directory', type=str, required=True, + help='directory where compo files are') main(ap.parse_args()) diff --git a/sahliEditorPython/sahlifile.py b/sahliEditorPython/sahlifile.py index 8d366bc..0f3e631 100644 --- a/sahliEditorPython/sahlifile.py +++ b/sahliEditorPython/sahlifile.py @@ -37,9 +37,7 @@ class sahlifile: else: location = self.blank_location() slides = self.blank_slides() - filedata = [ - self.blank_filedata() - ] + filedata = [] self.sahli = { 'location': location, 'slides': slides, @@ -55,9 +53,62 @@ class sahlifile: } def blank_location(self): - "blank location structure" + """blank location structure""" return '' + def blank_picture(self): + """Blank picture structure""" + return { + 'file': '', + 'name': '', + 'amiga': False, + 'filetype': 'image', + 'width': '1600', + 'author': '', + 'font': 'Propaz', + 'color': [0, 0, 0, 255], + 'bg': [255, 255, 255, 255], + 'line1': '', + 'line2': '', + 'text': '' + } + # ---------------------------------------------------------------------- + + def blank_amiga_ascii(self): + """blank amiga ascii""" + return { + 'file': '', + 'name': '', + 'amiga': True, + 'filetype': 'plain', + 'width': '80', + 'author': '', + 'font': 'Propaz', + 'color': [250, 250, 250, 255], + 'bg': [0, 0, 0, 255], + 'line1': '', + 'line2': '', + 'text': '' + } + # ---------------------------------------------------------------------- + + def blank_ansi(self): + """blank PC Ansi""" + return { + 'file': '', + 'name': '', + 'amiga': False, + 'filetype': 'ansi', + 'width': '80', + 'author': '', + 'font': 'Propaz', + 'color': [255, 255, 255, 255], + 'bg': [0, 0, 0, 255], + 'line1': '', + 'line2': '', + 'text': '' + } + def blank_filedata(self): """Blank filedata structure""" From 14a646e680ae88d2be22f7f38cbced4cdab27a53 Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Thu, 9 Apr 2020 21:44:02 +0300 Subject: [PATCH 31/36] read sauce info. Required changes to sauce library. --- editor.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/editor.py b/editor.py index 2ddfa05..d7c5a27 100644 --- a/editor.py +++ b/editor.py @@ -9,6 +9,7 @@ import json import argparse import os +from sauce import SAUCE from sahliEditorPython import sahlifile as SF @@ -17,8 +18,6 @@ def getfilesindir(directory): for root, dirs, files, rootfd in os.fwalk(directory): return files -# ---------------------------------------------------------------------- - def getfilenames(filedata): """return the file names from a sahli filedata array""" @@ -36,6 +35,43 @@ def getdata(filedata, name): return [] +def getpicdata(filename): + """extract picture data from filename""" + return 'todo.txt' + + +def getansidata(filename): + """extract SAUCE data from filename""" + saucedata = SAUCE(filename) + ansidata = { + 'author': saucedata.author, + 'group': saucedata.group, + 'title': saucedata.title, + 'filesize': saucedata.filesize, + 'comments': saucedata.comments + } + tinfonames = [saucedata.tinfo1_name, + saucedata.tinfo2_name, + saucedata.tinfo3_name, + saucedata.tinfo4_name] + tinfo = [saucedata.tinfo1, + saucedata.tinfo2, + saucedata.tinfo3, + saucedata.tinfo4] + for i in range(0, 3): + if tinfonames[i] == 'width': + ansidata['width'] = tinfo[i] + if tinfonames[i] == 'height': + ansidata['height'] = tinfo[i] +# print(tinfonames[i]) + return ansidata + + +def getamigadata(filename): + """try to get some form of info from file (:""" + return 'todo.txt' + + def main(args): """maintain a list.sahli file""" if args.new: @@ -48,11 +84,25 @@ def main(args): filedatanames = getfilenames(filedata) newdata = [] for i in files: + dirfile = '{}/{}'.format(args.directory, i) if i in filedatanames: print('found! {}'.format(i)) + a = getansidata(dirfile) newdata.append(getdata(filedata, i)) else: print('not found! {}'.format(i)) + suf = i.split('.')[-1] + if suf in ['png', 'jpg', 'jpeg', 'gif', + 'PNG', 'JPG', 'JPEG', 'GIF']: + stuff = getpicdata(dirfile) + elif suf in ['ans', 'ANS', 'BIN', 'bin', 'XB', 'xb']: + stuff = getansidata(dirfile) + a = 5 + elif suf in ['TXT', 'ASC', 'txt', 'asc', + 'NFO', 'nfo', 'diz', 'DIZ']: + stuff = getamigadata(dirfile) + else: + print("dunno what type of file this is...") a = 5 From dbfb8db6d40d81b51fb6d41829c390d6c12df45a Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Thu, 9 Apr 2020 21:44:29 +0300 Subject: [PATCH 32/36] changes to the sauce library, to make work with python 3. - likely needs complete overhaul, as it doesn't do latest SAUCE per burps. --- sauce.py | 510 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 510 insertions(+) create mode 100644 sauce.py diff --git a/sauce.py b/sauce.py new file mode 100644 index 0000000..00a6408 --- /dev/null +++ b/sauce.py @@ -0,0 +1,510 @@ +#! /usr/bin/env python +# +# _______ +# ____________ _______ _\__ /_________ ___ _____ +# | _ _ \ _ | ____\ _ / | |/ _ \ +# | / / / / | | | /___/ _ | | / / +# |___/___/ /___/____|________|___ | |_| |___|_____/ +# \__/ |___| +# +# (c) 2006-2012 Wijnand Modderman-Lenstra - https://maze.io/ +# + +''' +Parser for SAUCE or Standard Architecture for Universal Comment Extensions. +''' + +__author__ = 'Wijnand Modderman-Lenstra ' +__copyright__ = '(C) 2006-2012 Wijnand Modderman-Lenstra' +__license__ = 'LGPL' +__version__ = '1.2' +__url__ = 'https://github.com/tehmaze/sauce' + +import datetime +import os +import struct +try: + from io import StringIO +except ImportError: + from io import StringIO + + +class SAUCE(object): + ''' + Parser for SAUCE or Standard Architecture for Universal Comment Extensions, + as defined in http://www.acid.org/info/sauce/s_spec.htm. + + :param filename: file name or file handle + :property author: Name or 'handle' of the creator of the file + :property datatype: Type of data + :property date: Date the file was created + :property filesize: Original filesize NOT including any information of + SAUCE + :property group: Name of the group/company the creator is employed by + :property title: Title of the file + + Example:: + + >>> art = open('31337.ANS', 'rb') + >>> nfo = sauce.SAUCE(art) + >>> nfo.author + 'maze' + ... + >>> nfo.group + '' + >>> nfo.group = 'mononoke' + >>> raw = str(nfo) + + Saving the new file:: + + >>> sav = open('31337.NEW', 'wb') + >>> nfo.write(sav) + >>> # OR you can do: + >>> sav = nfo.write('31337.NEW') + + ''' + + # template + template = ( + # name default size type + ('SAUCE', 'SAUCE', 5, '5s'), + ('SAUCEVersion', '00', 2, '2s'), + ('Title', '\x00' * 35, 35, '35s'), + ('Author', '\x00' * 20, 20, '20s'), + ('Group', '\x00' * 20, 20, '20s'), + ('Date', '\x00' * 8, 8, '8s'), + ('FileSize', [0], 4, 'I'), + ('DataType', [0], 1, 'B'), + ('FileType', [0], 1, 'B'), + ('TInfo1', [0], 2, 'H'), + ('TInfo2', [0], 2, 'H'), + ('TInfo3', [0], 2, 'H'), + ('TInfo4', [0], 2, 'H'), + ('Comments', [0], 1, 'B'), + ('Flags', [0], 1, 'B'), + ('Filler', ['\x00'] * 22, 22, '22c'), + ) + templates = [t[0] for t in template] + datatypes = ['None', 'Character', 'Graphics', 'Vector', 'Sound', + 'BinaryText', 'XBin', 'Archive', 'Executable'] + filetypes = { + 'None': { + 'filetype': ['Undefined'], + }, + 'Character': { + 'filetype': ['ASCII', 'ANSi', 'ANSiMation', 'RIP', 'PCBoard', + 'Avatar', 'HTML', 'Source'], + 'flags': {0: 'None', 1: 'iCE Color'}, + 'tinfo': ( + ('width', 'height', None, None), + ('width', 'height', None, None), + ('width', 'height', None, None), + ('width', 'height', 'colors', None), + ('width', 'height', None, None), + ('width', 'height', None, None), + (None, None, None, None), + ), + }, + 'Graphics': { + 'filetype': ['GIF', 'PCX', 'LBM/IFF', 'TGA', 'FLI', 'FLC', + 'BMP', 'GL', 'DL', 'WPG', 'PNG', 'JPG', 'MPG', + 'AVI'], + 'tinfo': (('width', 'height', 'bpp')) * 14, + }, + 'Vector': { + 'filetype': ['DX', 'DWG', 'WPG', '3DS'], + }, + 'Sound': { + 'filetype': ['MOD', '669', 'STM', 'S3M', 'MTM', 'FAR', 'ULT', + 'AMF', 'DMF', 'OKT', 'ROL', 'CMF', 'MIDI', 'SADT', + 'VOC', 'WAV', 'SMP8', 'SMP8S', 'SMP16', 'SMP16S', + 'PATCH8', 'PATCH16', 'XM', 'HSC', 'IT'], + 'tinfo': ((None,)) * 16 + (('Sampling Rate',)) * 4, + }, + 'BinaryText': { + 'flags': {0: 'None', 1: 'iCE Color'}, + }, + 'XBin': { + 'tinfo': (('width', 'height'),), + }, + 'Archive': { + 'filetype': ['ZIP', 'ARJ', 'LZH', 'ARC', 'TAR', 'ZOO', 'RAR', + 'UC2', 'PAK', 'SQZ'], + }, + } + + def __init__(self, filename='', data=''): + assert (filename or data), 'Need either filename or record' + + if filename: + # if type(filename) == file: + # self.filehand = filename + # else: + self.filehand = open(filename, 'rb') + self._size = os.path.getsize(self.filehand.name) + else: + self._size = len(data) + self.filehand = StringIO(data) + + self.record, self.data = self._read() + + def __str__(self): + return ''.join(list(self._read_file())) + + def _read_file(self): + # Buffered reader (generator), reads the original file without SAUCE + # record. + self.filehand.seek(0) + # Check if we have SAUCE data + if self.record: + reads, rest = divmod(self._size - 128, 1024) + else: + reads, rest = divmod(self._size, 1024) + for x in range(0, reads): + yield self.filehand.read(1024) + if rest: + yield self.filehand.read(rest) + + def _read(self): + if self._size >= 128: + self.filehand.seek(self._size - 128) + record = self.filehand.read(128) + if record.startswith(b'SAUCE'): + self.filehand.seek(0) + return record, self.filehand.read(self._size - 128) + + self.filehand.seek(0) + return None, self.filehand.read() + + def _gets(self, key): + if self.record is None: + return None + + name, default, offset, size, stype = self._template(key) + data = self.record[offset:offset + size] + data = struct.unpack(stype, data) + if stype[-1] in 'cs': + # return ''.join(data) + return data[0].decode() + elif stype[-1] in 'BI' and len(stype) == 1: + return data[0] + else: + return data + + def _puts(self, key, data): + name, default, offset, size, stype = self._template(key) + #print offset, size, data, repr(struct.pack(stype, data)) + if self.record is None: + self.record = self.sauce() + self.record = ''.join([ + self.record[:offset], + struct.pack(stype, data), + self.record[offset + size:] + ]) + return self.record + + def _template(self, key): + index = self.templates.index(key) + name, default, size, stype = self.template[index] + offset = sum([self.template[x][2] for x in range(0, index)]) + return name, default, offset, size, stype + + def sauce(self): + ''' + Get the raw SAUCE record. + ''' + if self.record: + return self.record + else: + data = 'SAUCE' + for name, default, size, stype in self.template[1:]: + #print stype, default + if stype[-1] in 's': + data += struct.pack(stype, default) + else: + data += struct.pack(stype, *default) + return data + + def write(self, filename): + ''' + Save the file including SAUCE data to the given file(handle). + ''' + filename = type(filename) == file and filename or open( + filename, 'wb') + for part in self._read_file(): + filename.write(part) + filename.write(self.sauce()) + return filename + + # SAUCE meta data + + def get_author(self): + astr = self._gets('Author') + if astr is not None: + return astr.strip() + else: + return '' + + def set_author(self, author): + self._puts('Author', author) + return self + + def get_comments(self): + return self._gets('Comments') + + def set_comments(self, comments): + self._puts('Comments', comments) + return self + + def get_datatype(self): + return self._gets('DataType') + + def get_datatype_str(self): + datatype = self.datatype + if datatype is None: + return None + if datatype < len(self.datatypes): + return self.datatypes[datatype] + else: + return None + + def set_datatype(self, datatype): + if type(datatype) == str: + datatype = datatype.lower().title() # fOoBAR -> Foobar + datatype = self.datatypes.index(datatype) + self._puts('DataType', datatype) + return self + + def get_date(self): + return self._gets('Date') + + def get_date_str(self, format='%Y%m%d'): + return datetime.datetime.strptime(self.date, format) + + def set_date(self, date=None, format='%Y%m%d'): + if date is None: + date = datetime.datetime.now().strftime(format) + elif type(date) in [datetime.date, datetime.datetime]: + date = date.strftime(format) + elif type(date) in [int, int, float]: + date = datetime.datetime.fromtimestamp(date).strftime(format) + self._puts('Date', date) + return self + + def get_filesize(self): + return self._gets('FileSize') + + def set_filesize(self, size): + self._puts('FileSize', size) + + def get_filler(self): + return self._gets('Filler') + + def get_filler_str(self): + filler = self._gets('Filler') + if filler is None: + return '' + else: + return filler.rstrip('\x00') + + def get_filetype(self): + return self._gets('FileType') + + def get_filetype_str(self): + datatype = self.datatype_str + filetype = self.filetype + + if datatype is None or filetype is None: + return None + + if datatype in self.filetypes and \ + 'filetype' in self.filetypes[datatype] and \ + filetype < len(self.filetypes[datatype]['filetype']): + return self.filetypes[datatype]['filetype'][filetype] + else: + return None + + def set_filetype(self, filetype): + datatype = self.datatype_str + if type(filetype) == str: + filetype = filetype.lower().title() # fOoBAR -> Foobar + filetype = [name.lower().title() + for name in self.filetypes[datatype]['filetype']].index(filetype) + self._puts('FileType', filetype) + return self + + def get_flags(self): + return self._gets('Flags') + + def set_flags(self, flags): + self._puts('Flags', flags) + return self + + def get_flags_str(self): + datatype = self.datatype_str + filetype = self.filetype + + if datatype is None or filetype is None: + return None + + if datatype in self.filetypes and \ + 'flags' in self.filetypes[datatype] and \ + filetype < len(self.filetypes[datatype]['filetype']): + return self.filetypes[datatype]['filetype'][filetype] + else: + return None + + def get_group(self): + gstr = self._gets('Group') + if gstr is not None: + return gstr.strip() + else: + return '' +# return self._gets('Group').strip() + + def set_group(self, group): + self._puts('Group', group) + return self + + def _get_tinfo_name(self, i): + datatype = self.datatype_str + filetype = self.filetype + + if datatype is None or filetype is None: + return None + + try: + return self.filetypes[datatype]['tinfo'][filetype][i - 1] + except (KeyError, IndexError): + return '' + + def get_tinfo1(self): + tinfo = self._gets('TInfo1') + if tinfo is not None: + return tinfo[0] + else: + return '' + + def get_tinfo1_name(self): + return self._get_tinfo_name(1) + + def set_tinfo1(self, tinfo): + self._puts('TInfo1', tinfo) + return self + + def get_tinfo2(self): + tinfo = self._gets('TInfo2') + if tinfo is not None: + return tinfo[0] + else: + return '' + + def get_tinfo2_name(self): + return self._get_tinfo_name(2) + + def set_tinfo2(self, tinfo): + self._puts('TInfo2', tinfo) + return self + + def get_tinfo3(self): + tinfo = self._gets('TInfo3') + if tinfo is not None: + return tinfo[0] + return '' + + def get_tinfo3_name(self): + return self._get_tinfo_name(3) + + def set_tinfo3(self, tinfo): + self._puts('TInfo3', tinfo) + return self + + def get_tinfo4(self): + tinfo = self._gets('TInfo4') + if tinfo is not None: + return tinfo[0] + return '' + + def get_tinfo4_name(self): + return self._get_tinfo_name(4) + + def set_tinfo4(self, tinfo): + self._puts('TInfo4', tinfo) + return self + + def get_title(self): + tstr = self._gets('Title') + if tstr is not None: + return tstr.strip() + else: + return '' +# return self._gets('Title').strip() + + def set_title(self, title): + self._puts('Title', title) + return self + + def get_version(self): + return self._gets('SAUCEVersion') + + def set_version(self, version): + self._puts('SAUCEVersion', version) + return self + + # properties + author = property(get_author, set_author) + comments = property(get_comments, set_comments) + datatype = property(get_datatype, set_datatype) + datatype_str = property(get_datatype_str) + date = property(get_date, set_date) + filesize = property(get_filesize, set_filesize) + filetype = property(get_filetype, set_filetype) + filetype_str = property(get_filetype_str) + filler = property(get_filler) + filler_str = property(get_filler_str) + flags = property(get_flags, set_flags) + flags_str = property(get_flags_str) + group = property(get_group, set_group) + tinfo1 = property(get_tinfo1, set_tinfo1) + tinfo1_name = property(get_tinfo1_name) + tinfo2 = property(get_tinfo2, set_tinfo2) + tinfo2_name = property(get_tinfo2_name) + tinfo3 = property(get_tinfo3, set_tinfo3) + tinfo3_name = property(get_tinfo3_name) + tinfo4 = property(get_tinfo4, set_tinfo4) + tinfo4_name = property(get_tinfo4_name) + title = property(get_title, set_title) + version = property(get_version) + + +if __name__ == '__main__': + import sys + if len(sys.argv) != 2: + print('%s ' % (sys.argv[0],), file=sys.stderr) + sys.exit(1) + else: + test = SAUCE(sys.argv[1]) + + def show(sauce): + print('Version.:', sauce.version) + print('Title...:', sauce.title) + print('Author..:', sauce.author) + print('Group...:', sauce.group) + print('Date....:', sauce.date) + print('FileSize:', sauce.filesize) + print('DataType:', sauce.datatype, sauce.datatype_str) + print('FileType:', sauce.filetype, sauce.filetype_str) + print('TInfo1..:', sauce.tinfo1) + print('TInfo2..:', sauce.tinfo2) + print('TInfo3..:', sauce.tinfo3) + print('TInfo4..:', sauce.tinfo4) + print('Flags...:', sauce.flags, sauce.flags_str) + print('Record..:', len(sauce.record), repr(sauce.record)) + print('Filler..:', sauce.filler_str) + + if test.record: + show(test) + else: + print('No SAUCE record found') + test = SAUCE(data=test.sauce()) + show(test) From e51bec49095026d4174ff010f6405e44c9029fa1 Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Fri, 10 Apr 2020 02:10:56 +0300 Subject: [PATCH 33/36] Actually handle a new file, and create a sahli file - just ansi for now --- editor.py | 27 ++++++++++++++++++++++++--- sahliEditorPython/sahlifile.py | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/editor.py b/editor.py index d7c5a27..d5640e4 100644 --- a/editor.py +++ b/editor.py @@ -48,7 +48,9 @@ def getansidata(filename): 'group': saucedata.group, 'title': saucedata.title, 'filesize': saucedata.filesize, - 'comments': saucedata.comments + 'comments': saucedata.comments, + 'width': None, + 'height': None } tinfonames = [saucedata.tinfo1_name, saucedata.tinfo2_name, @@ -87,6 +89,7 @@ def main(args): dirfile = '{}/{}'.format(args.directory, i) if i in filedatanames: print('found! {}'.format(i)) + # todo: _if_ I ever make this a non-preparser, then... futz with a = getansidata(dirfile) newdata.append(getdata(filedata, i)) else: @@ -95,21 +98,39 @@ def main(args): if suf in ['png', 'jpg', 'jpeg', 'gif', 'PNG', 'JPG', 'JPEG', 'GIF']: stuff = getpicdata(dirfile) + a = 5 elif suf in ['ans', 'ANS', 'BIN', 'bin', 'XB', 'xb']: stuff = getansidata(dirfile) - a = 5 + entry = mysahli.blank_ansi() + entry['file'] = i + entry['name'] = stuff['title'] + entry['author'] = '{}/{}'.format( + stuff['author'], stuff['group']) + entry['text'] = stuff['comments'] + if stuff['height'] is not None: + entry['height'] = stuff['height'] + if stuff['width'] is not None: + entry['width'] = stuff['width'] + newdata.append(entry) elif suf in ['TXT', 'ASC', 'txt', 'asc', 'NFO', 'nfo', 'diz', 'DIZ']: stuff = getamigadata(dirfile) else: print("dunno what type of file this is...") - a = 5 + mysahli.sahli['filedata'] = newdata + out = json.dumps(mysahli.sahli, sort_keys=False, indent=4) + if args.outfile == '>stdout': + print(out) + else: + with open(args.outfile, 'w') as f: + json.dump(mysahli.sahli, f, sort_keys=False, indent=4) if __name__ == '__main__': ap = argparse.ArgumentParser() ap.add_argument('-f', '--filename', default='list.sahli') ap.add_argument('-n', '--new', action='store_true') + ap.add_argument('-o', '--outfile', type=str, default='>stdout') ap.add_argument('-d', '--directory', type=str, required=True, help='directory where compo files are') main(ap.parse_args()) diff --git a/sahliEditorPython/sahlifile.py b/sahliEditorPython/sahlifile.py index 0f3e631..598614e 100644 --- a/sahliEditorPython/sahlifile.py +++ b/sahliEditorPython/sahlifile.py @@ -51,6 +51,7 @@ class sahlifile: 'template': '', 'css': '' } + return slides def blank_location(self): """blank location structure""" From ba66b982001161b90c5e1875ba4f671970b670db Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Fri, 10 Apr 2020 02:18:54 +0300 Subject: [PATCH 34/36] Now handles image preparsing --- editor.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/editor.py b/editor.py index d5640e4..5a0412a 100644 --- a/editor.py +++ b/editor.py @@ -10,6 +10,7 @@ import json import argparse import os from sauce import SAUCE +from PIL import Image from sahliEditorPython import sahlifile as SF @@ -37,7 +38,12 @@ def getdata(filedata, name): def getpicdata(filename): """extract picture data from filename""" - return 'todo.txt' + imagedata = Image.open(filename) + picdata = { + 'width': imagedata.width, + 'height': imagedata.height + } + return picdata def getansidata(filename): @@ -98,7 +104,12 @@ def main(args): if suf in ['png', 'jpg', 'jpeg', 'gif', 'PNG', 'JPG', 'JPEG', 'GIF']: stuff = getpicdata(dirfile) - a = 5 + entry = mysahli.blank_picture() + entry['width'] = stuff['width'] + entry['height'] = stuff['height'] + entry['file'] = i + entry['name'] = i + newdata.append(entry) elif suf in ['ans', 'ANS', 'BIN', 'bin', 'XB', 'xb']: stuff = getansidata(dirfile) entry = mysahli.blank_ansi() From d57b5573c976e591382bfc54072818045eb65921 Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Fri, 10 Apr 2020 02:58:05 +0300 Subject: [PATCH 35/36] Some... strangeness seemed to occur in Amiga ascii with these values - however this may just be a local thing? I don't know, it seems to be fine when loaded over the net. --- editor.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/editor.py b/editor.py index 5a0412a..3ca9705 100644 --- a/editor.py +++ b/editor.py @@ -77,7 +77,14 @@ def getansidata(filename): def getamigadata(filename): """try to get some form of info from file (:""" - return 'todo.txt' + with open(filename, encoding='latin1') as f: + ascii = f.readlines() + width = 0 + for i in ascii: + if len(i) > width: + width = len(i) + return {'height': len(ascii), + 'width': width} def main(args): @@ -126,6 +133,12 @@ def main(args): elif suf in ['TXT', 'ASC', 'txt', 'asc', 'NFO', 'nfo', 'diz', 'DIZ']: stuff = getamigadata(dirfile) + entry = mysahli.blank_amiga_ascii() + entry['name'] = i +# entry['title'] = i +# entry['height'] = stuff['height'] + entry['file'] = i + newdata.append(entry) else: print("dunno what type of file this is...") mysahli.sahli['filedata'] = newdata From fbc59fdaaa3ab28109622cc3a620327762bee6b6 Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Tue, 14 Apr 2020 10:29:40 +0300 Subject: [PATCH 36/36] Print the actual file that is not importing. - prg not png: when you read png, and it's a prg for c64, this will help! --- editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.py b/editor.py index 3ca9705..bf96391 100644 --- a/editor.py +++ b/editor.py @@ -140,7 +140,7 @@ def main(args): entry['file'] = i newdata.append(entry) else: - print("dunno what type of file this is...") + print("dunno what type of file this is... {}".format(dirfile)) mysahli.sahli['filedata'] = newdata out = json.dumps(mysahli.sahli, sort_keys=False, indent=4) if args.outfile == '>stdout':