Using a Javascript on .lasso page

Using a Javascript on .lasso page

I’m designing a new web page (and learning html/css) and I want to include an images slide show on the page. The code, which includes some Javascript, comes from a copy/paste from w3schools.com <http://w3schools.com/>. Their code works fine on a simple .html page, but when I add some simple lasso search-a-database-and-show-the-results code and switch the page’s suffix to .lasso, the slide show images disappear.

Sorry about my novice-ness, but does anyone have any suggestions? It’s pretty clear that lasso doesn’t want to process the java code on the page. I’ve tried putting the slide show <script> stuff in the body at the bottom, which w3schools.com <http://w3schools.com/> suggests, in the head, and in the .css file. All no go. I’ve tried changing <script> to <script type="text/JavaScript”> and putting it in the head and where w3schools.com <http://w3schools.com/> suggest (at the end of the body). All no go.

Re: Using a Javascript on .lasso page

> 23 juli 2018 kl. 19:26 skrev Jolle Carlestam <[hidden email]>:
>
>
>>
>> [slideIndex-1]
>
> This piece, and all other places with square brackets are interpreted as Lasso code. You need to protect that from happening.
> The technique to accomplish that varies. Is this Lasso 8.x or 9.x?

One way, make into a string.

['[slideIndex-1]']
If you use this method make sure you escape any single quotes inside the string.

Re: Using a Javascript on .lasso page

> On Jul 23, 2018, at 12:26 PM, Jolle Carlestam <[hidden email]> wrote:
>
>
>>
>> [slideIndex-1]
>
> This piece, and all other places with square brackets are interpreted as Lasso code. You need to protect that from happening.
> The technique to accomplish that varies. Is this Lasso 8.x or 9.x?
>
> HDB
> Jolle
>
> #############################################################
>
> This message is sent to you because you are subscribed to
> the mailing list Lasso [hidden email]> Official list archives available at http://www.lassotalk.com> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to <[hidden email]>

I read his hopes that way too. But as I wrote, that is not a sound way to proceed. There are an endless amount of chars he’d have to look out for. Swedish, Danish, German alphabet all have their own quirky letters. French have all their á,à etc. There’s Spanish, Portuguese. What if some user throws in Arabic, Russian, Thai. And then there’s the endless fun with emojis. Why would someone not name their file "Ösig bild på Günther [insert your own emoji here].jpg”? I’ve had that happen.

(Oh, and the reason I don’t actually put an emoji in my example is due to a bug in Lasso 9 preventing it from saving text with emojis to the DB. This affects Lasso talk as well.)

In any case. If it’s a requirement I suggest implementing a couple of known non-ASCII characters to equivalent ASCII characters replacements and then run a catch-all regex on the result. Bils regex will catch all non-ASCII. I still think mine is better. It will make sure there’re only safe file name chars in the string. After all, some ASCII is not safe to use as file names.

>10 aug. 2018 kl. 06:52 skrev Steve Piercy - Website Builder <[hidden email]>:
>>
>>It depends on whether the OP wants to convert non-ASCII characters to the equivalent
>ASCII character stripped of diacritic marks, to another
>arbitrary character, or stripped away.
>>
>>For example:
>>
>>ü -> u
>>or
>>ü -> -
>>or
>>ü ->
>>
>>It seems they wanted the first option.
>>
>>Also consider whether case is important.
>>
>>Ü -> U or u?
>>
>>--steve
>
>I read his hopes that way too. But as I wrote, that is not a
>sound way to proceed. There are an endless amount of chars
>he’d have to look out for. Swedish, Danish, German alphabet
>all have their own quirky letters. French have all their á,à
>etc. There’s Spanish, Portuguese. What if some user throws in
>Arabic, Russian, Thai. And then there’s the endless fun with
>emojis. Why would someone not name their file "Ösig bild på
>Günther [insert your own emoji here].jpg”? I’ve had that happen.
>
>(Oh, and the reason I don’t actually put an emoji in my
>example is due to a bug in Lasso 9 preventing it from saving
>text with emojis to the DB. This affects Lasso talk as well.)
>
>In any case. If it’s a requirement I suggest implementing a
>couple of known non-ASCII characters to equivalent ASCII
>characters replacements and then run a catch-all regex on the
>result. Bils regex will catch all non-ASCII. I still think mine
>is better. It will make sure there’re only safe file name
>chars in the string. After all, some ASCII is not safe to use
>as file names.
>
>HDB
>Jolle
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]>Official list archives available at http://www.lassotalk.com>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to <[hidden email]>

