更改rails_admin中的徽标

发布于 2024-10-14 20:29:02 字数 258 浏览 1 评论 0 原文

我很喜欢 https://github.com/sferik/rails_admin 的rails_admin插件,但我不能我的生活得到了我的自定义徽标来替换已安装的徽标。

有人对如何实现这一目标有任何见解吗?我尝试覆盖 css 和rails_admin 目录/fil 结构,但它没有接受我的更改。

有人对如何解决这个问题有任何见解吗?

I'm loving the rails_admin plugin from https://github.com/sferik/rails_admin but I cant for the life of me get my custom logo to replace the installed one.

Anyone have any insight as to how to achieve this? I've tried overriding the css and rails_admin directory/fil structure but it doesnt pick my changes up.

Anyone got any insight as to how to get this resolved?

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

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

发布评论

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

评论(8

蓝眼睛不忧郁 2024-10-21 20:29:02

如果你现在想这样做,有一个受支持的方法 - 只需通过在 app/views/rails_admin/main/_title.html.erb (或 .haml 或其他)创建文件来覆盖标题部分)。

例如我的包含:

%h1.title
  = link_to rails_admin_dashboard_path do
    = image_tag "design/admin_logo.png"

if you want to do this now, there is a supported method - just override the title partial by creating a file at app/views/rails_admin/main/_title.html.erb (or .haml or whatever).

Mine for instance contains:

%h1.title
  = link_to rails_admin_dashboard_path do
    = image_tag "design/admin_logo.png"
始于初秋 2024-10-21 20:29:02

我想您只需更改徽标即可将徽标放在应用程序中的这个位置:

public/images/rails_admin/logo.png

I suppose you just change the logo to put your logo in this place in your application :

public/images/rails_admin/logo.png
药祭#氼 2024-10-21 20:29:02

我不知道这是否正确,以及rails_admin作者是否也想要你,但一个肮脏的方法是进入你的rails_admin gem并重命名(或删除)资产文件夹,这样Rails就找不到Rack资产,因此它会回退到Rails您通过复制的内容:

rake admin:copy_assets

然后您只需修改应用程序公共目录中的内容即可。

我知道这是一种黑客行为,如果您更新 gem,则必须再次执行此操作。
再说一次,我不知道这是否是一个好的建议,因为我不知道 Rails Admin 作者的政策。

I don't know if this is right and if rails_admin author wants you too, but a dirty method is to go into your rails_admin gem and rename (or delete) assets folders so Rails don't find the Rack assets so it fallbacks on Rails ones that you've copied through :

rake admin:copy_assets

Then you just have to modify the ones in your app public directory.

I know it's kind of a hack and you'll have to do it again if you update the gem.
And again, I don't know if it's a good advise since I don't know Rails Admin author's policy.

莫多说 2024-10-21 20:29:02

您可以将 gem 安装文件夹(捆绑包 show Rails_admin)中的 /app/views/layouts/rails_admin 文件夹复制到项目的 app/views/layouts 文件夹中。然后你可以修改_header.html.erb部分,就行:

span class="image_replacement"><%= @plugin_name %>

希望这有帮助

You can copy the /app/views/layouts/rails_admin folder, located in the gem installation folder (bundle show rails_admin), into your project's app/views/layouts folder. Then you can modify the _header.html.erb partial, on the line:

span class="image_replacement"><%= @plugin_name %>

Hope this helps

潇烟暮雨 2024-10-21 20:29:02

另一种方法是:

before_filter :if => Proc.new{ |c| c.request.path =~ /admin/ } do 
  @head_stylesheet_paths = ['admin_screen.css'] 
end

然后用 important 重载 image_replacement 类。

.image_replacement{
  background-image:url(...) !important; 
}

Another way to do this would be:

before_filter :if => Proc.new{ |c| c.request.path =~ /admin/ } do 
  @head_stylesheet_paths = ['admin_screen.css'] 
end

Then you override the image_replacement class with a bang important.

.image_replacement{
  background-image:url(...) !important; 
}
枕梦 2024-10-21 20:29:02

经过深入研究并在rails_admin google group上询问后,似乎目前不支持此功能。

After digging around and asking on the rails_admin google group it appears that this functionality is not supported at the moment.

夏末 2024-10-21 20:29:02

替换

public/images/rails_admin/logo.png

只要您还执行了以下操作,

rake admin:copy_assets

就应该有效:作为安装的一部分。

Replacing

public/images/rails_admin/logo.png

Should work as long as you also did this:

rake admin:copy_assets

As part of your install.

紫南 2024-10-21 20:29:02

使用纯 scss 可以非常轻松地做到这一点。有时候,最简单的事情也会起作用:)

.navbar-inner {
  background-image: image_url('logo.png');
  background-size: auto $navbar-height; // put your own sizes here
  background-repeat: no-repeat;
}

.brand {
  display: none !important; //get rid of the text
}

You can do it extremely easily with pure scss. Sometimes the simplest thing that could work will work :)

.navbar-inner {
  background-image: image_url('logo.png');
  background-size: auto $navbar-height; // put your own sizes here
  background-repeat: no-repeat;
}

.brand {
  display: none !important; //get rid of the text
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文