Giter Site home page Giter Site logo

Comments (2)

SamyPesse avatar SamyPesse commented on September 26, 2024

GitKit works great with browserify or Webpack.

I can also build a dist js to be released on NPM, so that you can use it in webpage (But I think using browserify is a better solution):

<script src="./node_modules/gitkit/dist/gitkit.js"></script>
<script>
    var transport = new GitKit.HTTPTransport('https://github.com/GitbookIO/gitbook.git');
</script>

I'll add a note about this in the readme.

from gitkit-js.

lukpueh avatar lukpueh commented on September 26, 2024

I colleague asked me about this today, so I wrote together a little step by step howto, maybe this helps other people too:

# Create a local test directory and cd into it
mkdir gitkit-tests; cd gitkit-tests

# The current npm package does not contain the latest changes
# To have (browser-enabled) Memory filesystem we need to install
# from github
npm install SamyPesse/gitkit-js

# Install a required dependency
npm install mkdirp

# Install browserify globally
npm install browserify -g

# Bundle up gitkit and MemoryFS and wrap them in a require 
# function so that you can use require in the browser
browserify -r gitkit -r gitkit/lib/fs/memory -o bundle.js

# Hack to bypass “same origin” policy
# when you develop a browser extension, this shouldn’t be a problem
# cf. https://developer.chrome.com/extensions/xhr#extension-origin
sed -i.bak 's/cors/no-cors/g' bundle.js

# Create an html file that loads the bundle.js
echo "<script src='bundle.js'></script>" > index.html

Now you can fire up the html page in a browser and use the browser’s
console and use require just like in the node console, e.g.:

# In the browser's developer console
var GitKit = require('gitkit');
var MemoryFS = require('gitkit/lib/fs/memory');
var fs = MemoryFS()
var repo = GitKit.Repository.createWithFS(fs, true);
var transport = new GitKit.HTTPTransport('https://github.com/GitbookIO/gitbook.git');
# And so on ...

from gitkit-js.

Related Issues (14)

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.