我已经为Pidgin(分别是所有基于libpurple的信使)和DBus以及Sinatra构建了一个小的Web UI.
这是为了娱乐和学习的目的,现在我正在寻找扩展它的想法.
你能想到它的任何有用的应用程序或扩展吗?
由于我在这个项目上工作以学习新东西,因此欢迎使用/组合其他技术的想法.
最后这里是链接:pidgin-web-ui
我试图在OSX Lion中与Sinatra和Mustache一起运行.经过大量的谷歌搜索后,我没有进一步解决问题.我很确定它与OSX中的Ruby权限有关,因为错误(下面)从示例config.ru文件的第一行开始(需要'app').该项目在这里(https://github.com/defunkt/mustache-sinatra-example)
这是我的错误
Boot Error
Something went wrong while loading config.ru
LoadError: no such file to load -- app
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
config.ru:1:in `block in inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:51:in `instance_eval'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in `eval'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in `inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:102:in `assemble_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:86:in `proceed_as_child'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:31:in `call!'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/favicon.rb:12:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:134:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/handler/webrick.rb:59:in `service'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激.提前致谢
这条线
<script type="text/JavaScript" src="public/js/jquery.js"></script>
Run Code Online (Sandbox Code Playgroud)
抛出一个恐怖
GET http://localhost/ajax/public/js/jquery.js 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)
没有'公开'它是一样的.
在我的应用程序中更改后,它无需公开工作:
get '/' do
erb :main
end
Run Code Online (Sandbox Code Playgroud)
至:
get '/sth_else' do
erb :main
end
Run Code Online (Sandbox Code Playgroud)
但我想在www.page.com/上加载一个页面,没有进一步的论据.请帮帮我.
这是一本书的例子,有点修改过.似乎会话不起作用.每次我开新会议.
#reporter.rb
require 'sinatra/base'
class LoginScreen < Sinatra::Base
#configure(:development) { set :session_secret, "something" }
enable :sessions
get('/login') { erb :login }
post('/login') do
if params[:user][:login] == 'admin' && params[:user][:password] == 'admin'
session['user_name'] = params[:user][:login]
redirect '/'
else
session[:notice] = "notice!"
redirect '/login'
end
end
end
class Reporter < Sinatra::Base
# "?????????" ????? ???????? ????? ?????????
# enable :sessions
# use Rack::Session::Pool, :expire_after => 2592000
#configure(:development) { set :session_secret, "something" }
use LoginScreen
before do
unless session[:user_name]
halt "Access denied, please …
Run Code Online (Sandbox Code Playgroud) 我有一个Android应用程序发布到我的sinatra服务.之前我无法读取sinatra服务的参数.但是,在我将内容类型设置为"x-www-form-urlencoded"之后.我能够看到params,但不是我想要的.我得到的东西是我在sinatra服务中提出的请求.
{"{\"user\":{\"gender\":\"female\"},\"session_id\":\"7a13fd20-9ad9-45c2-b308-
8f390b4747f8\"}"=> nil, "splat"=>["update_profile.json"], "captures"=>["update_profile.json"]}
Run Code Online (Sandbox Code Playgroud)
这就是我从我的应用程序发出请求的方式.
StringEntity se;
se = new StringEntity(getJsonObjectfromNameValueList(params.get_params(), "user");
se.setContentType("application/x-www-form-urlencoded");
postRequest.setEntity(se);
private JSONObject getJsonObjectfromNameValueList(ArrayList<NameValuePair> _params, String RootName) {
JSONObject rootjsonObject = new JSONObject();
JSONObject jsonObject = new JSONObject();
if (_params != null) {
if (!_params.isEmpty()) {
for (NameValuePair p : _params) {
try {
if (p.getName().equals(ApplicationFacade.SESSION_ID))
rootjsonObject.put((String) p.getName(), (String) p.getValue());
else
jsonObject.put((String) p.getName(), (String) p.getValue());
} catch (JSONException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} …
Run Code Online (Sandbox Code Playgroud) 我正在使用这个宝石,它正在为生产环境和开发工作,但不是在进行分段:
这是main.rb
set :environments, %w{development test production staging}
config_file 'config/config.yml'
Run Code Online (Sandbox Code Playgroud)
和config/config.yml
development: &development
sub1:
pay_to_email: test1@gmail.com
test:
<<: *development
staging:
<<: *development
production:
<<: *development
Run Code Online (Sandbox Code Playgroud) 在我的申请中,我有以下两条路线
get '/' do
...
haml :home
end
Run Code Online (Sandbox Code Playgroud)
和
get '/:id' do
@variable = Something.get(params[:id])
somethingelse = @variable.some_method
...
haml :show
end
Run Code Online (Sandbox Code Playgroud)
如果我使用shotgun
并执行我的应用程序并访问localhost:9393(shotgun的默认地址和端口),一切正常,即日志中不显示任何错误消息
如果我使用平常运行服务器(也是瘦的安装)ruby app.rb
并访问localhost:4567,那么它会抱怨some_method
NilClass 没有方法" ",好像第二条路由后跟空字符串一样id
.
在Sinatra文档中,据说路由是按顺序调用的,所以它甚至不应该遇到第二个.我错了吗?
作为测试,我改变了第二条路线,'/:id/show'
并且不再有错误.
在这两种情况下(我的意思是同时使用霰弹枪和普通服务器)网站都是完美呈现的,即在/
视图中是正确的home.haml而不是show.haml.因此错误仅出现在日志文件中.要讲的真相,@variable.some_method
直接在视图中调用,而在浏览时/
我收到了错误/show.haml
.
怎么办?有什么我不应该再遇到这个错误吗?我应该公然忽视它吗?
编辑:输出和代码的相关部分可以在这里找到:https://gist.github.com/4585374
使用Twig的PHP,我可以这样做:
layout.twig
<html>
<body>
{% block content %}{% endblock %}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
form.twig
{% extends "layout.twig" %}
{% block content %}
<div class="form">{% block form %}{% endblock %}</div>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
login.twig
{% extends form %}
{% block form %}
<form>
<input type="text" name="email" />
<input type="submit">
</form>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
这样我就有了所有页面的布局,一个带有表单和登录页面的页面布局.
但是使用Slim我只能指定所有模板的父布局:
layout.slim
html
body ==yield
Run Code Online (Sandbox Code Playgroud)
和我网站上每个页面的特殊布局:
login.slim
div.form
form
input type="text" name="email"
input type="submit"
Run Code Online (Sandbox Code Playgroud)
是否有一种简单的方法可以在Slim中实现具有多个级别的类似Twig的继承?
我做了一个小的Sinatra应用程序.在我的Gemfile中添加gem 'puma'
生产组
group :production do
gem 'puma'
gem 'dm-postgres-adapter'
end
Run Code Online (Sandbox Code Playgroud)
我设置了生产模式 config.ru
set :environment, :production
Run Code Online (Sandbox Code Playgroud)
但是在我运行之后,运行backup
默认的webrick Web服务器.我怎么解决这个问题?
我在我的Gemfile中添加了一些宝石,特别是activerecord,sinatra-activerecord,sqlite3,shotgun和tux.当我运行'捆绑安装'时,我得到了这个奇怪的错误,似乎没有关于它的任何Googleable信息.这是我得到的错误:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
make "DESTDIR=" clean
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
make "DESTDIR="
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
make failed, exit code 69
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.1/gems/bond-0.5.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.1/extensions/x86_64-darwin-12/2.1.0-static/bond-0.5.1/gem_make.out
An error occurred while installing bond (0.5.1), and Bundler cannot continue.
Make sure that `gem install bond -v …
Run Code Online (Sandbox Code Playgroud)