GithubHelp home page GithubHelp logo

ouyoung / seaport Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ltebean/seaport

0.0 2.0 0.0 144 KB

Hybrid app framework which makes it easy to ship static resources to client

License: MIT License

seaport's Introduction

##Introduction Seaport makes it easy to ship static resources to ios client. You just need to add a few lines of code, Seaport will handle all the rest things, including:

  • download package
  • manage versions
  • syncronize local package
  • remove unused package

##Getting Started

Seaport provides a default package cloud, and with seaport-client you can easily manage your packages.

####1. Install seaport-client

Node.js environment is required, then install seaport-client by:

npm install -g seaport-client

####2. Register an Account

Run seaport adduser, specify your username and password:

seaport adduser -u ltebean -s test

####3. Publish a Package

Run seaport publish, specify the appName, packageName, and current version, the current working directory will be packed into a zip and published to the package cloud:

seaport publish -a TestApp -p index -v 1.0.0

####4. Activate a specific version

For example, activate version 1.1.0 of package 'index' with appName 'TestApp':

seaport activate -a TestApp -p index -v 1.1.0

####5. Intergrate Seaport in Your App On ios side, first init a Seaport client by specifing the appName and the address of package cloud:

Seaport *seaport = [[Seaport alloc]initWithAppName:@"TestApp"
                                        serverHost:@"223.4.15.141"
                                        sevrerPort:@"9984"
                                            dbName:@"seaport"];

Check whether there are some updates, usually it should be called when app starts:

[seaport checkUpdate];

Then you could ask Seaport where is your package's root path, then load static resources from that path:

NSString *rootPath = [seaport packagePath:@"index"];
if(rootPath){
    NSString *filePath = [rootPath stringByAppendingPathComponent:@"index.html"];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]];
    [self.webView loadRequest:request];
}

If you are interested in the life cycle of package management, you could implement Seaport protocal:

seaport.delegate = self;

Seaport protocal:

-(void)seaport:(Seaport*)seaport didStartDownloadPackage:(NSString*) packageName version:(NSString*) version;
  
-(void)seaport:(Seaport*)seaport didFinishDownloadPackage:(NSString*) packageName version:(NSString*) version;
  
-(void)seaport:(Seaport*)seaport didFailDownloadPackage:(NSString*) packageName version:(NSString*) version withError:(NSError*) error;
  
-(void)seaport:(Seaport*)seaport didFinishUpdatePackage:(NSString*) packageName version:(NSString*) version;  

Setup your own package cloud

Seaport uses couchdb as its backend, so you must install couchdb first.

After finished, create a database and import all the views and examples by replicating from "http://223.4.15.141:9984/seaport"

Finally change the host, port, dbname config to the correspoding value in your code.

seaport's People

Contributors

ltebean avatar

Watchers

James Cloos 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.