[英]can I make a ruby GUI in javascript/html/css?
this is not a ruby on rails question 这不是ruby on rails问题
I just finished up a ruby basics course on teamtreehouse and I'm sitting here thinking of what I want to make to demonstrate to myself that I grasped what I learned. 我刚刚在teamtreehouse完成了一个红宝石基础课程,我正坐在这里思考我想要做些什么来向自己证明我掌握了我学到的东西。
I have a plan to write a program to automate setting up new hire files and folders on a network directory at my work at the click of a button. 我计划编写一个程序,通过单击按钮自动在我的工作中在网络目录上设置新的雇用文件和文件夹。 It might be nice to have a GUI for it instead of running it through the command line. 拥有一个GUI而不是通过命令行运行它可能会很好。
First off, is this possible to run ruby with javascript and html without running it through a server? 首先,这是否可以使用javascript和html运行ruby而无需通过服务器运行它?
I'm trying to think of different ways I would get ruby to speak with javascript. 我正在尝试用不同的方式来讨论用javascript说话。 My first thought was to use a JSON file to produce url links from in my webpage, but I have no idea how I would run the ruby program from the web page. 我的第一个想法是使用JSON文件从我的网页中生成url链接,但我不知道如何从网页运行ruby程序。
probably a dumb question. 可能是个愚蠢的问题。 Im trying to come up with a good project to get some confidence in bare bones ruby before I pursue ruby on rails or sinatra. 我试图想出一个好项目,以便在我在铁轨或sinatra上追求红宝石之前对裸骨红宝石有一些信心。
One easy way to run Ruby and many other languages in the browser would be to use a Ruby to JS compiler like http://opalrb.org/ . 在浏览器中运行Ruby和许多其他语言的一种简单方法是使用Ruby to JS编译器,如http://opalrb.org/ 。 Here's a huge list of more languages then you can shake a stick at: https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js#ruby . 这里有一个庞大的语言列表,你可以动摇一下: https : //github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js#ruby 。
The only trick is to make sure that the compiler can also be run in the browser not just the code it produces. 唯一的技巧是确保编译器也可以在浏览器中运行,而不仅仅是它生成的代码。
Hopefully that helps. 希望这会有所帮助。
---- edit ---- ----编辑----
I think I perhaps didn't read your question as much as I should have. 我想我也许没有尽可能多地阅读你的问题。 As for comunication between the server and the client goes, I would say go with sinatra . 至于服务器和客户端之间的通信,我会说与sinatra一起去。 It's really very simple, and you don't even have to use a database if it's just a project to learn with. 这真的非常简单,如果它只是一个可以学习的项目,你甚至不必使用数据库。 Just modify files and save your data that way. 只需修改文件并以这种方式保存数据。
If you want a more dynamic front end making AJAX calls then you can just make a route in sinatra that would return back the information in an easy to parse form for JS such as JSON. 如果你想要一个更动态的前端进行AJAX调用,那么你可以在sinatra中创建一个路径 ,它将以易于解析的形式返回信息,例如JSON。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.