webpackbin icon indicating copy to clipboard operation
webpackbin copied to clipboard

feature-request: Link to specific file for easy sharing

Open alexilyaev opened this issue 7 years ago • 2 comments

Hi,

I'm really excited about WebpackBin.

Would be great to be able to share a link of a bin which focuses a specific file. I was thinking we could add #filename.js or a /filename.js at the end.

@christianalfoni I"m willing to help if you could point me to where that URL logic should be written, I"m not familiar with the project.

Old issue ref:
https://github.com/christianalfoni/webpack-bin/issues/181

alexilyaev avatar May 06 '17 21:05 alexilyaev

@alexilyaev Hi there! That is a good idea :-)

Basically this is what needs to be done:

Given: "bins/id?file=someFileName.js

  1. In main.js the router needs to add property query: true, next to routes property. This will make the Cerebral router push queries into the signal payload

  2. Then the app.binRouted signal needs a function that checks if props.file exists, and if so it will make it the selected file

This should happen after the bin is grabbed from firebase:

      value(string`bins.${props`binKey`}`), {
        success: [
          when(props`value`), {
            true: [
              set(state`app.currentBinKey`, props`binKey`),
              setCurrentBin,
              // Here for example the current file is selected based on `props.file`, if exists :-)
              forceCodeUpdate,
              parallel([
                listenToBinStatsUpdates,
                whenLive, {
                  owner: connectLiveBinAsOwner,
                  participant: connectLiveBin,
                  otherwise: updateSandbox([
                    updateViewStats
                  ])
                }
              ])
            ],
            false: showSnackbar('This bin does not exist anymore, sorry', 5000, 'error')
          }
        ],
        error: showSnackbar('Unable to get BIN', 5000, 'error')
      }

christianalfoni avatar May 13 '17 12:05 christianalfoni

Stuck due to https://github.com/cerebral/webpackbin/issues/30

alexilyaev avatar May 14 '17 22:05 alexilyaev