app/controllers/works_controller.rb
def import_single(urls, options)
    # try the import
    storyparser = StoryParser.new

    begin
      if urls.size == 1
        @work = storyparser.download_and_parse_story(urls.first, options)
      else
        @work = storyparser.download_and_parse_chapters_into_story(urls, options)
      end
    rescue Timeout::Error
      flash.now[:error] = ts("Import has timed out. This may be due to connectivity problems with the source site. Please try again in a few minutes, or check Known Issues to see if there are import problems with this site.")
      render :new_import and return
    rescue StoryParser::Error => exception
      flash.now[:error] = ts("We couldn't successfully import that work, sorry: %{message}", :message => exception.message)
      render :new_import and return
    end

    unless @work && @work.save
      flash.now[:error] = ts("We were only partially able to import this work and couldn't save it. Please review below!")
      @chapter = @work.chapters.first
      load_pseuds
      @series = current_user.series.uniq
      render :new and return
    end

    # Otherwise, we have a saved work, go us
    send_external_invites([@work])
    @chapter = @work.first_chapter if @work
    if @work.posted
      redirect_to work_path(@work) and return
    else
      redirect_to preview_work_path(@work) and return
    end
  end
# import a single work (possibly with multiple chapters)
import a single work (possibly with multiple chapters)
import a single work ( possibly with multiple chapters )
def import_single(urls, options)
    storyparser = StoryParser.new
    begin
      if urls.size == 1
        @work = storyparser.download_and_parse_story(urls.first, options)
      else
        @work = storyparser.download_and_parse_chapters_into_story(urls, options)
      end
    rescue Timeout::Error
      flash.now[:error] = ts("Import has timed out. This may be due to connectivity problems with the source site. Please try again in a few minutes, or check Known Issues to see if there are import problems with this site.")
      render :new_import and return
    rescue StoryParser::Error => exception
      flash.now[:error] = ts("We couldn't successfully import that work, sorry: %{message}", :message => exception.message)
      render :new_import and return
    end
    unless @work && @work.save
      flash.now[:error] = ts("We were only partially able to import this work and couldn't save it. Please review below!")
      @chapter = @work.chapters.first
      load_pseuds
      @series = current_user.series.uniq
      render :new and return
    end
    send_external_invites([@work])
    @chapter = @work.first_chapter if @work
    if @work.posted
      redirect_to work_path(@work) and return
    else
      redirect_to preview_work_path(@work) and return
    end
  end
def import_single ( urls , options ) storyparser = StoryParser . new begin if urls . size == 1 @work = storyparser . download_and_parse_story ( urls . first , options ) else @work = storyparser . download_and_parse_chapters_into_story ( urls , options ) end rescue Timeout :: Error flash . now [ :error ] = ts ( "Import has timed out. This may be due to connectivity problems with the source site. Please try again in a few minutes, or check Known Issues to see if there are import problems with this site." ) render :new_import and return rescue StoryParser :: Error => exception flash . now [ :error ] = ts ( "We couldn't successfully import that work, sorry: %{message}" , :message => exception . message ) render :new_import and return end unless @work && @work . save flash . now [ :error ] = ts ( "We were only partially able to import this work and couldn't save it. Please review below!" ) @chapter = @work . chapters . first load_pseuds @series = current_user . series . uniq render :new and return end send_external_invites ( [ @work ] ) @chapter = @work . first_chapter if @work if @work . posted redirect_to work_path ( @work ) and return else redirect_to preview_work_path ( @work ) and return end end
import a single work (possibly with multiple chapters)
import a single work ( possibly with multiple chapters )
# try the import # Otherwise, we have a saved work, go us
urls
options