Coder Social home page Coder Social logo

Comments (18)

swapnilchincholkar avatar swapnilchincholkar commented on June 10, 2024 3

Simply using the generator didn't work for me for rails.6 API only app.

  1. After using the generator
  2. I changed configs from config/initializers/apitome.rb as
    config.css_override = "/stylesheets/apitome/application.css"
    and
    config.js_override = "/javascripts/apitome/application.js"
  3. Manually copied theme file from gem's code to public/stylesheets/apitome/

That also gave issue post deployments hence at last
a. overridden then layout (i.e copied from gem to application) at "app/views/layouts/apitome.rb" with default css to refer as
<%= stylesheet_link_tag "/stylesheets/apitome/default.css", media: "all" %>

b. changed config file as
config.layout = "apitome"

That worked perfectly post-deployment too. Hope it helps someone too.

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

That's reasonable.. where would the assets get moved to? /public? Do people even serve static files usually with rails-api?

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

And then, if we don't use the asset pipeline, how do people override easily? It might take some playing. Could you not just use sprockets-rails with rails-api and have the same result?

from apitome.

Spone avatar Spone commented on June 10, 2024

For now, I switched to ActionController::Metal instead of rails-api, so I can include the needed modules.
I think using the default assets statically with Apitome could be enough (or hosting them separately on a CDN / static server). I didn't need to override the assets.

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

Right, you may not need to override the assets for now, but it's nice to have the possibility, and is a core aspect of the project. I can play around and see if this is possible.

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

well, after poking around.. you'd have to copy the files into your own project, since there's no way to serve "public" assets from a gem. so I guess a generator to install the assets is about as good as it gets.

from apitome.

Spone avatar Spone commented on June 10, 2024

Great! I'll keep an eye on this, let me know if I can be of some help 😃

EDIT: a generator would be totally fine for this specific use case!

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

let me know how that goes.

from apitome.

Spone avatar Spone commented on June 10, 2024

I think the generator should copy the files to the following paths:

public/stylesheets/apitome/application.css
public/javascripts/apitome/application.js

in order to work with the following settings:

config.css_override = 'apitome/application.css'
config.js_override = 'apitome/application.js'

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

you shouldn't have to configure anything.. just install them.

from apitome.

Spone avatar Spone commented on June 10, 2024

Well, if I do not configure anything, here is what I have in the documentation HTML :

<link href="/stylesheets/apitome/application.css" media="all" rel="stylesheet" />
<script src="/javascripts/apitome/application.js"></script>

I think it's because I don't use Sprockets.

This config works, though:

config.css_override = '/assets/apitome/application.css'
config.js_override = '/assets/apitome/application.js'

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

Ah, right.. right, so sprockets must take over javascript_include_tag and stylesheet_link_tag methods.. makes sense. so the generator should put them in public/javascripts/apitome etc.?

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

I just made an update to this, tell me if it works better.

from apitome.

Spone avatar Spone commented on June 10, 2024

Yes it's working 👍 Thanks!

from apitome.

samnang avatar samnang commented on June 10, 2024

@jejacks0n I'm using rails-api, currently I copy the files manually. How do I run either rake task or generator to copy assets files from my project?

from apitome.

chrishough avatar chrishough commented on June 10, 2024

This does appear to be working but should there be a task to gen those files? I had to generate them with the asset pipeline turned on, than rename them.

from apitome.

jejacks0n avatar jejacks0n commented on June 10, 2024

https://github.com/modeset/apitome/blob/master/lib/generators/apitome/install/install_generator.rb

from apitome.

chrishough avatar chrishough commented on June 10, 2024

@jejacks0n ahh, thanks 😸

from apitome.

Related Issues (20)

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.