Integrating models and views in new Sinatra extensions - ruby

So I would like to use the new possibility to create extensions for Sinatra.
My Extension needs to integrate a model and some views/templates but I don't know how to or where to integrate them?
Did anybody already built something more complex than the example from the documentation?

Here is a list of libraries and extensions on the Sinatra web site

have a look at the Sinatra: Writing Extensions article on the official Sinatra website.

Related

generate html template engine i18n

I am searching for a solution to modularize static html files and to add multilanguage support. I want to generate static html files with gulp which are then served through an apache server.
I am now thinking about using the template engine marko to modularize html files and to prerender html files (handlebars would also be an option; jade is no option cause i don't like the syntax).
For multilanguage support i am thinking about to add an i18n plugin (for example https://www.npmjs.com/package/i18n). But this plugin needs an express server; also for multilanguage i want to prerender the files. Has anybody a hint for me which i18n plugin would best fit for me? Maybe also which one would best work together with marko and gulp?
The result should be html files generated inside /de and /en.
The following sample app might help: https://github.com/marko-js-samples/marko-koa-i18n
It is a server-based app that uses Koa and koa-i18n, but you can directly use i18n-2 to accomplish the same thing.
Disclaimer: I have not used i18n-2 or koa-i18n
A few things to note:
A custom tag is used to introduce a local variable that can be used to access the i18n bundle: (see: src/components/app-hello/template.marko and src/taglib/i18n-var-tag.js)
The i18n bundle is pulled out of out.global.i18n. See: Marko > Global Properties
The following Gulp plugin is currently out-of-date, but it might serve as a good starting point or you can submit a PR to improve it: https://github.com/viviangledhill/gulp-marko
In your case, you will want to prerender each template multiple times, each time with a different i18n bundle instance passed in as a global property.
If you would like more details please ask here or in the Gitter chat room: https://gitter.im/marko-js/marko
Hope that helps.

Ruby and databases

I am new in programming in Ruby, not to mention databases, so i would like a few pointers to my question. I have a few websites, where i gather information from users by a form, which they fill out (my websites are in Wordpress). The form is made in Contact Form 7 (https://wordpress.org/plugins/contact-form-7/) and the info is stored in the database with this plugin (https://wordpress.org/plugins/contact-form-7-to-database-extension/).
My question is: Is it possible to make a ruby program, that would fetch info from my sites (databases) and show me the information? Is there a better way of doing this (Ruby on rails perhaps)?
It is possible to access your wp data from a ruby app. You will need to familiarise yourself with the wordpress api. This gem might also help. You can build a small sinatra based app to keep it simple or use rails.

Is it possible to incorporate QuickBooks PHP DevKit into CodeIgniter

Specifically speaking, is it possible to use Consolibyte's Quickbooks PHP DevKit into an app using the CodeIgniter framework? If so, where would I place it in my directory structure, and how would I access it? I'm just doing some preliminary research into whether or not this could be used to integrate my app with Quickbooks Online.
Thanks for any input!
is it possible to use Consolibyte's Quickbooks PHP DevKit into an app using the CodeIgniter framework?
Yes, of course!
If so, where would I place it in my directory structure, and how would I access it?
Entirely up to you. Usually people put it in a library/quickbooks/ directory or something. Then, just use require_once 'path/to/library/quickbooks/QuickBooks.php'; like you would with any other PHP script.
I'm just doing some preliminary research into whether or not this could be used to integrate my app with Quickbooks Online.
It can be used for that.
You'll need a controller that kicks off the OAuth process. So basically you'll use the code from here:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/index.php#L134
To show the connect button, and then put this code into a controller to kick off OAuth:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/oauth.php
From there, you can use the other example code snippets to exchange data with QuickBooks.
If you have trouble, post your code so we can see what you're doing (feel free to use our support forums if you need more detailed help/discussion: http://www.consolibyte.com/forum/)

php framework with plugins for spreadsheet generation, login/user system,twitter bootstrap integration?

I am considering php framework Codeigniter & Cakephp for small site I would be developing but I am open to using pretty much any framework does fullfill the following requirements. requirements are:
A simple pre-build user authentication system or login system as a plugin, something long
the lines of php-login-script.
Allows Easy integration with third-part excel/spreadsheet generation library or
has some plugin.
Should support PHP 5.2, hence symfony2 can't be considered
Bonus points if the framework
has integration with twitter
bootstrap
Looking for framework which can fullfill all of the above points, so I can save some time. Else, I would prefer framework which does most of the requirements & would write rest myself.
So, based on above requirements; which php framework/script would you suggest?
CakePHP2
User plugin https://github.com/cakedc/users
Twitter Bootstrap https://github.com/slywalker/TwitterBootstrap
There are plenty of different xls export helpers. Just google it and review them I can not recommend any of them because I have not used them. We have our own but we did not open source it.
Overall I would recommend to use CakePHP2 in any case over Codeigniter. I've recently had to convert a project from CI to Cake and now I know why... ;)
I don't know codeIgniter very well, but for Cakephp I can tell you that:
Authentifiaction is easy to implement.
It's easy to generate xml (which Excel can open), for .xls you'll have to do all by yourself.
supports 5.2
there is a helper for twitter bootstrap, but I've never used it.
For me the deal breaker concerning CodeIgniter is the lack of built-in ORM. You should consider if you need one or not.

OAuth2 Provider gem for non-rails, non-mongo apps?

I need to add OAuth2 authentication to a Sinatra-based API. No ActiveRecord, no MongoDB... but DataMapper.
Does anybody know what gems I can use to achieve this? I added rack-oauth2-server, but it depends on Mongo. I'm trying to understand rack-oauth2, but there is practically no documentation and I can't see how this is supposed to integrate in a real application that provides oauth authentication. Any well-documented gems out there? (Not Rails gems).
omniauth-oauth2 looked like it would work, but again, there's basically no documentation on how to integrate it. Links to articles that outline integration with these gems would also be useful.
I've been searching all day and just keep going around in circles. I'm sure this is a solved problem.
Why you didn't look at http://rubydoc.info/gems/oauth2/0.7.1/frames?

Resources