Files
2012-02-21 01:15:00 -05:00

1 line
5.7 KiB
JSON

[{"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304732598.0135641, "message": "the trick is simple, include a json file that includes javascript code with a datasource and then eval the code or include it in a dynamically created script tag.", "group_id": 236, "id": 948250}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304732650.114783, "message": "end of the day", "group_id": 236, "id": 948253}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304732544.983604, "message": "In just hate to scroll in the appbuilder over plumbery code that never changes and has no business functionnality. So I found a solution to include js files just when needed ( not like use javascript resource) wherever one might need ( global block, rule ) .", "group_id": 236, "id": 948248}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304732559.0149691, "message": "You can have a look here : https://github.com/devloic/kynetxloic/blob/master/kbx/json_js.krl", "group_id": 236, "id": 948249}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304732604.3934519, "message": "and guess what? it even works in KBX", "group_id": 236, "id": 948251}, {"user_id": 30462, "stars": [{"date_created": 1304739185.8864541, "user_id": 30456}], "topic_id": 34095, "date_created": 1304737600.453259, "message": "42 years? That should do it.", "group_id": 236, "id": 948494}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304779897.5246689, "message": "lol", "group_id": 236, "id": 951112}, {"user_id": 4291, "stars": [{"date_created": 1304792184.3310239, "user_id": 763}], "topic_id": 34095, "date_created": 1304790282.0191669, "message": "Brilliant! Thank you for sharing the code. Sorry to be slow to understand, but why not use \"use javascript\" in the meta block?", "group_id": 236, "id": 951813}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304795535.139096, "message": "Hi Ed! I don't like to use \"use resource\" because it loads everything even though some javascript is not needed in a certain context. \nFor now kynetx apps are relatively small of size but I think in the future they could become more complex and that's when we will need to load the js just when needed. \nActually I don't just include js libraries like jquery plugins that don't change during development. To keep a ruleset light I chose to\ninclude one js file in every \"emit\" par of a rule . When I do that I can work inside my eclipse IDE editing the js file of the rule I am working on and I don't add code in the appbuilder. I can version the js file in a repository (svn). In other words the app becomes a lot more modular and easier to read in my opinion. But \"use resource\" is a static string so I can't cacheburst the js files and I don't trust the browsers or KRL to retrieve the last updated js file .\nWith this technique things become more dynamic and as a consequence more flexible. I can cacheburst, I can easily change the location of the files. When I finish debugging an app I generate google closure compiled js files with an ant script, upload the files to an online server and change the flag dev=true to dev=false in my ruleset and the app will use the online compiled js files. No hassle.\nIn a previous technique I included script tags dynamically with src attribute, this was even better because I could host my js files on a localhost apache and that speeded the development.\n", "group_id": 236, "id": 952291}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304795556.6091609, "message": "The problem was that it increased complexity because there is no reliable cross browser mechanism to know when a script is loaded so I had to use setTimeouts to check if a function was available before actually using it.\nI might switch back to this mechanism if I find a cleaner way to handle the timeline of code execution.\nWith these techniques I managed to run some of my apps locally , in offline mode, testing on my local apache. This is very convenient for development and was a necesity because where I live bandwith is not always the best.\nThat's what makes me think that we could figure out a way to push some apps on Mozilla addons. \nI hope I am making myself more or less clear. \nI intend to publish some kind of \"ruleset code template\" to illustrate that once I'll be really satisfied with the tools I use. The main goal of this template is really to have : reusability/readability of code and allow a team to work on a same kynetx app which in my opinion means \nbeing able to have a local testing environment and versioning of source code.\n", "group_id": 236, "id": 952293}, {"user_id": 4291, "stars": [], "topic_id": 34095, "date_created": 1304797984.03421, "message": "@loic Thank you for the detailed explaination! I grok!", "group_id": 236, "id": 952441}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304837995.8217969, "message": "In my example : https://github.com/devloic/kynetxloic/blob/master/kbx/json_js.krl I used \"injectJs\" and \"eval\" to run the js code. In KBX you should use \"eval\" if you want to have access to $K", "group_id": 236, "id": 956943}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304845034.7539711, "message": "I was thinking about using the KRL http library to retrieve js files directly instead of a json object but I didn't see any caching mechanism so I tried it with a datasource and it worked.", "group_id": 236, "id": 957100}, {"user_id": 30494, "stars": [], "topic_id": 34095, "date_created": 1304845092.103718, "message": "So now you can just retrieve/run a js file directly ( no need to convert it to a json object which meant escaping double-quotes...)", "group_id": 236, "id": 957102}]