This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # In your controller use the Rails in-built function, send_file to send the file to your browser for preview. | |
| # Specify the filepath of your file in the send_file function. | |
| def preview | |
| send_file "#{Rails.root}/uploads/pictures/#{@file.name}" | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def search | |
| @songs = Song.search(params[:query]) | |
| if request.xhr? | |
| render :json => @songs.to_json | |
| else | |
| render :index | |
| end | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <p id="notice"><%= notice %></p> | |
| <h1>Listing Songs</h1> | |
| <%= react_component "SongsContainer", { songsPath: songs_path(:json), searchPath: search_path } %> | |
| <%= link_to 'New Song', new_song_path %> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var SongsContainer = React.createClass({ | |
| componentWillMount(){ | |
| this.fetchSongs(); | |
| }, | |
| fetchSongs() { | |
| $.ajax({ | |
| url: this.props.songsPath, | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var Songs = React.createClass({ | |
| render() { | |
| var showSongs = (song) => <Song name={song.name} artist={song.artist} key={song.id}/>; | |
| return <ul>{this.props.songs.map(showSongs)}</ul>; | |
| } | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var Song = React.createClass({ | |
| render () { | |
| return ( | |
| <div> | |
| <h4>{ this.props.artist } sang:</h4> | |
| <p>{ this.props.name }</p> | |
| </div> | |
| ) | |
| } | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var SongsSearch = React.createClass({ | |
| render () { | |
| return ( | |
| <div> | |
| <form ref="form" action={ this.props.searchPath } acceptCharset="UTF-8" method="get"> | |
| <p><input ref="query" name="query" placeholder="Search here." onChange={ this.props.submitPath } /></p> | |
| </form> | |
| <a href="#" onClick={ this.props.cancelPath }>Cancel</a> | |
| </div> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | getNames: function(people) { | |
| var length = people.length; | |
| if (length == 0) { | |
| return ""; | |
| } else if (length == 1) { | |
| return people[0].name; | |
| } else if (length == 2) { | |
| return people[0].name + " and " + people[1].name; | |
| } else { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Time | |
| # Adds an offset to your time | |
| # So you can go from | |
| # Fri, 22 Jul 2016 07:56:38 UTC +00:00 | |
| # To, | |
| # Fri, 22 Jul 2016 13:26:38 UTC +00:00 | |
| # | |
| # Example, | |
| # t = Time.now.utc | |
| # => Fri, 22 Jul 2016 07:56:38 UTC +00:00 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'fileutils' | |
| require 'securerandom' | |
| directory = File.expand_path File.dirname(__FILE__) | |
| textfiles = "#{directory}/textfiles" | |
| FileUtils::mkdir_p textfiles | |
| Dir["#{directory}/*.scss"].each do |file| | |
| file_content = File.new(file, "r").read | |
| rgbas = file_content.scan(/rgba\(([0-9, ]*)/) | 
OlderNewer