ace
Lightweight FE/BE Framework. Provides tools for launching prototype websites.
Install via git
git clone git@github.com:fluffybunnies/ace.git path-to-project
Install via npm
mysite=./mysite; ; npm install --prefix /tmp aced && cp -ri /tmp/node_modules/aced/* "$mysite" && cd "$mysite" && ls -l
Sire
Or, deploy directly to an ubuntu instance with# Deploy sire to remote server: ./sire/index.sh _deploy# Deploy ace to remote server: ./sire/signal.sh ace
Front End - UI
Instagram Gallery
- Plug and play with a simple gallery id
- Or configure an api mapping to generate dynamic galleries
aceui;
Twitter Feed
- Horizontal or vertical ticker animation
aceui;
Simple Carousel
aceui;
Chat
See demo page and web/assets/ace.chat.js
Uses arrrr module for backend
Tooltips
- Place smart tooltips on any html element
- Intelligent positioning adapts to custom css styles and always remains within viewport
- Activated by hover, click, or any other custom event
- Supports tip activation groupings
ace; // or... ace;
ShadBox
- Bring images to life with this shadow box modal
- Makes load-time look good, with options to customize the animation
- Plugs directly into other ace modules such as the photo carousel and instagram gallery via a simple on/off option
ace; // or... ace;
Pop
- Use as a simple alert dialog
- Or extend with versatile classes and bindings
ace.pop('An email has been sent with a link to reset your password.');
// or...
ace.pop({
header: 'Are you sure?'
,body: 'Clicking Ok will delete everything you own.'
,btns: [
['cancel','Cancel']
,['ok','Ok']
]
,exit_btn: true
,position: 'fixed'
,true_center: false
}).on('ok',function(){
forfeitTheWorld();
});
Loader
- Loader overlay animation remains visible while "up()"s > "down()"s
ace.loader.up()
doSomethingAsync(function(){
ace.loader.down()
})
ace.loader.up()
doSomethingElseAsync(function(){
ace.loader.down()
})
Highlight
- Animate background color to bring attention to $element(s)
- Defaults to yellow fadeout over 1 second
- Use case: Highlight cell in datatable that was just updated
var $rowIJustUpdated = $('table tr.num-15');
ace.highlight($rowIJustUpdated).find('td.info').html(newValue);
$('body').addClass('flashMeGreen');
ace.highlight($('.flashMeGreen'), {
start:'00ff00'
,duration: 1500
,framerate: 15
})
Resource
- On-demand versioned asset loading
- Think async requirejs lite with packs and css
// simple:
ace.resource.fetch('https://s3.example.com/assets/SNotifs.js');
// with callback:
ace.resource.fetch('https://s3.example.com/assets/SNotifs.js',function(){
console.log('js and css loaded');
})
// multiple
ace.resource.fetch([
'//s3.example.com/assets/Leaderboards.js'
,'//s3.example.com/assets/Leaderboards.css'
],function(){
console.log('everything loaded');
})
// split cbs
ace.resource.fetch([
'//s3.example.com/assets/SActivity.pv2.js'
,'//s3.example.com/assets/SActivity.pv2.css'
],function(){
console.log('js loaded')
letsStartFunctionalizing()
},function(){
console.log('css loaded')
renderThings()
});
// packs
ace.resource.fetch('pack:social')
Req
- Shorthand for api calls
ace.req('twitter/feed',function(err,data){
if (err) return console.log(err)
populateTwitterFeed()
})
ace.req('comments','post',{
body: 'Thnks!'
})
Front End - Utils
// 'ace.util.'+Object.keys(ace.util).sort().join('\nace.util.')aceutilarrayFilteraceutilcapitalizeaceutildeleteCookieaceutildeobfuaceutilescapeHtmlaceutilescapeRegExaceutilformatDateaceutilformatIntegeraceutilformatPlaceaceutilformatTimeAgoaceutilgetCookieaceutilgetImageToWindowFitaceutilgetParameterByNameaceutilgetViewportScrollYaceutilhashaceutilisEmptyObjectaceutilisFullyWithinViewportaceutilisWithinViewportaceutilobfuaceutilonTouchDeviceaceutilpadZaceutilparseCookiesaceutilrandaceutilremoveClassWithPrefixaceutilreplaceAllaceutilsetCookieaceutilsetUniqueClassValaceutilstdErrAlertaceutilstrToClassaceutiltrueDim
Front End - Bus
All widgets (and the global ace.bus) extend AceBase - a standard event emitter with a "ready" implementation
// ready() is ambivalent to whether or not the event has already been triggeredacebus;acebus;acebus;acebus;/* ...Let's do something once!Let's do something everytime!Let's do something everytime!*/
Back End - API
Basic API skeleton. Includes a few routes as examples:
Smile
http://ace.fabfitfun.com/ace/api/demo/smile
Send email with attachments
http://ace.fabfitfun.com/ace/api/demo/email-csv-php?email_to=alec@luckygroupinc.com
Back End - Helpers
SES
Amazon SES wrapper. Super simple interface makes it easy to send emails with attachments.
Ses::send(array( 'to' => array('trinkledinkle@example.com'), 'from' => 'stinklewinkle@gmail.com', 'reply_to' => 'funky.munky@example.com', 'bcc' => 'rufus@example.com', 'subject' => 'Kali M lent you 2 loyalty points!', 'message' => 'ssssssup', 'type' => 'html', 'attachment' => WEBROOT.'/saved/secret_list.csv',));
Protect
Contains basic methods to help secure your prototype website.
Protect::preventBruteForce($numRequests=4, $perSeconds=2000, $usePath=true, $bank=50)
Back End - Utils
Ace::getConfig Request value loaded from config.php / config.local.phpAce::g Example: if (Ace::g($_POST,'param') == 'abc') ... instead of if (isset($_POST['param']) && $_POST['param'] == 'abc') ... Example: $host = Ace::g($_SERVER,array('HOST_NAME','SERVER_NAME')); instead of $host = isset($_SERVER['HOST_NAME']) ? $_SERVER['HOST_NAME'] : isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;Ace::onHttps Works behind ELB using HTTP_X_FORWARDED_PROTOAce::enforceHttps Redirect to https://selfAce::vres Optimize asset caching by marking url with file-modified-timeAce::e For debugging: exit with $messageAce::isAssoc Returns true if array does not have continuously ascending numeric keysAce::varDump HTML-formatted alternative to var_dumpAce::putDeep Insert into an array without checking isset() Example: $house = array( 'bedroom' => array('bed','dresser'=>array('pants')), ); Ace::putDeep($house,'kitchen>oven','bread'); Ace::putDeep($house,'bedroom>dresser[]','shirt'); Ace::varDump($house);Ace::onMobile Uses list from http://detectmobilebrowsers.com/ against HTTP_USER_AGENTAce::clientIp Works behind ELB and other proxiesAce::curlGet curlGet( $url [, $params [, $curlOpts ]] )Ace::curlPost curlPost( $url [, $params [, $curlOpts [, $urlEncodedParams = false ]]] ) $urlEncodedParams mimicks application/x-www-form-urlencoded as opposed to the default multipart/form-dataAce::curlDelete curlDelete( $url [, $params [, $curlOpts ]] )Ace::setAssetHeadersForFilename For use when loading a file via php instead of webserverAce::sphericalDistance Calculate the distance between 2 lat/lng pointsAce::strToTime Enforce app-consistent timezone referenceAce::strToTimeUtc Enforce app-consistent timezone referenceAce::date Enforce app-consistent timezone referenceAce::dateUtc Enforce app-consistent timezone referenceAce::dbTime Mysql date format. Same as Ace::date('Y-m-d H:i:s', $time);Ace::dbTimeUtc Mysql date format. Same as Ace::dateUtc('Y-m-d H:i:s', $time);Ace::time Allows overriding return value of `Ace::time()` for unit testsAce::aceTmz Enforce app-consistent timezone reference
Back End - Node
If you deployed using Sire, node will be installed with the latest stable version.
Send email with attachments
node /bin/demo-emailCsvjs --emailTo='alec@luckygroupinc.com' --emailFrom='acquiremint@beachmint.com'
Utils
// node -e "console.log('ut.'+Object.keys(require('./lib/ut.js')).sort().join('\nut.'))"utdateDiffutdbTimeutfileTimeutflipObjKeyValsutgetFirstChildutgetFirstKeyutisNumericutpadZutpluckFromArrayutprettyTimeutrandutreplaceAllutspawnutstatsutsuperTrimuttrim
Health Check
Status Page
To Do
- Fix
ace.ui.instagram
(instagram api forced update) - Import relevant bin/s (e.g. create_dto.php)
- Import magic adapter + dao methods
- Import Ace + bootshell + method comments + etc upgrades
- Don't simply copy+paste work done in Ace::normalizePostData, unit test normal www-form-encoded post from node, maaaybe fall back to the json obj encapsed form
- e.g. DaoSqlAbstract::makePivotWhere
- Import Eav
- Convert ace.highlight.js to ace.jq.highlight.js
- Review current state (escaped globals, memory+proc benchmark, etc)
- Create example route to demonstrate DaoSqlAbstract
- Prepend semicolons to ace modules that begin with "(" to allow for alternate builders like gulp
- Add: SocialShare, flashUI, Lights, et al
- MVC-type routes separate from API
- Import home.php
- Implement basic cache layer with memcache driver
- Start with App::getAppVersion()
- Generate ace.min.js/ace.min.css on start + post-gitsync / file change
- Unit tests
- More descriptive error messages for missing initial configs