Code Monkey home page Code Monkey logo

knop's People

Contributors

bfad avatar johansolve avatar jolle-c avatar stevepiercy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knop's Issues

Knop_grid header and footer show incorrect maxrecords with -sql

Demo lib_customer_list.inc

page_skiprecords($maxrecords); // build search params // first set some basic search parameters var('searchparams'=array(-maxrecords=$maxrecords, -skiprecords=$skiprecords)); // use -uselimit only for non-filemaker data sources !$d->'isfilemaker' ? $searchparams->insert(-uselimit); // then add sort parameters, if any $searchparams -> merge($list -> sortparams); // then add search parameters, if any $searchparams -> merge($list -> quicksearch); // get list of records //$d -> select($searchparams); local(sql = 'SELECT * FROM `knopdemo`.`customer` LIMIT ' + $skiprecords + ',' + $maxrecords) $d -> select(-sql=#sql) ``` /\* Both the header and footer show the incorrect maxrecords of 50 when it should show 20. /* ``` // clear any record locks $s_user -> clearlocks; ``` ?>

knop_database oncreate -keyfield's column cannot be numeric

This code will fail.

var(db) = knop_database(
    -database='database',
    -table='table',
    -maxrecords=$maxrecords,
    -keyfield='id',
    )
An unhandled failure during a web request
Error Code: 21
Error Msg: Is a directory
Error Stack: 
169:20 file.lasso

Use a varchar for -keyfield.

Improve error handling in knop_database.lasso

In knop_database -> saverecord, early errors get trampled by later errors when working with record locks, and are not captured properly and placed on the stacktrace.

To Replicate

  • Checkout commit 8baeda3
  • Login and navigate to Customers Advanced, click an item, edit it, then try to save it.

knop_database -> getrecord does not clear stale lockvalue

To repeat this issue, use the Knop 8 demo, login, go to Advanced, select a record, and try to delete it.

When a record is requested and a stale lockvalue exists in the database object, knop_form incorrectly generates a lockvalue instead of a keyvalue. This prevents the record from being saved or deleted.

In addition, when trying to delete a record, the $s_user variable "disappears". An error is returned:

No tag, type or constant was defined under the name string->trace with arguments: array: (-html)
at: /index.lasso on line: 115 at position: 13

Line 115:
$s_user -> trace(-html);

Then if one refreshes the error page:

No tag, type or constant was defined under the name string->auth.
at: /_config/cfg__nav.inc on line: 38 at position: 16

Line38:
if: $s_user -> auth;

Inserting this at line 37:

$__html_reply__ = $s_user->isa('string');
abort;

Returns:
true

It's as if the knop_user type gets redefined as type string and loses all of its knop_user methods. Now we need to find where that happens while deleting a record with a lock.

In fact, I think I found the problem, in global__config.inc:

test 1

// Configure user
var: 's_user'=(knop_user: -userdb=$d, -userfield='email', -passwordfield='password'),
    's_lang'=null;

$__html_reply__ = $s_user->type;
abort;

session_start: -name='knopdemo';
session_addvar: -name='knopdemo', 's_user', 's_lang';

=>
user

test 2

// Configure user
var: 's_user'=(knop_user: -userdb=$d, -userfield='email', -passwordfield='password'),
    's_lang'=null;

session_start: -name='knopdemo';
$__html_reply__ = $s_user->type;
abort;
session_addvar: -name='knopdemo', 's_user', 's_lang';

=>
string

That result makes ZERO sense, because this file gets loaded whether the action is a save or delete.

user -> login fails on FileMaker 12+

FileMaker 12 syntax has changed to not require an extra "=" when performing a query. So I inserted a temporary workaround in line 422:

