Can programs be embedded into WordPress? - ruby-on-rails

Before I begin, I have only just started learning how to code so please presume no prior knowledge. Everything I learn from you guys will be a first for me :)
My friend has a website created using WordPress and has asked me if I can figure out how to implement a program into his page. Specifically, he wants the site to contain a playable computer game that interacts with his page.. like desktop destroyer for example.
What I need to learn:
1) I need to know what language wordpress uses to build their pages
2) Do i need to learn another language like ruby on rails and embed that into the page?
3) Where to start...
I'm pretty much starting this completely from scratch so any other helpful guidance is very much appreciated!

Wordpress uses PHP to build it's pages. I think it would be very hard to make a video game in PHP: AFAIK there hasn't been much in the way of graphical library work done for it.
What you would probably end up doing is to make a standalone game, probably using Javascript and Html5 (Flash used to be the best choice for this but of course it's not supported in iOS which makes it a bad choice now). Get your game working in an empty browser page, then you can embed it into your wordpress site.
If you've already got the game, and just need to include it in the wordpress page then that's simple. You can just embed it: it runs client-side so php doesn't even have anything to do with it (PHP just runs on the server, like Ruby on Rails).
EDIT: just realised, it's not just "very hard" to write a game in PHP, it's impossible, since it's a server-side tech and the game engine would need to run in the browser. Duh. You could of course handle the back end with php - saving and loading data from a database for example.

Where to start
Look at what you want to achieve - you want to make a "game" in a Wordpress site - this will be less about Wordpress and more about the game.
#Max Williams summed it up pretty well - a "game" online is comprised of two elements - the front-end and back-end.
--
Games
The back-end is basically an API which connects to the DB & server. This would be where the likes of PHP / Rails would come in - a way for you to interact with data on your server
Even games such as World Of Tanks use this setup; the front-end gives you an interface to interact with the data provided by the back-end.
In reference to your PHP / framework question, you need to realize that your Wordpress site will just serve a framework of pages, in which you'll be able to include a game. The inclusion of the game would be to load either a flash or, even better, a java app which will be dynamic & sprite-based
The front-end app will basically take your inputs / interactions, and send them to the backend. This will typically by done with a perpetual websocket connection, but can be achieved in other ways too
Finally, for each request which is received by the server, it will respond with data the app has to factor into the game experience. Sounds complicated, but it's quite simple (not easy) when you think about it logically

Related

Rails API, JSON - how to connect to a web app and bring tables to life?

Hello!
First of all I would like to let you know that I am a fairly new to programming (mostly Ruby on Rails). I have been studying by myself for around 6 months. I recently got a first project - a voting app.
I have created the layout to the app - using HTML, CSS, bootstrap, a little JS and JQuery.
Now I need to bring the app to life - so, make the tables alive. I have heard that it shouldn't be hard to do in Rails API (using REST), which I have created with the help of some tutorials (like this guy). The webapp will be used only locally, on a device.
So, my questions is:
How to connect Rails API to the layout and make it "talk" to eachother?
I know I should use JSON to communicate the front end with server, but I am not sure where to start.
Thanks in advance!
If you're trying to make a website you should follow this tutorial. APIs are more for sharing your sites data or functionality with other sites, or for serving data to mobile apps/frontend frameworks like AngularJS.

CMS, Backend for iOS App

My question might be too easy. But i come from web development background and just started creating iOS app by learning from here and there. I have made 2 prototypes, but the second one need backend, cms.
From my prev experience i used php, mysql, html, css. I custom made the cms to organize my content and all user data, etc would be stored into database and can be maintained from the cms.
I use swift, but i seem to miss something important. in ios area what are the tools to develop the db (not local storage, coredata, and such) and maintain that; like what i used to use in web dev area? i dont even know how to ask the right question, but i really hope you guys would understand
can you guys give me direction? a link to basic knowledge of this will be fine
thanks
I think usually it will be database on a server and you will send requests and get answers in JSON format. You will have to parse them and use in your app.

Ruby on Rails separate front & back

I've been using Ruby on Rails since a little more than one year now and I've always do it in a casual way, I mean, everything in one place (front & back), using the standard .html.erb file populated by the associated controller method.
Otherwise, today in our project, I have the need to separate the front and the back end for multiples reasons (code maintainability / clarity, better architecture, more reactivity, etc...).
I've done plenty of researches, watch some conferences (1, 2, 3), but didn't find my solution yet. It looks like to be a question that comes often, but what is the best practice/tools to separate the backend and the frontend of a Ruby on Rails app?
I don't feel we need (yet) a huge JS framework like React/EmberJS/Angular/etc...
First I was thinking about something like Middleman/Jekyll and make the communication via JSON and API calls, but it seems like that it's not a good solution for dynamic website.
So is there a frontend framework that works well with a Rails API and which is easily maintainable and upgradable (add feature/extension to it like gems)?
Thanks for your insights.
A friend of mine wrote this great article/tutorial on Rails as a backend API.
http://blog.launchacademy.com/the-basics-of-building-an-api-in-ruby-on-rails/
As well as this tutorial on Rails/Ember.js
https://github.com/diegodesouza/Project-Planner-EmberJS
You can get an idea of how it's done and implement your preferred front end framework.
Hope it sheds some light on this question.
I have a similar setup as one of the commenters on the question.
I'm using Rails mainly for just the project structure, to define some page layouts, and for ActiveRecord.
I then have my JSON APIs defined using the Grape API framework.
I have a SPA, written on AngularJS that lives in the public/ folder. It doubles as my mobile app, made possible by phonegap. If my Angular app didn't double as my mobile app, I could've possibly just used the asset pipeline to serve up the SPA. To compensate for that, I have a separate build task written in Grunt to minify/uglify my JS/CSS assets before I deploy them out to production.
I also use Comfortable Mexican Sofa for my static content pages.
It took some trial and error to get things right, but overall I find that this setup serves me pretty well.

blog without any server side scripting, is it a good idea?

I am planning to build a website. I can build the front end with html,css and javascript with the help of twitter bootstrap and jquery ui. Actually i have done a bit of work and it looks good to me.
But I am short of knowledge in case of server side language, (just learning python and django in fact).
So is it advised to build by blog without the database things and all? or should i delay it by 3-4 months until i learn server side programming?
Can I do thing like searching posts, sorting them , comment on post with out the use of databases?
Is it easy to transform my blog to a database based one in later stage easily without taking it off the web?
ps: i dont want to use blogging platforms like wordpress.
you can make a website using static web pages. But that wont be really good enough for your users or readers. Besides that you really have to put a lot of time in manually writing the code for each page.
But if you choose to build a dynamic blog that will be better for the readers. You deploy functions like search , comment more easily.
Using a free and open source blogging platform like wordpress will cut down your task. It has ready made themes, plug ins available to get your tasks done and customize your site the way you want.Again it will be far more secure and attractive.
So my suggestion will be to go with wordpress.
And as far as the learning par is concerned you will learn more stuff while working with wordpress than building a static site

What's the best way to integrate a Django and Rails app sharing the same MySQL datastore?

I'm going to be collaborating with a Python developer on a web
application. I'm going to be building a part of it in Ruby and he is
going to build another part of it using Django. I don't know much about
Django.
My plan for integrating the two parts is to simply map a certain URL
path prefix (say, any request that begins with /services) to the Python
code, while leaving Rails to process other requests.
The Python and Ruby parts of the app will share and make updates to the
same MySQL datastore.
My questions:
What do people think generally of this sort of integration strategy?
Is there a better alternative (short of writing it all in one language)?
What's the best way to share sensitive session data (i.e. a logged in
user's id) across the two parts of the app?
As I see it you can't use Django's auth, you can't use Django's ORM, you can't use Django's admin, you can't use Django's sessions - all you are left with is URL mapping to views and the template system. I'd not use Django, but a simpler Python framework. Time your Python programmer expanded his world...
One possible way that should be pretty clean is to decide which one of the apps is the "main" one and have the other one communicate with it over a well-defined API, rather than directly interacting with the underlying database.
If you're doing it right, you're already building your Rails application with a RESTful API. The Django app could act as a REST client to it.
I'm sure it could work the other way around too (with the rest-client gem, for instance).
That way, things like validations and other core business logic are enforced in one place, rather than two.
A project, product, whatever you call it, needs a leader.
This is the first proof that you don't have one. Someone should decide either you're doing ruby or python. I prefer ruby myself, but I understand those who prefer python.
I think starting a product asking yourself those kind of questions is a BAD start.
If your colleague only knows prototype, and you only know JQuery, are you going to mix the technologies too? Same for DB? And for testing frameworks?
This is a never ending arguing subject. One should decide, IMHO, if you want so;ething good to happen. I work with a lot of teams, as a consultant, Agile teams, very mature teams for some of them, and that's the kind of stuff they avoid at all cost.
Except if one of you is going to work on some specific part of the project, which REALLY needs one or other of the technologies, but still think the other one is best for the rest of the application.
I think, for example, at a batch computing. You have ALL your web app in ror or django, and you have a script, called by CRON or whatever, computing huge amounts of data outside the web app, filling a DB or whatever.
My2Cts.

Resources