...
 
Commits (1)
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}]
],
"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread",
["transform-class-properties", { "spec": true }]
]
}
......@@ -18,3 +18,6 @@
deploy.sh
.env
pids/
/public/packs
/public/packs-test
/node_modules
plugins:
postcss-smart-import: {}
postcss-cssnext: {}
......@@ -59,6 +59,7 @@ gem 'font-awesome-rails'
gem 'chosen-rails'
gem 'select2-rails'
gem 'rails-timeago', '~> 2.0'
gem 'webpacker', '~> 3.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
......
......@@ -89,6 +89,7 @@ GEM
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
cookiejar (0.3.3)
crass (1.0.3)
dalli (2.7.6)
debug_inspector (0.0.3)
descendants_tracker (0.0.4)
......@@ -119,7 +120,7 @@ GEM
em-socksify (0.3.1)
eventmachine (>= 1.0.0.beta.4)
equalizer (0.0.11)
erubi (1.6.1)
erubi (1.7.0)
erubis (2.7.0)
et-orbi (1.0.5)
tzinfo
......@@ -155,7 +156,8 @@ GEM
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
http_parser.rb (0.6.0)
i18n (0.8.6)
i18n (0.9.3)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
......@@ -189,16 +191,17 @@ GEM
activesupport (>= 4, < 5.2)
railties (>= 4, < 5.2)
request_store (~> 1.0)
loofah (2.0.3)
loofah (2.1.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.6)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
method_source (0.9.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.3.0)
minitest (5.10.3)
minitest (5.11.2)
minitest-rails (3.0.0)
minitest (~> 5.8)
railties (~> 5.0)
......@@ -222,7 +225,9 @@ GEM
rack (>= 1.2.0)
rack-protection (2.0.0)
rack
rack-test (0.7.0)
rack-proxy (0.6.3)
rack
rack-test (0.8.2)
rack (>= 1.0, < 3)
rails (5.1.4)
actioncable (= 5.1.4)
......@@ -256,7 +261,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.19.0)
rake (12.1.0)
rake (12.3.0)
rash (0.4.0)
hashie (~> 2.0.0)
rb-fsevent (0.10.2)
......@@ -318,7 +323,7 @@ GEM
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.8)
tzinfo (1.2.3)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
......@@ -338,6 +343,10 @@ GEM
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webpacker (3.2.1)
activesupport (>= 4.2)
rack-proxy (>= 0.6.1)
railties (>= 4.2)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
......@@ -398,6 +407,7 @@ DEPENDENCIES
unicorn
virtus
web-console
webpacker (~> 3.0)
BUNDLED WITH
1.14.6
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb
require('@rails/jquery');
require('@rails/jquery_ujs');
require('@rails/rails-timeago');
require('@rails/bootstrap-sprockets');
require('@rails/chosen-jquery');
require('@rails/momentjs');
require('search');
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
window.init = ->
title = $("[name='search[title]']")
author = $("[name='search[author]']")
summary = $("[name='search[summary]']")
saved = $("[name='saved_search_id']")
category_required = $("[name='search[category_required][]']")
category_optional = $("[name='search[category_optional][]']")
category_optional_exclude = $("[name='search[category_optional_exclude]']")
character_required = $("[name='search[character_required][]']")
character_optional = $("[name='search[character_optional][]']")
character_optional_exclude = $("[name='search[character_optional_exclude]']")
tags_include_ids = $("[name='search[tags_include_ids][]']")
tags_exclude_ids = $("[name='search[tags_exclude_ids][]']")
fandoms = $("[name='search[fandoms][]']")
crossovers = $("[name='search[crossovers][]']")
include_source_fandoms = $("[name='search[include_source_fandoms]']")
status = $("[name='search[status]']")
language = $("[name='search[language]']")
rating = $("[name='search[rating][]']")
wordcount_lower = $("[name='search[wordcount_lower]']")
wordcount_upper = $("[name='search[wordcount_upper]']")
chapters_lower = $("[name='search[chapters_lower]']")
chapters_upper = $("[name='search[chapters_upper]']")
published_after = $("[name='search[published_after]']")
published_before = $("[name='search[published_before]']")
updated_after = $("[name='search[updated_after]']")
updated_before = $("[name='search[updated_before]']")
sort_by = $("[name='search[sort_by]']")
order_by = $("[name='search[order_by]']")
selectors = {title,author,summary,saved,
category_required,category_optional,category_optional_exclude,
character_required,character_optional,character_optional_exclude,
fandoms,crossovers,include_source_fandoms
status,language,rating,
tags_include_ids, tags_exclude_ids,
wordcount_lower, wordcount_upper,
chapters_lower, chapters_upper,
published_after, published_before, updated_after, updated_before
sort_by,order_by
}
saved.chosen({allow_single_deselect: true}).off('change').on('change', (e,p) -> navigate(e,p))
category_required.chosen({max_selected_options: 2})
category_optional.chosen()
character_required.chosen({max_selected_options: 4})
character_optional.chosen()
tags_include_ids.chosen()
tags_exclude_ids.chosen()
fandoms.chosen().off('change').on('change', (e,p) -> updateFandom(e,p))
crossovers.chosen({allow_single_deselect: true}).off('change').on('change', (e,p) -> updateCrossover(e,p))
status.chosen({allow_single_deselect: true})
language.chosen({allow_single_deselect: true})
rating.chosen()
sort_by.chosen()
order_by.chosen()
$('#clear_fandoms').click ->
fandoms.val([])
$('#clear_crossovers').click ->
crossovers.val([])
$('#clear_character_required').click ->
character_required.val([])
$('#clear_character_optional').click ->
character_optional.val([])
$('#advanced_search :checkbox').click ->
updateCheckboxLabel($(this))
updateCheckboxLabel = (elem) ->
label_elem = $("label[for='"+elem.attr("name")+"']")
label = label_elem.data("type")
if (elem.is(':checked'))
label = "Excluded " + label
else
label = "Included " + label
label_elem.text(label)
navigate = (e,p) ->
opt = $("option:selected", $("[name='saved_search_id']"))[0]
if(opt.value != null && opt.value != "")
$.getJSON('/user/saved_searches/'+opt.value, (data) ->
s = data.search
title.val(s.title)
author.val(s.author)
summary.val(s.summary)
fandoms.val(s.fandoms)
fandoms.trigger('chosen:updated')
crossovers.val(s.crossovers)
crossovers.trigger('chosen:updated')
include_source_fandoms.prop('checked', s.include_source_fandoms)
updateFandom().done(->
# wait for crossovers change before adding chars
for prop in ['category', 'character']
for type in ['required', 'optional']
propname = prop + "_" + type
selectors[propname].val(s[propname])
selectors[propname].trigger('chosen:updated')
toggleprop = prop + "_optional_exclude"
selectors[toggleprop].prop('checked', s[toggleprop])
updateCheckboxLabel(selectors[toggleprop])
)
for prop in ['wordcount_lower', 'wordcount_upper', 'chapters_lower', 'chapters_upper',
'published_after', 'published_before', 'updated_after', 'updated_before',
'tags_include_ids', 'tags_exclude_ids',
'rating', 'language', 'status', 'sort_by', 'order_by']
selectors[prop].val(s[prop])
selectors[prop].trigger('chosen:updated')
)
updateCrossover = (e,p) ->
fandom = $("option:selected", $("[name='search[fandoms][]']"));
crossover = $("option:selected", $("[name='search[crossovers][]']"));
params = (fandom.map (c) -> "fandom[]="+$(this).val()).toArray()
.concat((crossover.map (c) -> "fandom[]="+$(this).val()).toArray())
if params.length > 0
$.getJSON("/characters?"+params.join('&'), (data) ->
select = $("[name='search[character_required][]']")
select2 = $("[name='search[character_optional][]']")
existing = select.val()
existing2 = select2.val()
options = select.prop('options')
options2 = select2.prop('options')
$('option', select).remove()
$('option', select2).remove()
$.each(data, (k,v) ->
options[options.length] = new Option(v.name,v.id)
options2[options.length] = new Option(v.name,v.id)
)
select.val(existing)
select2.val(existing2)
select.trigger('chosen:updated');
select2.trigger('chosen:updated');
)
else
$.Deferred().resolveWith({})
updateFandom = (e,p,c) ->
updateCrossover(e,p).done(->
fandom = $("option:selected", $("[name='search[fandoms][]']"));
crossover = $("option:selected", $("[name='search[crossovers][]']"));
fandoms_selected = (fandom.map (c) -> $(this).val()).toArray()
crossovers_selected = (crossover.map (c) -> $(this).val()).toArray()
params = (fandom.map (c) -> "fandom[]="+$(this).val()).toArray()
.concat((crossover.map (c) -> "fandom[]="+$(this).val()).toArray())
if params.length > 0
$.getJSON("/crossovers?"+params.join('&'), (data) ->
select = $("[name='search[crossovers][]']")
options = select.prop('options')
$('option', select).remove()
options[options.length] = new Option('', '')
$.each(data, (k,v) ->
options[options.length] = new Option(v.name,v.id)
)
select.val(crossovers_selected)
select.trigger('chosen:updated')
)
)
$ ->
$('.report-broken').click (e) ->
e.stopImmediatePropagation();
story_id = $(this).data('story-id')
$.post('/search/report_broken', {'story_id': story_id})
.done((data) -> alert('Reported link as broken! Thank you. It may take some time to deindex this story.'))
$('a.story-link').on 'mousedown', (e) ->
e.stopImmediatePropagation();
search = $('#search').data('search');
story_id = $(this).data('story-id')
searchParams = new URLSearchParams(location.search);
page = if searchParams && searchParams.has('page') then searchParams.get('page') else 1
$.post('/search/click', {
'story_id': story_id,
'search': search,
'page': page
})
......@@ -2,9 +2,9 @@
<html>
<head>
<title>Scryer<%= content_for?(:title) ? " :: #{content_for(:title)}" : '' %></title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= javascript_include_tag controller_name, media: 'all', 'data-turbolinks-track' => true %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'true' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': true %>
<%= javascript_pack_tag controller_name, media: 'all', 'data-turbolinks-track': true %>
<%= csrf_meta_tags %>
<%= favicon_link_tag favicon_name %>
<meta name="viewport" content="width=device-width">
......
const environment = require('./environment')
module.exports = environment.toWebpackConfig()
const { environment } = require('@rails/webpacker')
const coffee = require('./loaders/coffee')
environment.loaders.append('coffee', coffee)
module.exports = environment
module.exports = {
test: /\.coffee(\.erb)?$/,
use: [{
loader: 'coffee-loader'
}]
}
const environment = require('./environment')
module.exports = environment.toWebpackConfig()
const environment = require('./environment')
module.exports = environment.toWebpackConfig()
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
extensions:
- .coffee
- .erb
- .js
- .jsx
- .ts
- .vue
- .sass
- .scss
- .css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
disable_host_check: true
use_local_ip: false
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true