if(#db -> 'isfilemaker') => {
    // FileMaker 12 and later syntax
    #searchparams -> merge(array(-op='eq', .'userfield' = #_username))
    // FileMaker 11 and earlier syntax
    //                  #searchparams -> merge(array(-op='eq', .'userfield' = '="' + #_username + '"'))
else

This ought to be handled better by automatically detecting the version of FileMaker if at all possible.

record locking is broken

Record locking fails with error messages, depending on whether one is trying to edit:

Keyfield or keyvalue missing 7006

or delete:

Record locked by another user 7010

a record in the Knop 9 demo under Customer Advanced > Edit.

In addition, an anonymous user can delete any record with a record lock through the Customers Simple interface.

Integration with Twitter Bootstrap

Backport customizations of Knop for 8 to support Twitter Bootstrap. Steve Piercy has this working for a custom knop.lasso, but he needs to make those changes work with a switch, e.g., "-twbootstrap", then merge those changes into the Knop types. If you want to play with the custom knop.lasso, please contact Steve Piercy.

A version for Knop for Lasso 9 is also being developed simultaneously by Jolle Carlestam.

-urlargs appended to knop_nav object in Knop 9

First try this:

  • Navigate to /customer/list/
  • Click "Create new" button (if in English)
  • note URL in address bar becomes /customer/edit/?-urlargs=
  • Click "Cancel" button
  • Click link for Demo User
  • Click "Cancel" button
  • Click "Create new" button again
  • note URL in address bar becomes /customer/edit/lo9rnb7ilr6r6/?-urlargs=-urlargs%3D

Cannot login when userfield is id

Use this sample code. For some reason, authentication fails whenever the userfield is set to id, but it will work when the userfield is any other column.

$db -> settable('user')
$s_user -> userfield = 'id'
$s_user -> login(-username=$s_id, -password=($f -> getvalue('password')))
$s_auth_id = integer($s_user -> id_user)

$out -> append($db -> action_statement)
$out -> append('<br>')
$out -> append($db -> found_count)
$out -> append('<br>')
$out -> append($s_user -> auth)
$out -> append('<br>')
$out -> append($s_user -> id_user)

Comma in select field value does not render in form

When a select field has a value that includes a comma, e.g., "Stockton, CA", and the user selects that option from the select menu and submits the form, Knop will write the value to the database and everything else, but it will not render the field with the value selected when the record is loaded a subsequent time.

Update apache.conf files and documentation to use preferred FallbackResource

Retain original mod_rewrite rules for backward compatibility with older versions of Apache.

https://github.com/knop-project/knop/blob/master/knop9/apache/apache.conf
https://github.com/knop-project/knop/blob/master/knop8/apache/apache.conf

Reference:
http://httpd.apache.org/docs/current/rewrite/remapping.html#fallback-resource
Added in version 2.2.16.

http://httpd.apache.org/docs/current/mod/mod_dir.html#fallbackresource
Compatibility: The disabled argument is available in version 2.4.4 and later.

Don't coerce an array to a string for form -> getbutton

This is madness.

https://github.com/knop-project/knop/blob/master/knop9/knoplibs/knop_form.lasso#L1042-L1054

        local(clientparams = .'clientparams' -> asstring)
        // look for submit buttons, the least destructive first
        with i in array('cancel', 'save', 'add', 'search', 'delete') do => {
            if(#clientparams >> 'button_' + #i
                || #clientparams >> 'button_' + #i + '.x'
                || #clientparams >> 'button_' + #i + '.y') => {
                .'formbutton' = #i
                return #i
            }
        }

coercing the object to a string means that buttons named 'button_saveaddanother' and 'button_savecheckout' both return 'save' for form -> getbutton. The workaround is to insert an arbitrary string that does not much any of the five values in the array.

help.lasso for Knop for Lasso 9

In Lasso 8, we have this pretty nifty semi-automatic documentation of the Knop API and its types and methods.

http://montania.se/projects/knop/help.lasso

It's not fully automatic. We meticulously added all that information for each method as the value for the -description parameter. help.lasso parses the string, then formats it to look pretty. The output is nice, but the labor involved and potential for mistakes is not so much. Also it is not in a single searchable file (like a PDF) and it lacks a search feature (excluding in-browser searching, of course).

Thus we've been looking at better ways of documenting the Knop API for Lasso 9. Our goals are:

  • Write source code once and parse the source for API documentation.
  • Read a method's signature and return its parameters, traits, and other elements into a structure that can be easily parsed.
  • Avoid use of -description, if possible.
  • Use a simple markup language (like .rst) that can be parsed easily and output to HTML, RTF, plain text, or PDF.
  • Generate a searchable index.

Essentially we're looking to create a Lasso domain for Sphinx.

http://sphinx.pocoo.org/domains.html

We're looking to collaborate with any developer on this effort. Please add your comments below.

Demo site doesn't work

Followed the instructions for Lasso 9. When I try to load the demo site all I see is this:

Error:

An unhandled failure during a web request

Error Code: -9948

Error Message: Definition Not Found: knop_lang(-default=string, -fallback=boolean) Candidates were: knop_lang(default::string =?, fallback::boolean =?)

Any idea what I'm doing wrong? I filled out the DB credentials and set it on my instance in Lux. I renamed the apache.conf to .htaccess and put it in the web root with all the demo files.

Knop for Lasso 9 demo fails on Mac OS X 10.5

When loading /sitemap/ of the demo on Mac OS X 10.5 the following error is displayed:

An unhandled failure during a web request
Error Code: -9948
Error Msg: Definition Not Found: knop_database(-database=string, -table=string, -username=string, -password=string, -keyfield=string, -lockfield=string)
Error Stack: 
18:9 //Library/WebServer/Documents/knop-project/knop9/demo//_config/cfg__global.inc
483:3 web_response.lasso
482:4 web_response.lasso
12:1 //Library/WebServer/Documents/knop-project/knop9/demo//index.lasso
483:3 web_response.lasso
482:4 web_response.lasso
19:20 //Library/WebServer/Documents/knop-project/knop9/demo//_urlhandler.lasso
14:1 //Library/WebServer/Documents/knop-project/knop9/demo//_urlhandler.lasso
483:3 web_response.lasso
482:4 web_response.lasso
13:6 /var/lasso/instances/default//LassoStartup/urlhandler_atbegin.lasso
12:5 /var/lasso/instances/default//LassoStartup/urlhandler_atbegin.lasso
11:4 /var/lasso/instances/default//LassoStartup/urlhandler_atbegin.lasso
70:15 web_response.lasso
81:3 query.lasso
8:16 staticarray.lasso
7:3 staticarray.lasso
80:8 query.lasso
70:4 web_response.lasso
63:4 web_response.lasso
235:4 web_response.lasso
182:2 error.lasso
182:2 error.lasso
176:2 error.lasso
175:2 error.lasso
62:3 web_response.lasso
235:4 web_response.lasso
229:3 web_response.lasso
227:6 web_response.lasso
664:17 fastcgi.lasso
182:2 error.lasso
182:2 error.lasso
176:2 error.lasso
175:2 error.lasso
663:2 fastcgi.lasso
287:16 fastcgi.lasso
283:3 fastcgi.lasso
275:2 fastcgi.lasso
182:2 error.lasso
182:2 error.lasso
176:2 error.lasso
175:2 error.lasso
281:2 fastcgi.lasso
275:2 fastcgi.lasso
599:5 fastcgi.lasso
599:5 fastcgi.lasso
598:4 fastcgi.lasso
591:4 fastcgi.lasso
589:21 fastcgi.lasso

knop_nav has comment remnant

If this is not necessary, please remove. Otherwise close issue.

/*

  • Regular link
  • Dropdown
            </li>
            <li class="dropdown">
              <a href="#" data-toggle="dropdown" class="dropdown-toggle">Dropdown 2 <b class="caret"></b></a>
              <ul class="dropdown-menu" id="menu2">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Separated link</a></li>
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" data-toggle="dropdown" class="dropdown-toggle">Dropdown 3 <b class="caret"></b></a>
              <ul class="dropdown-menu" id="menu3">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Separated link</a></li>
              </ul>
            </li>
          </ul>
    

    */

knop_cache missing L-debug

Please consider the following modification to restore L-debug functionality.

define knop_cachestore(
    type::string,
    expires::integer = -1,
    session::string = '',
    name::string = ''
) => debug => {

...

define knop_cachefetch(
    type::string,
    session::string = '',
    name::string = '',
    maxage::date = date('1970-01-01')
) => debug => {

...

define knop_cachedelete(
    type::string,
    session::string = '',
    name::string = ''
) => debug => {

Knop8: user->login does not work with databases with hyphen in name

In Knop8, with a database named "foo-test", user->login will generate an SQL action statement:

SELECT SQL_CALC_FOUND_ROWS * FROM foo-test.users WHERE (username = 'username') LIMIT 0,50

which in turn causes an SQL error.

The workaround is not to use hyphens in your database names.

Knop Demo Login - Implement standard security practices

The Knop Demo's Login does not implement the features that Knop provides, and additional basic security features beyond the scope of Knop are left off.

  • forced HTTPS/SSL on login form
  • obliteration of session and cookie data when reaching login form
  • redirect to another page after successful login
  • encrypted, hashed, salted passwords
  • failed login management configuration flags (amtacrick)
    • exponential increase in delay in milliseconds for each subsequent failed login attempt, implemented as sleep(x^n), where x โ‰ฅ 0.0 and n > 0.0 and x^n is cast as an integer
    • lock out users after N failed login attempts within an optional duration
    • add explicit lockout timestamp, defined as the instant at which the lockout becomes effective (amtacrick). Duration or clearing of the lockout are left to the developer to implement in their solutions. Lasso 9 may soon have an event_schedule implementation, and we'll investigate that as a possibility to clear a lockout.
    • add fingerprint for non-authenticated users (amtacrick). knop_user supports a fingerprint for authenticated users, but not for anonymous users, so this code could be reused. See:
      https://github.com/knop-project/knop/blob/master/knop8/source/_ctype/user.inc#L27
  • other? please add your thoughts

HTTPS/SSL probably will not be implemented for the Demo because it makes it hard for newbs to get started. Instead we might offer a flag in the global config to enable SSL with a redirect to a secure login page.

Create Demo Site

Create a demo site of Knop hosted by the kind and generous folks at Anu Internet Services.

Task List

  • Hosting donated by Anu Internet Services
  • Configure Lasso 8 and 9
  • Register domain name knop-project.org
  • Get email address info at knop-project dot org
  • Configure server
  • Create users for those who will SSH onto server to perform work and maintenance
  • Deploy Knop for Lasso 8
  • Deploy Knop for Lasso 9.3
  • Create scripts to wipe and reload data hourly
  • Prevent deletion of the primary demo user
  • Show timer stats that compare performance of version 8 and 9
  • Links to docs, GitHub, Google Group
  • Allow developers to add their name/business (entity) and projects under their entity for review and acceptance on the site

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.