Git Product home page Git Product logo

mimetype-xml's Introduction

MimetypeXML

Custom mimetype from TOML to XML

Install

  • You need Ruby and Gems (gems comes with ruby) Install this gem with
gem install mimetype-xml 

# You might want to run this with sudo,
# or add the Gem userdir to the beginning of your $PATH variable
# like so in your bashrc: `PATH=$(ruby -e 'print Gem.user_dir')/bin:$PATH`
# This depends on your platform.

Usage

Create the TOML config (./custom-mime.toml):

## CUSTOM MIMETYPES TOML CONFIG FILE ##
# Optional variables ard marked with `(opt.)` in a
# comment at the end of the line

# Add mimetype for elixir files
[x-application-elixir]

type    = "application/x-elixir"
pattern = ["*.ex", "*.exs"] # Always in an array
                            # (even if only one pattern, e.g. ["*.ext"])

comment      = "Elixir File" # Default language
comment_lang = [ ["no", "Elixir Fil"], ["la", "Ordo Elixir"] ] # etc. (opt.)

icon = "mimetypes/application-x-elixir.svg"
size = 48 # I don't really know

xml_file = "elixir-file-mimetype.xml" # (opt.), not useful...


# Another for crystal files

[x-application-crystal]
type = "application/x-crystal"
pattern =  ["*.cr"]
comment = "Crystal File"
icon = "mimetypes/application-x-crystal.svg"
size = 48

# That simple to add new mimetypes, just make the icon in the
# path specified in the `icon` variable. 
# e.g. 'mimetypes/appliaction-x-myfile.svg'

Then generate the xml files and install it through a ruby script (./generate-mimetypes.rb):

require 'mimetype_xml'
require 'toml' # `toml` comes with this gem (`mimetype_xml`)

xml = MimetypeXML::Generate.toml_file(
  :file      => './custom-mime.toml', # The location of the TOML config
  :xml_dir   => '/usr/share/mime/packages/', # Make sure the dir is writable for the user, run `sudo chmod 777 /usr/share/mime/packages/`
  :icon_pack => '~/.icons/YOUR_ICON_PACK' # Replace this with the install dir of your iconpack
)

files = xml.write_files
files.install

Then run the script from your shell:

ruby ./generate-mimetypes.rb

The binary file doesn't do anything at the moment.

mimetype-xml's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.