serviceworker-rails | Use Service Worker with the Rails asset pipeline | Web Framework library

 by   rossta Ruby Version: v0.6.0 License: MIT

kandi X-RAY | serviceworker-rails Summary

kandi X-RAY | serviceworker-rails Summary

serviceworker-rails is a Ruby library typically used in Server, Web Framework, Ruby On Rails applications. serviceworker-rails has no vulnerabilities, it has a Permissive License and it has low support. However serviceworker-rails has 5 bugs. You can download it from GitHub.

Use Service Worker with the Rails asset pipeline
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              serviceworker-rails has a low active ecosystem.
              It has 569 star(s) with 43 fork(s). There are 11 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 8 open issues and 34 have been closed. On average issues are closed in 103 days. There are 23 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of serviceworker-rails is v0.6.0

            kandi-Quality Quality

              serviceworker-rails has 5 bugs (0 blocker, 0 critical, 5 major, 0 minor) and 13 code smells.

            kandi-Security Security

              serviceworker-rails has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              serviceworker-rails code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              serviceworker-rails is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              serviceworker-rails releases are not available. You will need to build from source code and install.
              Installation instructions, examples and code snippets are available.
              serviceworker-rails saves you 521 person hours of effort in developing the same functionality from scratch.
              It has 1222 lines of code, 120 functions and 68 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed serviceworker-rails and discovered the below as its top functions. This is intended to give you an instant insight into serviceworker-rails implemented functionality, and help decide if they suit your requirements.
            • Runs the block .
            • Initialize a Rack middleware .
            • Get the handler for a given handler .
            • Resolve handler
            • Returns the route handler for the given route .
            • Matches an asset against the given path .
            • Returns the middleware for the middleware .
            • Tries to respond to a rack response .
            • Matches the path for a Rack environment .
            • Returns the request headers .
            Get all kandi verified functions for this library.

            serviceworker-rails Key Features

            No Key Features are available at this moment for serviceworker-rails.

            serviceworker-rails Examples and Code Snippets

            No Code Snippets are available at this moment for serviceworker-rails.

            Community Discussions

            QUESTION

            "Could not find concurrent-ruby-1.1.7 in any of the sources" when deploy rails with capistrano
            Asked 2020-Oct-21 at 15:11

            I saw a lot of similar questions here, but nothing of provided advises has helped. Every time I run cap production deploy I got error:

            ...

            ANSWER

            Answered 2020-Oct-21 at 15:11

            How I solved it:

            1. Go to server command line
            2. As we can see in error log, the last command before error appears was:

            Command: cd /home/deploy/project/releases/20201018151933 && ( export RAILS_ENV="production" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.6.5" ; RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.6.5 $HOME/.rbenv/shims/bundle exec bundle check )

            So we go to our folder:

            cd /home/deploy/project/releases/20201018151933

            and run there command:

            export RAILS_ENV="production" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.6.5" ; RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.6.5 $HOME/.rbenv/shims/bundle exec bundle check

            After that we see same error:

            Could not find concurrent-ruby-1.1.7 in any of the sources. Run 'bundle install' to install missing gems.

            1. In same folder run bundle install and after gem installed we can out of server command line.
            2. Run cap production deploy and everything is gonna be fine.

            I still don't know what is the root problem of this error, and how to fix it permanently, but this works for me. I hope it will be useful for anyone else.

            Source https://stackoverflow.com/questions/64415137

            QUESTION

            Including Stripe card info in ajax form removes authenticity_token
            Asked 2020-Feb-20 at 22:54

            I have a form_tag using Ajax to save a new user card with Stripe. It renders a Stripe card form, passes the input to a controller method, and then is supposed to serve a js file. It works without the Stripe stuff, but with it, I'm getting authentication issues.

            Here's the basic code:

            ...

            ANSWER

            Answered 2020-Feb-20 at 22:54

            Keep everything as it was, and just update .submit()

            The actual issue is sending as HTML instead of as JS on form.submit().

            https://github.com/rails/rails/issues/29546

            Source https://stackoverflow.com/questions/60138894

            QUESTION

            How to fix importScripts not defined using service worker and onesignal?
            Asked 2019-Sep-18 at 01:41

            I am trying to set up a web push app, with one signal notifications. I know nothing about service workers, but used rails service-workers gem. I get this error >importScripts is not defined. I have already followed this tutorial from rossta, serviceworker-rails. The error must be in OneSignalSDKWorker.js.erb.

            I have already tried to change the name to OneSignalSDKWorker.js nothing seems to work. I'm working fully https on Heroku. make a function

            ...

            ANSWER

            Answered 2019-Sep-18 at 01:41

            I can see a couple potential issues.

            1) If you are attempting to importScripts from a service worker, that needs to be executed at the top of the file and not in a method. In other words, it needs to be the first thing that runs within your service worker.

            2) You are attempting to register multiple services workers which works but only if they are defined for different scopes. In the code you provided, you are registering them for the same scope which will only register one of them.

            Source https://stackoverflow.com/questions/57966276

            QUESTION

            How to reference the path to a compiled Webpack pack file from inside a JS file in Rails?
            Asked 2019-Aug-13 at 08:43

            I am using the webpacker gem (version 4.0.7) for a Rails 6 RC2 app, and I am also using serviceworker-rails middleware gem (version 0.6.0) to integrate Service Worker with Rails.

            Now, I want to create a serviceworker.js pack file (which I copied over and modified from serviceworker-rails README file) so that it can be served by Webpack and be routed using serviceworker-rails middleware.

            So, in app/javascript/packs/serviceworker.js.erb (with erb-loader installed), I did this:

            ...

            ANSWER

            Answered 2019-Aug-13 at 08:43

            So, after digging deep for so long, I found the solution from this issue on GitHub (and also realized that I didn't read and understand the error properly as the error was undefined method 'asset_pack_path' and has nothing to do with compilation whatsoever). The problem was fixed by simply doing:

            Source https://stackoverflow.com/questions/57422965

            QUESTION

            serviceworker-rails gem not intergrating with solidus eCommerce gem
            Asked 2018-Sep-23 at 03:47

            I am using the serviceworker-rails gem to make my eCommerce application a progressive web app. Here is a gem file snippet from the project;

            ...

            ANSWER

            Answered 2018-Sep-23 at 03:47

            I finally got it to work :) . The gem supplying the application layout is solidus but the problem is that the manifest is in the local application within which solidus is a gem.

            To make it visible to the gem; I removed the tags from

            Source https://stackoverflow.com/questions/52368561

            QUESTION

            Accessing webpacker helpers in myfile.js.erb
            Asked 2018-Feb-26 at 15:06

            I've got a Rails application that is using webpacker to serve the styles and the javascript. I'm using serviceworker-rails gem to have a service worker.

            Externally from the service worker installation I need to add the cache the css and js produced by webpack. How can i achieve this?

            I've tried serving the file with the asset pipeline an using the webpacker helpers but when it's compiled I get:

            ...

            ANSWER

            Answered 2018-Feb-26 at 15:06

            Accessing webpacker helpers in a file that will be part of applicaition.js produced by webpack is impossible (change my mind if you know how to do it)

            Instead I've used the asset pipeline to serve this file and inside use:
            <%= Webpacker.manifest.lookup 'application.css' %>
            to get the application styles, and will return something like:
            /packs/application-d85a17a26660e00c18a4d4f9535ee7d7.css

            The same applies for application.js

            Source https://stackoverflow.com/questions/48989560

            QUESTION

            push notification with Service Worker without subscribe
            Asked 2017-Oct-27 at 10:00

            right now i'm using push notification from this library https://github.com/rossta/serviceworker-rails

            I have followed the instructions and i have success implemented it, (i got the push notification). But now, i'm wondering whether is it possible for user to push notification without subscribe ? Because i wanted my push notification is sent after people register on my sign up form, and only admin who can subscribe & get push notification from new user registration.

            This is my script when a new user visit and sign up for the first time

            ...

            ANSWER

            Answered 2017-Oct-27 at 05:24

            You can send push notification from admin side using curl function. I did push notification recently using java script and PHP. You can send same as ruby on rails. Please refer firebase.google.com. You will get better idea.

            Using firebase three files is needed to send push notification. FIrst html/php/ruby file for allow user to accept permission. Second Service worker file upload in the root folder. Third server file need to send push notification for the individual token or group token. When user allows the notification you will get a token. You can save the token in the database and send the push notification.

            Html,

            Source https://stackoverflow.com/questions/46930467

            QUESTION

            Where to use "//= require" outside application.js?
            Asked 2017-May-12 at 09:37

            I'm getting an error while pushing to production...

            ...

            ANSWER

            Answered 2017-May-12 at 09:37

            Based on the second half of that note: "or replace require_tree with something more explicit." the issue should be solvable by removing //= require serviceworker-companion from the tree.

            You can acomplish that by adding an exception to the tree in the following way:

            (In aplication.js)

            After

            Source https://stackoverflow.com/questions/43930548

            QUESTION

            How to customize browser webpush notification body & icon?
            Asked 2017-May-01 at 17:51

            How can we make the browser notification icon and body dynamically customized based upon the @challenge.image and the @challenge.description?

            I got the notification to pop up by clicking webpush-button, but only the title of the message is dynamically changing. How can I make it work for body and icon too?

            challenges/show.html.erb

            ...

            ANSWER

            Answered 2017-Apr-26 at 12:31

            The event.data object in the self.addEventListener("push", (event)=> {...}), has a method json(), that method convert to json the event.data value.

            This will works only if the sended data is in the proper json format.

            Here is an example how I'm using web push:

            Source https://stackoverflow.com/questions/43633766

            QUESTION

            How to trigger browser notifications request on a specific action?
            Asked 2017-Apr-26 at 12:05

            As soon as a person comes to my site they are confronted with...

            But I only want that popup to occur after a user clicks "Push" so that the user may understand the context of the request.

            How to only trigger the browser notification request upon a user clicking "Push"?

            I implemented push via serviceworker gem, webpush gem, VAPID tutorial.

            ...

            ANSWER

            Answered 2017-Apr-26 at 11:13

            Just Wrap your notification asking part from application.js with function. Then add that function to click handlers of Push button.

            Source https://stackoverflow.com/questions/43631481

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install serviceworker-rails

            Add this line to your application's Gemfile:.
            After bundling the gem in your Rails project, run the generator from the root of your Rails project.
            config/initializers/serviceworker.rb - for configuring your Rails app
            app/assets/javascripts/serviceworker.js.erb - a blank Service Worker script with some example strategies
            app/assets/javascripts/serviceworker-companion.js - a snippet of JavaScript necessary to register your Service Worker in the browser
            app/assets/javascripts/manifest.json.erb - a starter web app manifest pointing to some default app icons provided by the gem
            public/offline.html - a starter offline page
            Adds a sprockets directive to application.js to require serviceworker-companion.js
            Adds serviceworker.js and manifest.json to the list of compiled assets in config/initializers/assets.rb
            Injects tags into the head of app/views/layouts/application.html.erb for linking to the web app manifest
            Let's add a ServiceWorker to cache some of your JavaScript and CSS assets. We'll assume you already have a Rails application using the asset pipeline built on Sprockets.
            The page requests a service worker at /serviceworker.js
            The Rails app responds to the request by compiling and rendering the file in app/assets/javascripts/serviceworker.js.erb.
            The console displays messages from the page and the service worker
            The application JavaScript and CSS assets are added to the browser's request/response Cache.

            Support

            Bug reports and pull requests are welcome on GitHub at https://github.com/rossta/serviceworker-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/rossta/serviceworker-rails.git

          • CLI

            gh repo clone rossta/serviceworker-rails

          • sshUrl

            git@github.com:rossta/serviceworker-rails.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link