knop-project / knop Goto Github PK
View Code? Open in Web Editor NEWWeb application framework for Lasso 8 and 9
Web application framework for Lasso 8 and 9
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.
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.
The method getrecord
fails with FileMaker, even with supplied values for -keyfield and -keyvalue, probably at line 587:
.select(-keyfield = #keyfield, -keyvalue = #keyvalue, -inlinename = #inlinename)
Create a demo site of Knop hosted by the kind and generous folks at Anu Internet Services.
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.
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.
per a suggestion from Ke Carlton. knop_lang
currently uses one big map to store language strings, and using one thread per language would improve performance.
If this is not necessary, please remove. Otherwise close issue.
/*
</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>
*/
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:
-description
, if possible.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.
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
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.
I am not going to renew the domain knop-project.org
. If you would like to take it over, I will approve a transfer to you. It expires on 2021-05-31.
Additionally Anu Internet services hosts the Knop demo at https://knop-project.org/ for no cost as a non-profit. I would hand over the reigns to any willing volunteer.
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:
// 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
// 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.
Rewrite code samples. Reorganize. Convert to markdown.
customer/list/?-urlargs=&-page=6
Create new
customer/?-urlargs=-page=6
The user should be redirected to the list page 6.
Update source URLs in knop9/knoplibs/debug.type.lasso to be local a fork of the debug repo, but under the knop-project userspace
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
.
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)
First try this:
/customer/list/
/customer/edit/?-urlargs=
/customer/edit/lo9rnb7ilr6r6/?-urlargs=-urlargs%3D
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.
In the type definition for knop_crypthash, make cost an optional integer.
cost::integer = 1
Then override the default value with a random value.
#_cost == 1 ? #_cost = integer_random(8000, 12000)
Thus the user can calculate their own cost and pass it in or let Knop set it.
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.
knop_user
supports a fingerprint for authenticated users, but not for anonymous users, so this code could be reused. See: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.
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; ``` ?>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.
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 => {
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.
and subsequently session fails.
@stevepiercy has a ton of custom validation snippets to validate user input on the server side.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.