Html 在 Rails 中创建类似背包的日历
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/247656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating a Backpack-like Calendar in Rails
提问by Gabe Hollombe
What are the current best practices in the Rails world for displaying a calendar month view with event items bound to the days in the month (like in Backpack or Google Calendar, for example)?
Rails 世界中显示日历月视图的当前最佳实践是什么,其中事件项目绑定到该月的天数(例如在 Backpack 或 Google 日历中)?
I don't need anything like fancy stuff like drag and drop support. I'm just looking for code to let me get a list of events in my controller and somehow expose them as entries in a monthly calendar display view (maybe with class names on the HTML elements to allow me to display different types of events differently, or maybe to display events from multiple calendars).
我不需要像拖放支持这样的花哨的东西。我只是在寻找代码来让我在我的控制器中获取事件列表,并以某种方式将它们公开为月历显示视图中的条目(可能在 HTML 元素上使用类名,以允许我以不同方式显示不同类型的事件,或者可能显示来自多个日历的事件)。
There's the Dynamic Calendar Helperthat was created a few years ago, which very well might still work just fine for me, but I'm just wondering if I should be looking at other plugins, too.
还有的动态日历助手已创建在几年前,这非常好可能仍然工作得很好,我,但我只是想知道如果我应该寻找其他的插件了。
Other possibilities I've found so far:
到目前为止我发现的其他可能性:
- A few possible contenders(judging from their descriptions) on GitHub
- Joyent Connector, which is now open source, has calendar capabilities
- GitHub 上的一些可能的竞争者(从他们的描述来看)
- Joyent Connector现已开源,具有日历功能
So, can you point me in the right direction as to what folks are using to output monthly calendars with data these days?
那么,您能否为我指出正确的方向,这些天人们使用什么来输出带有数据的月历?
采纳答案by Gabe Hollombe
I ended up going with the Dynamic Calendar Helper for now.
我现在最终使用了动态日历助手。
回答by Jeff Schuil
Here's a Rails plugin that can display multiple, overlapping events across calendar days.
这是一个 Rails 插件,可以跨日历日显示多个重叠事件。
http://github.com/elevation/event_calendar
http://github.com/elevation/event_calendar
Screenshot(s) at: http://dev.elevationblog.com/2009/7/23/event-calendar-rails-plugin
截图在:http: //dev.elevationblog.com/2009/7/23/event-calendar-rails-plugin
回答by user60683
Check out http://github.com/p8/table_builder/tree/master. It works more like form_for. It also doesn't require Event objects, just objects with a method that returns a date.
查看http://github.com/p8/table_builder/tree/master。它更像 form_for。它也不需要 Event 对象,只需要具有返回日期的方法的对象。
<% calendar_for(@tasks, :year => @year, :month => @month) do |t| %>
<%= t.head('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun') %>
<% t.day(:day_method => YOUR_DATE_METHOD) do |day, tasks| %>
<%= day.day %><br />
<% tasks.each do |task| %>
<%= h(task.name) %><br />
<% end %>
<% end %>
<% end %>
<% end %>
回答by Martin Dow
If anyone's still looking for a rails calendar plugin, Topfunky's calendar_helper now works well:
如果有人仍在寻找 rails 日历插件,Topfunky 的 calendar_helper 现在可以正常工作:
回答by bradheintz
I don't know if this suits the constraints of your problem, but have you looked at the Google Calendar API? I don't know whether you can count on your users having their own accounts, or whether you can programmatically create all the calendars you need on one account and just pull the per-calendar data through the API, but it might be worth a look.
我不知道这是否适合您问题的限制,但是您是否查看过Google Calendar API?我不知道您是否可以指望您的用户拥有自己的帐户,或者您是否可以通过编程方式在一个帐户上创建您需要的所有日历并通过 API 提取每个日历的数据,但它可能值得一看.
回答by Cameron McCloud
Take a look at the calendar view in Redmine.
查看 Redmine 中的日历视图。