Re: Replace non-standard characters?

Ideally, you'd randomly create a file name for the actual "on disk" file,
but present the file name as whatever the user wants when allowing it to be
downloaded or displayed on a web page. Otherwise, the user could name it
".htaccess" or other badness. Also, depending on the usage, you might need
to create a sub-folder system so that no one sub-folder has too many files
over the life of the solution. Of course, if you're using AWS buckets,
then it doesn't matter. Context is king!

> Indeed, this is part of what I do in Lasso 8, which the OP uses:
>
> $newfile = $files->find('upload.realname'
> )->split('/')->last->split('\\')->last;
> $newfile->lowercase;
> $newfile = string_replaceregexp($newfile, -find='[^a-z0-9.]',
> -replace='-');
>
> I allow only lowercase alphanumeric characters, hyphen, and period.
>
> I also sniff the file with magic to determine its MIME type and use a
> proper file extension (I never trust the user).
>
> --steve
>
>
> On 8/10/18 at 7:06 AM, [hidden email] (Jolle Carlestam) pronounced:
>
>
> 10 aug. 2018 kl. 06:52 skrev Steve Piercy - Website Builder <
>> [hidden email]>:
>>
>>>
>>> It depends on whether the OP wants to convert non-ASCII characters to
>>> the equivalent
>>>
>> ASCII character stripped of diacritic marks, to another arbitrary
>> character, or stripped away.
>>
>>>
>>> For example:
>>>
>>> ü -> u
>>> or
>>> ü -> -
>>> or
>>> ü ->
>>>
>>> It seems they wanted the first option.
>>>
>>> Also consider whether case is important.
>>>
>>> Ü -> U or u?
>>>
>>> --steve
>>>
>>
>> I read his hopes that way too. But as I wrote, that is not a sound way to
>> proceed. There are an endless amount of chars he’d have to look out for.
>> Swedish, Danish, German alphabet all have their own quirky letters. French
>> have all their á,à etc. There’s Spanish, Portuguese. What if some user
>> throws in Arabic, Russian, Thai. And then there’s the endless fun with
>> emojis. Why would someone not name their file "Ösig bild på Günther [insert
>> your own emoji here].jpg”? I’ve had that happen.
>>
>> (Oh, and the reason I don’t actually put an emoji in my example is due to
>> a bug in Lasso 9 preventing it from saving text with emojis to the DB. This
>> affects Lasso talk as well.)
>>
>> In any case. If it’s a requirement I suggest implementing a couple of
>> known non-ASCII characters to equivalent ASCII characters replacements and
>> then run a catch-all regex on the result. Bils regex will catch all
>> non-ASCII. I still think mine is better. It will make sure there’re only
>> safe file name chars in the string. After all, some ASCII is not safe to
>> use as file names.
>>
>> HDB
>> Jolle
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]>> Official list archives available at http://www.lassotalk.com>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to <[hidden email]>
>>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy Website Builder Eugene, OR
> <[hidden email]> <http://www.stevepiercy.com/>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
> the mailing list Lasso [hidden email]> Official list archives available at http://www.lassotalk.com> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to <[hidden email]>
>

Re: Replace non-standard characters?

> 10 aug. 2018 kl. 07:32 skrev Bil Corry <[hidden email]>:
>
> Ideally, you'd randomly create a file name for the actual "on disk" file,
> but present the file name as whatever the user wants when allowing it to be
> downloaded or displayed on a web page. Otherwise, the user could name it
> ".htaccess" or other badness. Also, depending on the usage, you might need
> to create a sub-folder system so that no one sub-folder has too many files
> over the life of the solution.

This is my solution as well. Files are stored on disk with a lasso_uniqueid name. Original name is stored in a table and used when sending file to user. No cleaning up of file names done.
Files are stored in a per date folder ensuring that there’re not too many files in one place.

The cleaning up file name routine is used in a solution where the client wanted image files created on the server with names based on an ID value that they provided. In that case it was important to make sure that the provided value is actually usable as a file name, hence the cleaning.