Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !365

Removes inline_svg dependency.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/mariochavez/remove-inline_svg into master Dec 25, 2015
  • Overview 14
  • Commits 1
  • Pipelines 0
  • Changes 11

Created by: mariochavez

inline_svg gem is currently broken to work with Sprockets 3 and the Rails application environment set to production. So this has broken administrate as well. Normally a fix should be implemented in broken gem but after looking at why administrate requires inline_svg gem I realize that it is easy to replace it with a helper method.

ApplicationHelper#svg_tag method was added to substitute the work of inline_svg. This method creates a svg tag that will look like:

<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"><use
xlink:href="http://localhost:3000/assets/administrate/search-360c782d91a21edd53f5754c3fd8f8984ec5d9b36389f6df1fe618a4e50405b6.svg#search" width="16" height="16"></use></svg>

This will allow to resize the svg image and to use css to change properties like color.

But there are a couple of differences with inline_svg. First the svg file should have an id property, for my previous example it is search.

The second difference is that use tag needs to have height and width properties set as attributes of the tag, css properties will not affect the svg size.

ApplicationHelper#svg_tag used to generate html shown above looks like:

<%= svg_tag "administrate/search.svg",
  svg_id: "search", width: "16", height: "16" %>

This solution will play nice with Sprockets and with modern browsers.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/mariochavez/remove-inline_svg