<commit_before>//
//  WebStack.swift
//  BartlebyKit
//
//  Created by <NAME> on 28/07/2016.
//
//

import Cocoa
import WebKit

class WebStack: NSViewController,RegistryDependent {

    @IBOutlet weak var webView: WebView!

    private var URL:NSURL?

    private var _loadingAttempted:Bool=false

    var registryDelegate: RegistryDelegate?{
        didSet{
            if let document=self.registryDelegate?.getRegistry(){
                self.URL=NSURL(string: document.baseURL.absoluteString.stringByReplacingOccurrencesOfString("/api/v1", withString: "")+"/signIn?spaceUID=\(document.spaceUID)&userUID=\(document.registryMetadata.currentUser!.UID)&password=\(document.registryMetadata.currentUser!.password)");
            }
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }


    override func viewDidAppear() {
        super.viewDidAppear()
        if !self._loadingAttempted {
            if let URL=self.URL {
                let r=NSURLRequest(URL:URL)
                self.webView.mainFrame.loadRequest(r)
                self._loadingAttempted=true
            }
        }
    }

    
}<commit_msg>Allow url reloading in web stack in case of failure<commit_after>//
//  WebStack.swift
//  BartlebyKit
//
//  Created by <NAME> on 28/07/2016.
//
//

import Cocoa
import WebKit

class WebStack: NSViewController,RegistryDependent,WebFrameLoadDelegate {

    @IBOutlet weak var webView: WebView!{
        didSet{
            webView.frameLoadDelegate=self
        }
    }

    private var URL:NSURL?

    private var _loadingAttempted:Bool=false

    var registryDelegate: RegistryDelegate?{
        didSet{
            if let document=self.registryDelegate?.getRegistry(){
                self.URL=NSURL(string: document.baseURL.absoluteString.stringByReplacingOccurrencesOfString("/api/v1", withString: "")+"/signIn?spaceUID=\(document.spaceUID)&userUID=\(document.registryMetadata.currentUser!.UID)&password=\(document.registryMetadata.currentUser!.password)");
            }
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }


    override func viewDidAppear() {
        super.viewDidAppear()
        if !self._loadingAttempted {
            if let URL=self.URL {
                let r=NSURLRequest(URL:URL)
                self.webView.mainFrame.loadRequest(r)
                self._loadingAttempted=true
            }
        }
    }

    // Mark: WebFrameLoadDelegate
    
    public func webView(sender: WebView!, didFailLoadWithError error: NSError!, forFrame frame: WebFrame!){
        self._loadingAttempted=false
    }

}
{'fraction_non_alphanumeric': 0.10723860589812333, 'fraction_numerical': 0.0068939103791650705, 'mean_word_length': 2.4919786096256686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5754535', 'n_tokens_mistral': 807, 'n_tokens_neox': 747, 'n_words': 132}