Giter VIP home page Giter VIP logo

mattress's People

Contributors

cform avatar dmauro avatar kiliankoe avatar ledzeppelin avatar lordkev avatar prayagverma avatar segiddins avatar sharpfive avatar yas375 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mattress's Issues

storing multiple pages

I need to save multiple pages as user navigate through them, in example and in wiki you have used only 1 url should i use different database to store requested pages?

Swift 4

Is this project still alive?
Really need a Swift 4 version.

Issue using Mattress with CocoaPods & Swift 2.3

When including Mattress via CocoaPods and manually specifying the SWIFT_VERSION to 2.3, I get a compilation error with DiskCache.diskPath() (line 457):

if !NSFileManager.defaultManager().fileExistsAtPath(fileURL.absoluteString, isDirectory: &isDir) {
...
}

The issue stems from the fact that NSFileManager.fileExistsAtPath(...) accepts a non-optional string, so fileURL.absoluteString has to be unwrapped.

I pushed a fix to my own fork and raised a PR - just not too sure if my solution is the most ideal given the rest of the context of DiskCache. Let me know what you think ๐Ÿ‘

stuff not nil

When I add mattress to my project with alamofire and objectmapper this method in mattress says "stuff not nil"

func diskPathForRequest(request: NSURLRequest) -> NSURL? {
        var url: NSURL?
        if let
            hash = hashForRequest(request),
            baseURL = diskPath()
        {
            NSLog("stuff not nil")
            url = NSURL(string: hash, relativeToURL: baseURL)
        }
        return url
    }

Is there something I have to configure?

Example-Project does not build

(null): error: /Users/kevinlord/Library/Developer/Xcode/DerivedData/Mattress-aqemttuzbkdmvefylygnstriakjp/Build/Products/Debug-iphoneos/CommonCrypto.framework: No such file or directory

(null): error: /Users/kevinlord/Library/Developer/Xcode/DerivedData/Mattress-aqemttuzbkdmvefylygnstriakjp/Build/Products/Debug-iphoneos/Mattress.framework: No such file or directory

Seems the project has a dependency to kevins mac ;)

Use of unresolved identifier 'Mattress'

Hi,
after installation via cocoa pods this line
let urlCache = Mattress.URLCache(memoryCapacity: 20 * MB, diskCapacity: 20 * MB, diskPath: nil,
mattressDiskCapacity: 1 * GB, mattressDiskPath: nil, mattressSearchPathDirectory: .DocumentDirectory,
isOfflineHandler: isOfflineHandler)

shows an error Use of unresolved identifier 'Mattress'

DictionaryKey for DiskCache's current cache size mislabled

It shouldn't affect functionality, but the key used to store our current cache size is labeled as "maxCacheSize", which it is not. The maxCacheSize gets passed in on initialization each time. We should rename that, and while we're at it, go ahead and capitalize those DictionaryKey constants for style.

Add dependeny and update documenation

Hi,
could you please add Reachability as a dependency and/ or write this in the documentation? I added pod 'ReachabilitySwift', '~> 2.1' to my podfile and needed to update your example to the code below:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        setupCaching()

        return true
    }

    private func setupCaching(){

        do{
            let reach = try Reachability.reachabilityForInternetConnection()
            try reach.startNotifier()
            let kB = 1024
            let MB = 1024 * kB
            let GB = 1024 * MB
            let isOfflineHandler: (() -> Bool) = {
                let isOffline = reach.currentReachabilityStatus == Reachability.NetworkStatus.NotReachable
                return isOffline
            }
            let urlCache = Mattress.URLCache(memoryCapacity: 20 * MB, diskCapacity: 20 * MB, diskPath: nil,
                mattressDiskCapacity: 1 * GB, mattressDiskPath: nil, mattressSearchPathDirectory: .DocumentDirectory,
                isOfflineHandler: isOfflineHandler)

            NSURLCache.setSharedURLCache(urlCache)
        }
        catch let err as NSError {
            print("Error with caching: " + err.localizedDescription)
        }
    }

Matressdirectory empty

Hi I recognized that currently the data is stored outside the Mattress directory. Could you fix this please?

E.g. the data is currently stored here: "/Documents/00d550086fdea685f9832b96a29be3e0"

Warning iOS9, XCode 7.1.1

Mattress/Source/URLProtocol.swift:198:27: 'init(request:delegate:)' was deprecated in iOS 9.0: Use NSURLSession (see NSURLSession.h)

Could you remove this warning please?

FeatureRequest: Ship cached websites with app store build

I'm creating a conference app with an integration of some websites for venue, sponsors etc. This pages do not change quite often and it would be great to ship them cached with the app store build.

Some users start the app at the conference center for the first time where wifi conditions are sometimes very poor. Instead of showing a blank page the users should see at least "something".

It would be great if mattress could support this. What I currently would do is caching the websites within the simulator, cache the contents of the required pages and zip the mattress folder afterwards to ship it with the app (Currently there is a bug, see #33).

Is there something that can be solved by mattress to improve this process? For example that mattress could create the zip-file and present a mail dialog to bring the file to the devs machine? Or to update the cache automatically before creating the app store build?
Will the cache be working on other devices?

Plans to support Objective C Projects

Hi - i currently have a big Objective C Project that will not be migrated to Swift. It has been migrated to iOS9 as minimum deployment target.

Now I imported Mattress via cocoapods and and added the use_frameworks! tag. This causes problems with other imported libraries.

Have you planned to implement support for Objective C that is compatible to other library?
Another point is that I get a warning regarding deprecation of NSURLConnection in your lib with iOS9.

Caching with different states

I have recognized that a page often ends loading with a different state. I printing the line
let state = webView.stringByEvaluatingJavaScriptFromString("document.readyState")
to the console. Sometimes it finishes with "interactive" and sometimes with "completed" when loading the same url. Should the caching process then be repeated?

I tried to cache different pages consequently by calling.

cachePage(SiteA)
cachePage(SiteB)
cachePage(SiteC)

Is it possible that I have to wait until the former caching process has been completed? What I'm trying to achieve is that my apps caches certain pages after initialization to present them as fast as possible when the user visits them.

Another question: Does the caching mechanism needs an instance of a webView in my class or can it cache independently, so that I can put cachePage in it's own model class?

    func cachePage(url: NSURL) {
        log.info("Caching page \(url.absoluteString)")
        if let cache = NSURLCache.sharedURLCache() as? Mattress.URLCache
        {
            cache.diskCacheURL(url, loadedHandler: { (webView) -> (Bool) in
                    let state = webView.stringByEvaluatingJavaScriptFromString("document.readyState")
                    log.verbose("state: \(state)")
                    return state == "complete"
                }, completeHandler: { () -> Void in
                    log.info("Finished caching \(url.absoluteString)")
                }, failureHandler: { (error) -> Void in
                    log.error("Error caching: \(error.localizedDescription)")
            })
        }
    }

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.