<commit_before># attache-rails

[![Gem Version](https://badge.fury.io/rb/attache-rails.svg)](https://badge.fury.io/rb/attache-rails)
[![Build Status](https://travis-ci.org/choonkeat/attache-rails.svg?branch=master)](https://travis-ci.org/choonkeat/attache-rails)

Ruby on Rails / ActiveRecord integration for [attache server](https://github.com/choonkeat/attache) using [attache/api](https://github.com/choonkeat/attache-api)

## Dependencies

[React](https://github.com/reactjs/react-rails), jQuery, Bootstrap 3

## Installation

**WARNING: Please see upgrade notes below if you are upgrading from V2**

Install the attache-rails package from Rubygems:

``` bash
gem install attache-rails
```

Or add this to your `Gemfile`

``` ruby
gem "attache-rails"
```

Add the attache javascript to your `application.js`

``` javascript
//= require attache
```

If you want to customize the file upload look and feel, define your own React `<AttacheFilePreview/>`, `<AttacheHeader/>`, `<AttachePlaceholder/>` renderer *before* including the attache js. For example,

``` javascript
//= require ./my_attache_file_preview.js
//= require attache
```

The `AttacheRails.upgrade_fileinputs` idempotent function is setup to find all the elements with `enable-attache` css class and upgrade them to use the direct upload & preview javascript. If you wish to re-run this function any other time, e.g. hookup the `cocoon:after-insert` event, you may

``` javascript
$(document).on('cocoon:after-insert', AttacheRails.upgrade_fileinputs);
```


## Usage
<commit_msg>Update README with instructions for using low level components<commit_after># attache-rails

[![Gem Version](https://badge.fury.io/rb/attache-rails.svg)](https://badge.fury.io/rb/attache-rails)
[![Build Status](https://travis-ci.org/choonkeat/attache-rails.svg?branch=master)](https://travis-ci.org/choonkeat/attache-rails)

Ruby on Rails / ActiveRecord integration for [attache server](https://github.com/choonkeat/attache) using [attache/api](https://github.com/choonkeat/attache-api)

## Dependencies

[React](https://github.com/reactjs/react-rails), jQuery, Bootstrap 3

## Installation

**WARNING: Please see upgrade notes below if you are upgrading from V2**

Install the attache-rails package from Rubygems:

``` bash
gem install attache-rails
```

Or add this to your `Gemfile`

``` ruby
gem "attache-rails"
```

Add the attache javascript to your `application.js`

``` javascript
//= require attache
```

#### Using its components alone

If you prefer to skip automatic upgrading of `input[type=file]`, you can wield `attache_file_input.AttacheFileInput` yourself

``` javascript
// = require attache/file_input
```

Or use the lower level components

``` javascript
//= require attache/cors_upload
//= require attache/bootstrap3

attache_cors_upload.CORSUpload
attache_bootstrap3.Bootstrap3FilePreview
attache_bootstrap3.Bootstrap3Header
attache_bootstrap3.Bootstrap3Placeholder
```

#### Customize UI

If you want to customize the file upload look and feel, define your own React `<AttacheFilePreview/>`, `<AttacheHeader/>`, `<AttachePlaceholder/>` renderer *before* including the attache js. For example,

``` javascript
//= require ./my_attache_file_preview.js
//= require attache
```

The `AttacheRails.upgrade_fileinputs` idempotent function is setup to find all the elements with `enable-attache` css class and upgrade them to use the direct upload & preview javascript. If you wish to re-run this function any other time, e.g. hookup the `cocoon:after-insert` event, you may

``` javascript
$(document).on('cocoon:after-insert', AttacheRails.upgrade_fileinputs);
```


## Usage

{'fraction_non_alphanumeric': 0.12822624931356397, 'fraction_numerical': 0.0030203185063152112, 'mean_word_length': 5.238013698630137, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 14, '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': '5116776', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1125, 'n_words': 326}