Ruby on Rails 的多功能博客,密码保护?

发布于 2024-08-16 16:01:44 字数 276 浏览 6 评论 0原文

大家好,我正在制作一个带有博客的个人网站。我希望对某些条目进行密码保护,就像我在至少一个 WordPress 上看到的那样。这没什么大不了的。但我想知道是否有一些真正灵活的东西可以让隐藏的文本在发帖后显示出来?例如,公共帖子可能会说“我今天和朋友鲍勃一起喝咖啡”,但是在输入个人密码后,一些标记为私人的文本将类似于“鲍勃臭死了!!”另外,我想要为朋友、家人等提供不同的隐私层。不知道如何将它们联系在一起,但我什至对 Ruby 中的博客世界了解不多 - 有没有任何可扩展性足够好的东西,我可以我自己将这些功能组合在一起,而无需重新发明轮子?

Hey guys, I am making a personal website with a blog. I'd like to have certain entries password protected like I've seen on at least one wordpress. That's no biggie. But I was wondering if there was something really flexible which will allow hidden text to be revealed after a post? For example, the public post may say, "I met my friend Bob for coffee today" but upon putting in the personal password, some text tagged as being private will be like, "Bob stinks!!" Also, I'll want different layers of privacy for friends,family members, etc. Not sure how to tie it all together but I don't even know much about the blog world in Ruby - is there anything that's extensible enough that I could put together these features myself without having to reinvent the wheel?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

z祗昰~ 2024-08-23 16:01:44

Rails 有多个授权插件,它们具有视图助手,仅当用户具有适当的访问权限时才显示该标记。因此,家庭成员可以看到鲍勃很臭!,但客人只能看到公共帖子。 Javascript 对此可能有点过分了,除非你想在不刷新页面的情况下显示隐藏的数据。

acl_system2 有restrict_to方法。 CanCan 有罐吗?查看辅助方法。 这里是一些其他授权 gem/插件。

There are several authorization plugins for Rails that have view helpers that only display that markup when the user has appropriate access. So a family member could see Bob stinks!, but the guest would only see the public post. Javascript is probably overkill for this, unless you want to show the hidden data without refreshing the page.

acl_system2 has the restrict_to method. CanCan has the can? view helper method. Here are some other authorization gems/plugins.

柠檬色的秋千 2024-08-23 16:01:44

Ryan Bates 的 Cancan 库应该是一个灵活的授权解决方案,可能对您实现不同层的隐私有很好的帮助:http://github.com/ryanb/cancan

关于实现本身 - 我认为,这是一个太笼统的问题,无法在这里回答,并且由您作为软件设计师来决定方法。

Ryan Bates' Cancan library is supposed to be a flexible authorization solution that may be of good help for you with implementing different layers of privacy: http://github.com/ryanb/cancan

Concerning implementation as such - I think, it's too generic a question to be answered here, and is up to you as software designer to decide on the approach.

一杆小烟枪 2024-08-23 16:01:44

我不知道任何已经存在的库(如果有的话)具有上述功能;但我觉得鉴于上述要求;你首先需要一个权限框架;对权限进行细化管理。

通过将回调嵌入到视图中,视图应该是一件更容易做的事情。 (即在 HTML 中)使用 Jquery(或任何其他 JS 框架)和 JSON。成功验证用户身份后,您可以发出回调以使用 json 获取要显示的内容并将其附加到标记的 div 中。或者
您可以完全获取“受监管”的内容并将其显示给用户。

i am not aware of any libraries already existing (if any at all) for above mentioned functionality; but I feel that given the above requirement; you'd need a permission framework first; to manage permissions on a granular level.

The view should be a easier thing to do, with callbacks embedded in view. (i.e. in HTML) using Jquery (or any other JS framework) and JSON. Upon successfully authenticating user, you can issue the callbacks to fetch the content to be shown using json and append it to the marked divs. OR
you could fetched the "policed" content completely and show it to the user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文