sunspot_solr 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/sunspot-solr +2 -6
- data/lib/sunspot/solr/server.rb +2 -3
- data/solr/README.txt +181 -181
- data/solr/bin/post +29 -19
- data/solr/bin/solr +247 -428
- data/solr/bin/solr.cmd +102 -256
- data/solr/bin/solr.in.cmd +15 -7
- data/solr/bin/solr.in.sh +26 -12
- data/solr/server/README.txt +110 -113
- data/solr/server/contexts/solr-jetty-context.xml +8 -8
- data/solr/server/etc/jetty-http.xml +47 -0
- data/solr/server/etc/jetty-https-ssl.xml +175 -159
- data/solr/server/etc/jetty-https.xml +53 -0
- data/solr/server/etc/jetty-ssl.xml +46 -0
- data/solr/server/etc/jetty.xml +189 -167
- data/solr/server/etc/webdefault.xml +527 -527
- data/solr/server/lib/javax.servlet-api-3.1.0.jar +0 -0
- data/solr/server/lib/jetty-continuation-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-deploy-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-http-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-io-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-jmx-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-rewrite-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-security-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-server-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-servlet-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-servlets-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-util-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-webapp-9.2.11.v20150529.jar +0 -0
- data/solr/server/lib/jetty-xml-9.2.11.v20150529.jar +0 -0
- data/solr/server/modules/http.mod +9 -0
- data/solr/server/modules/https.mod +9 -0
- data/solr/server/modules/server.mod +11 -0
- data/solr/server/modules/ssl.mod +9 -0
- data/solr/server/resources/jetty-logging.properties +1 -0
- data/solr/server/resources/log4j.properties +24 -24
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/commons-exec-1.3.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/{hadoop-annotations-2.3.0.jar → hadoop-annotations-2.6.0.jar} +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-auth-2.6.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-common-2.6.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-hdfs-2.6.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/htrace-core-3.0.4.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpclient-4.4.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpcore-4.4.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpmime-4.4.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/jackson-core-2.5.4.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/jackson-dataformat-smile-2.5.4.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-analyzers-common-5.0.0.jar → lucene-analyzers-common-5.3.1.jar} +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-analyzers-kuromoji-5.0.0.jar → lucene-analyzers-kuromoji-5.3.1.jar} +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-analyzers-phonetic-5.0.0.jar → lucene-analyzers-phonetic-5.3.1.jar} +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-backward-codecs-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-codecs-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-core-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-expressions-5.0.0.jar → lucene-expressions-5.3.1.jar} +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-grouping-5.0.0.jar → lucene-grouping-5.3.1.jar} +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-highlighter-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-join-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-memory-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-misc-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-queries-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-queryparser-5.0.0.jar → lucene-queryparser-5.3.1.jar} +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-sandbox-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-spatial-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-suggest-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/org.restlet-2.3.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/org.restlet.ext.servlet-2.3.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-core-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-solrj-5.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/t-digest-3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/web.xml +169 -181
- data/solr/server/solr-webapp/webapp/WEB-INF/weblogic.xml +28 -28
- data/solr/server/solr-webapp/webapp/admin.html +164 -163
- data/solr/server/solr-webapp/webapp/css/angular/analysis.css +304 -0
- data/solr/server/solr-webapp/webapp/css/angular/chosen.css +465 -0
- data/solr/server/solr-webapp/webapp/css/angular/cloud.css +398 -0
- data/solr/server/solr-webapp/webapp/css/angular/common.css +724 -0
- data/solr/server/solr-webapp/webapp/css/angular/cores.css +233 -0
- data/solr/server/solr-webapp/webapp/css/angular/dataimport.css +370 -0
- data/solr/server/solr-webapp/webapp/css/angular/documents.css +179 -0
- data/solr/server/solr-webapp/webapp/css/angular/files.css +53 -0
- data/solr/server/solr-webapp/webapp/css/angular/index.css +206 -0
- data/solr/server/solr-webapp/webapp/css/angular/logging.css +376 -0
- data/solr/server/solr-webapp/webapp/css/angular/menu.css +321 -0
- data/solr/server/solr-webapp/webapp/css/angular/plugins.css +212 -0
- data/solr/server/solr-webapp/webapp/css/angular/query.css +162 -0
- data/solr/server/solr-webapp/webapp/css/angular/replication.css +500 -0
- data/solr/server/solr-webapp/webapp/css/angular/schema-browser.css +567 -0
- data/solr/server/solr-webapp/webapp/css/angular/segments.css +173 -0
- data/solr/server/solr-webapp/webapp/css/angular/threads.css +161 -0
- data/solr/server/solr-webapp/webapp/css/chosen.css +421 -421
- data/solr/server/solr-webapp/webapp/css/styles/analysis.css +311 -311
- data/solr/server/solr-webapp/webapp/css/styles/cloud.css +410 -410
- data/solr/server/solr-webapp/webapp/css/styles/common.css +701 -701
- data/solr/server/solr-webapp/webapp/css/styles/cores.css +244 -244
- data/solr/server/solr-webapp/webapp/css/styles/dashboard.css +155 -155
- data/solr/server/solr-webapp/webapp/css/styles/dataimport.css +403 -403
- data/solr/server/solr-webapp/webapp/css/styles/documents.css +197 -197
- data/solr/server/solr-webapp/webapp/css/styles/files.css +54 -54
- data/solr/server/solr-webapp/webapp/css/styles/index.css +207 -207
- data/solr/server/solr-webapp/webapp/css/styles/java-properties.css +52 -52
- data/solr/server/solr-webapp/webapp/css/styles/logging.css +391 -391
- data/solr/server/solr-webapp/webapp/css/styles/menu.css +329 -328
- data/solr/server/solr-webapp/webapp/css/styles/plugins.css +195 -195
- data/solr/server/solr-webapp/webapp/css/styles/query.css +173 -173
- data/solr/server/solr-webapp/webapp/css/styles/replication.css +515 -515
- data/solr/server/solr-webapp/webapp/css/styles/schema-browser.css +578 -578
- data/solr/server/solr-webapp/webapp/css/styles/segments.css +145 -0
- data/solr/server/solr-webapp/webapp/css/styles/threads.css +172 -172
- data/solr/server/solr-webapp/webapp/img/chosen-sprite-2x.png +0 -0
- data/solr/server/solr-webapp/webapp/img/filetypes/README +27 -27
- data/solr/server/solr-webapp/webapp/img/solr.svg +39 -39
- data/solr/server/solr-webapp/webapp/index.html +208 -0
- data/solr/server/solr-webapp/webapp/js/angular/app.js +713 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/analysis.js +199 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/cloud.js +528 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/core-overview.js +225 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/cores.js +465 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/dataimport.js +284 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/documents.js +139 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/files.js +92 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/index.js +95 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/java-properties.js +45 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/logging.js +146 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/plugins.js +166 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/query.js +99 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/replication.js +227 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/schema-browser.js +432 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/segments.js +94 -0
- data/solr/server/solr-webapp/webapp/js/angular/controllers/threads.js +51 -0
- data/solr/server/solr-webapp/webapp/js/angular/services.js +214 -0
- data/solr/server/solr-webapp/webapp/js/lib/ZeroClipboard.js +342 -342
- data/solr/server/solr-webapp/webapp/js/lib/chosen.js +982 -982
- data/solr/server/solr-webapp/webapp/js/lib/console.js +29 -29
- data/solr/server/solr-webapp/webapp/js/lib/d3.js +9373 -9373
- data/solr/server/solr-webapp/webapp/js/lib/highlight.js +31 -31
- data/solr/server/solr-webapp/webapp/js/lib/jquery-1.7.2.min.js +30 -30
- data/solr/server/solr-webapp/webapp/js/lib/jquery.ajaxfileupload.js +184 -184
- data/solr/server/solr-webapp/webapp/js/lib/jquery.blockUI.js +523 -523
- data/solr/server/solr-webapp/webapp/js/lib/jquery.cookie.js +71 -71
- data/solr/server/solr-webapp/webapp/js/lib/jquery.form.js +806 -806
- data/solr/server/solr-webapp/webapp/js/lib/jquery.jstree.js +3534 -3534
- data/solr/server/solr-webapp/webapp/js/lib/jquery.sammy.js +1863 -1863
- data/solr/server/solr-webapp/webapp/js/lib/jquery.timeago.js +189 -189
- data/solr/server/solr-webapp/webapp/js/lib/linker.js +48 -48
- data/solr/server/solr-webapp/webapp/js/lib/naturalSort.js +82 -0
- data/solr/server/solr-webapp/webapp/js/lib/order.js +216 -216
- data/solr/server/solr-webapp/webapp/js/main.js +60 -58
- data/solr/server/solr-webapp/webapp/js/require.js +11349 -11349
- data/solr/server/solr-webapp/webapp/js/scripts/analysis.js +545 -545
- data/solr/server/solr-webapp/webapp/js/scripts/app.js +680 -679
- data/solr/server/solr-webapp/webapp/js/scripts/cloud.js +877 -877
- data/solr/server/solr-webapp/webapp/js/scripts/cores.js +719 -719
- data/solr/server/solr-webapp/webapp/js/scripts/dashboard.js +562 -562
- data/solr/server/solr-webapp/webapp/js/scripts/dataimport.js +812 -812
- data/solr/server/solr-webapp/webapp/js/scripts/documents.js +370 -370
- data/solr/server/solr-webapp/webapp/js/scripts/files.js +265 -265
- data/solr/server/solr-webapp/webapp/js/scripts/index.js +340 -340
- data/solr/server/solr-webapp/webapp/js/scripts/java-properties.js +106 -106
- data/solr/server/solr-webapp/webapp/js/scripts/logging.js +578 -576
- data/solr/server/solr-webapp/webapp/js/scripts/ping.js +72 -72
- data/solr/server/solr-webapp/webapp/js/scripts/plugins.js +462 -462
- data/solr/server/solr-webapp/webapp/js/scripts/query.js +229 -229
- data/solr/server/solr-webapp/webapp/js/scripts/replication.js +527 -527
- data/solr/server/solr-webapp/webapp/js/scripts/schema-browser.js +1229 -1229
- data/solr/server/solr-webapp/webapp/js/scripts/segments.js +206 -0
- data/solr/server/solr-webapp/webapp/js/scripts/threads.js +158 -158
- data/solr/server/solr-webapp/webapp/libs/angular-chosen.js +139 -0
- data/solr/server/solr-webapp/webapp/libs/angular-cookies.js +229 -0
- data/solr/server/solr-webapp/webapp/libs/angular-cookies.min.js +31 -0
- data/solr/server/solr-webapp/webapp/libs/angular-resource.min.js +36 -0
- data/solr/server/solr-webapp/webapp/libs/angular-route.js +1018 -0
- data/solr/server/solr-webapp/webapp/libs/angular-route.min.js +38 -0
- data/solr/server/solr-webapp/webapp/libs/angular-sanitize.js +703 -0
- data/solr/server/solr-webapp/webapp/libs/angular-sanitize.min.js +39 -0
- data/solr/server/solr-webapp/webapp/libs/angular.js +26093 -0
- data/solr/server/solr-webapp/webapp/libs/angular.min.js +273 -0
- data/solr/server/solr-webapp/webapp/libs/chosen.jquery.js +1194 -0
- data/solr/server/solr-webapp/webapp/libs/chosen.jquery.min.js +30 -0
- data/solr/server/solr-webapp/webapp/libs/d3.js +9373 -0
- data/solr/server/solr-webapp/webapp/libs/highlight.js +31 -0
- data/solr/server/solr-webapp/webapp/libs/jquery-2.1.3.min.js +29 -0
- data/solr/server/solr-webapp/webapp/libs/jquery.jstree.js +3534 -0
- data/solr/server/solr-webapp/webapp/libs/ngtimeago.js +102 -0
- data/solr/server/solr-webapp/webapp/partials/analysis.html +128 -0
- data/solr/server/solr-webapp/webapp/partials/cloud.html +104 -0
- data/solr/server/solr-webapp/webapp/partials/core_overview.html +227 -0
- data/solr/server/solr-webapp/webapp/partials/cores.html +231 -0
- data/solr/server/solr-webapp/webapp/partials/dataimport.html +209 -0
- data/solr/server/solr-webapp/webapp/partials/documents.html +118 -0
- data/solr/server/solr-webapp/webapp/partials/files.html +47 -0
- data/solr/server/solr-webapp/webapp/partials/index.html +261 -0
- data/solr/server/solr-webapp/webapp/partials/java-properties.html +27 -0
- data/solr/server/solr-webapp/webapp/partials/logging-levels.html +56 -0
- data/solr/server/solr-webapp/webapp/partials/logging.html +56 -0
- data/solr/server/solr-webapp/webapp/partials/plugins.html +72 -0
- data/solr/server/solr-webapp/webapp/partials/query.html +356 -0
- data/solr/server/solr-webapp/webapp/partials/replication.html +239 -0
- data/solr/server/solr-webapp/webapp/partials/schema-browser.html +206 -0
- data/solr/server/solr-webapp/webapp/partials/segments.html +99 -0
- data/solr/server/solr-webapp/webapp/partials/threads.html +65 -0
- data/solr/server/solr-webapp/webapp/tpl/analysis.html +83 -83
- data/solr/server/solr-webapp/webapp/tpl/cloud.html +87 -87
- data/solr/server/solr-webapp/webapp/tpl/cores.html +226 -226
- data/solr/server/solr-webapp/webapp/tpl/dashboard.html +201 -201
- data/solr/server/solr-webapp/webapp/tpl/dataimport.html +183 -183
- data/solr/server/solr-webapp/webapp/tpl/documents.html +107 -107
- data/solr/server/solr-webapp/webapp/tpl/files.html +44 -44
- data/solr/server/solr-webapp/webapp/tpl/index.html +250 -250
- data/solr/server/solr-webapp/webapp/tpl/logging.html +23 -23
- data/solr/server/solr-webapp/webapp/tpl/plugins.html +39 -39
- data/solr/server/solr-webapp/webapp/tpl/query.html +361 -361
- data/solr/server/solr-webapp/webapp/tpl/replication.html +216 -216
- data/solr/server/solr-webapp/webapp/tpl/schema-browser.html +192 -192
- data/solr/server/solr-webapp/webapp/tpl/segments.html +49 -0
- data/solr/server/solr-webapp/webapp/tpl/threads.html +56 -56
- data/solr/server/solr/README.txt +77 -77
- data/solr/server/solr/solr.xml +51 -51
- data/solr/server/solr/zoo.cfg +17 -17
- data/solr/server/start.jar +0 -0
- data/spec/server_spec.rb +3 -8
- metadata +132 -43
- data/solr/server/lib/jetty-continuation-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-deploy-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-http-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-io-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-jmx-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-security-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-server-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-servlet-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-util-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-webapp-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/jetty-xml-8.1.10.v20130312.jar +0 -0
- data/solr/server/lib/servlet-api-3.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/.gitignore +0 -1
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-auth-2.3.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-common-2.3.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-hdfs-2.3.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpclient-4.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpcore-4.3.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpmime-4.3.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-backward-codecs-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-codecs-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-core-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-highlighter-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-join-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-memory-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-misc-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-queries-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-spatial-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-suggest-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/org.restlet-2.1.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/org.restlet.ext.servlet-2.1.1.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-core-5.0.0.jar +0 -0
- data/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-solrj-5.0.0.jar +0 -0
- data/solr/server/webapps/solr.war +0 -0
|
@@ -1,370 +1,370 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
-
contributor license agreements. See the NOTICE file distributed with
|
|
4
|
-
this work for additional information regarding copyright ownership.
|
|
5
|
-
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
-
(the "License"); you may not use this file except in compliance with
|
|
7
|
-
the License. You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
//helper for formatting JSON and others
|
|
18
|
-
var content_generator = {
|
|
19
|
-
|
|
20
|
-
_default: function (toEsc) {
|
|
21
|
-
return toEsc.esc();
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
json: function (toEsc) {
|
|
25
|
-
return app.format_json(toEsc);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
//Utiltity function for turning on/off various elements
|
|
31
|
-
function toggles(documents_form, show_json, show_file, show_doc, doc_text, show_wizard) {
|
|
32
|
-
var json_only = $('#json-only');
|
|
33
|
-
var the_document = $('#document', documents_form);
|
|
34
|
-
if (show_doc) {
|
|
35
|
-
//console.log("doc: " + doc_text);
|
|
36
|
-
the_document.val(doc_text);
|
|
37
|
-
the_document.show();
|
|
38
|
-
} else {
|
|
39
|
-
the_document.hide();
|
|
40
|
-
}
|
|
41
|
-
if (show_json) {
|
|
42
|
-
json_only.show();
|
|
43
|
-
} else {
|
|
44
|
-
json_only.hide();
|
|
45
|
-
}
|
|
46
|
-
var file_upload = $('#file-upload', documents_form);
|
|
47
|
-
var upload_only = $('#upload-only', documents_form);
|
|
48
|
-
if (show_file) {
|
|
49
|
-
file_upload.show();
|
|
50
|
-
upload_only.show();
|
|
51
|
-
} else {
|
|
52
|
-
file_upload.hide();
|
|
53
|
-
upload_only.hide();
|
|
54
|
-
}
|
|
55
|
-
var wizard = $('#wizard', documents_form);
|
|
56
|
-
if (show_wizard) {
|
|
57
|
-
wizard.show();
|
|
58
|
-
} else {
|
|
59
|
-
wizard.hide();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// #/:core/documents
|
|
63
|
-
|
|
64
|
-
//Utiltity function for setting up the wizard fields
|
|
65
|
-
function addWizardFields(active_core, wizard) {
|
|
66
|
-
var core_basepath = active_core.attr('data-basepath');
|
|
67
|
-
var select_options = "";
|
|
68
|
-
//Populate the select options based off the Fields REST API
|
|
69
|
-
$.getJSON(window.location.protocol + '//' + window.location.host
|
|
70
|
-
+ core_basepath + "/schema/fields").done(
|
|
71
|
-
//TODO: handle dynamic fields
|
|
72
|
-
//TODO: get the unique key, too
|
|
73
|
-
function (data) {
|
|
74
|
-
var field_select = $("#wiz-field-select", wizard);
|
|
75
|
-
field_select.empty();
|
|
76
|
-
$.each(data.fields,
|
|
77
|
-
function (i, item) {
|
|
78
|
-
//console.log("i[" + i + "]=" + item.name);
|
|
79
|
-
if (item.name != "_version_"){
|
|
80
|
-
select_options += '<option name="' + item.name + '">'
|
|
81
|
-
+ item.name + '</option>';
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
//console.log("select_options: " + select_options);
|
|
85
|
-
//fill in the select options
|
|
86
|
-
field_select.append(select_options);
|
|
87
|
-
});
|
|
88
|
-
var wizard_doc = $("#wizard-doc", wizard);
|
|
89
|
-
wizard_doc.die('focusin')
|
|
90
|
-
.live('focusin', function (event) {
|
|
91
|
-
$("#wizard-doc", wizard).text("");
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
//Add the click handler for the "Add Field" target, which
|
|
95
|
-
//takes the field content and moves it into the document target
|
|
96
|
-
var add_field = $("#add-field-href", wizard);
|
|
97
|
-
add_field.die("click")
|
|
98
|
-
.live("click",
|
|
99
|
-
function (event) {
|
|
100
|
-
//take the field and the contents and append it to the document
|
|
101
|
-
var wiz_select = $("#wiz-field-select", wizard);
|
|
102
|
-
var selected = $("option:selected", wiz_select);
|
|
103
|
-
console.log("selected field: " + selected);
|
|
104
|
-
var wiz_doc = $("#wizard-doc", wizard);
|
|
105
|
-
var the_document = $("#document");
|
|
106
|
-
var current_doc = the_document.val();
|
|
107
|
-
console.log("current_text: " + current_doc + " wiz_doc: " + wiz_doc.val());
|
|
108
|
-
var index = current_doc.lastIndexOf("}");
|
|
109
|
-
var new_entry = '"' + selected.val() + '":"' + wiz_doc.val() + '"';
|
|
110
|
-
if (index >= 0) {
|
|
111
|
-
current_doc = current_doc.substring(0, index) + ', ' + new_entry + "}";
|
|
112
|
-
} else {
|
|
113
|
-
//we don't have a doc at all
|
|
114
|
-
current_doc = "{" + new_entry + "}";
|
|
115
|
-
}
|
|
116
|
-
current_doc = content_generator['json'](current_doc);
|
|
117
|
-
the_document.val(current_doc);
|
|
118
|
-
//clear the wiz doc window
|
|
119
|
-
wiz_doc.val("");
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
//console.log("adding " + i + " child: " + child);
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//The main program for adding the docs
|
|
129
|
-
sammy.get
|
|
130
|
-
(
|
|
131
|
-
new RegExp(app.core_regex_base + '\\/(documents)$'),
|
|
132
|
-
function (context) {
|
|
133
|
-
var active_core = this.active_core;
|
|
134
|
-
var core_basepath = active_core.attr('data-basepath');
|
|
135
|
-
var content_element = $('#content');
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
$.post
|
|
139
|
-
(
|
|
140
|
-
'tpl/documents.html',
|
|
141
|
-
function (template) {
|
|
142
|
-
|
|
143
|
-
content_element
|
|
144
|
-
.html(template);
|
|
145
|
-
var documents_element = $('#documents', content_element);
|
|
146
|
-
var documents_form = $('#form form', documents_element);
|
|
147
|
-
var url_element = $('#url', documents_element);
|
|
148
|
-
var result_element = $('#result', documents_element);
|
|
149
|
-
var response_element = $('#response', documents_element);
|
|
150
|
-
var doc_type_select = $('#document-type', documents_form);
|
|
151
|
-
//Since we are showing "example" docs, when the area receives the focus
|
|
152
|
-
// remove the example content.
|
|
153
|
-
$('#document', documents_form).die('focusin')
|
|
154
|
-
.live('focusin',
|
|
155
|
-
function (event) {
|
|
156
|
-
var document_type = $('#document-type', documents_form).val();
|
|
157
|
-
if (document_type != "wizard"){
|
|
158
|
-
//Don't clear the document when in wizard mode.
|
|
159
|
-
var the_document = $('#document', documents_form);
|
|
160
|
-
the_document.text("");
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
/*response_element.html("");*/
|
|
166
|
-
//Setup the handlers for toggling the various display options for the "Document Type" select
|
|
167
|
-
doc_type_select
|
|
168
|
-
.die('change')
|
|
169
|
-
.live
|
|
170
|
-
(
|
|
171
|
-
'change',
|
|
172
|
-
function (event) {
|
|
173
|
-
var document_type = $('#document-type', documents_form).val();
|
|
174
|
-
var file_upload = $('#file-upload', documents_form);
|
|
175
|
-
|
|
176
|
-
//need to clear out any old file upload by forcing a redraw so that
|
|
177
|
-
//we don't try to upload an old file
|
|
178
|
-
file_upload.html(file_upload.html());
|
|
179
|
-
if (document_type == "json") {
|
|
180
|
-
toggles(documents_form, true, false, true, '{"id":"change.me","title":"change.me"}', false);
|
|
181
|
-
$("#attribs").show();
|
|
182
|
-
} else if (document_type == "upload") {
|
|
183
|
-
toggles(documents_form, false, true, false, "", false);
|
|
184
|
-
$("#attribs").show();
|
|
185
|
-
} else if (document_type == "csv") {
|
|
186
|
-
toggles(documents_form, false, false, true, "id,title\nchange.me,change.me", false);
|
|
187
|
-
$("#attribs").show();
|
|
188
|
-
} else if (document_type == "solr") {
|
|
189
|
-
toggles(documents_form, false, false, true, '<add>\n' +
|
|
190
|
-
'<doc>\n' +
|
|
191
|
-
'<field name="id">change.me</field>\n' +
|
|
192
|
-
'<field name="title" >chang.me</field>\n' +
|
|
193
|
-
'</doc>\n' +
|
|
194
|
-
'</add>\n', false);
|
|
195
|
-
$("#attribs").hide();
|
|
196
|
-
} else if (document_type == "wizard") {
|
|
197
|
-
var wizard = $('#wizard', documents_form);
|
|
198
|
-
addWizardFields(active_core, wizard);
|
|
199
|
-
//$("#wizard-doc", wizard).text('Enter your field text here and then click "Add Field" to add the field to the document.');
|
|
200
|
-
toggles(documents_form, false, false, true, "", true);
|
|
201
|
-
$("#attribs").show();
|
|
202
|
-
} else if (document_type == "xml") {
|
|
203
|
-
toggles(documents_form, false, false, true, '<doc>\n' +
|
|
204
|
-
'<field name="id">change.me</field>' +
|
|
205
|
-
'<field name="title">change.me</field>' +
|
|
206
|
-
'</doc>', false);
|
|
207
|
-
$("#attribs").show();
|
|
208
|
-
}
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
);
|
|
212
|
-
doc_type_select.chosen().trigger('change');
|
|
213
|
-
//Setup the submit option handling.
|
|
214
|
-
documents_form
|
|
215
|
-
.die('submit')
|
|
216
|
-
.live
|
|
217
|
-
(
|
|
218
|
-
'submit',
|
|
219
|
-
function (event) {
|
|
220
|
-
var form_values = [];
|
|
221
|
-
var handler_path = $('#qt', documents_form).val();
|
|
222
|
-
if ('/' !== handler_path[0]) {
|
|
223
|
-
form_values.push({ name: 'qt', value: handler_path.esc() });
|
|
224
|
-
handler_path = '/update';
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
var document_url = window.location.protocol + '//' + window.location.host
|
|
228
|
-
+ core_basepath + handler_path + '?wt=json';
|
|
229
|
-
|
|
230
|
-
url_element
|
|
231
|
-
.attr('href', document_url)
|
|
232
|
-
.text(document_url)
|
|
233
|
-
.trigger('change');
|
|
234
|
-
var the_document = $('#document', documents_form).val();
|
|
235
|
-
var commit_within = $('#commitWithin', documents_form).val();
|
|
236
|
-
var boost = $('#boost', documents_form).val();
|
|
237
|
-
var overwrite = $('#overwrite', documents_form).val();
|
|
238
|
-
var the_command = "";
|
|
239
|
-
var content_type = "";
|
|
240
|
-
var document_type = $('#document-type', documents_form).val();
|
|
241
|
-
var doingFileUpload = false;
|
|
242
|
-
//Both JSON and Wizard use the same pathway for submission
|
|
243
|
-
//New entries primarily need to fill the_command and set the content_type
|
|
244
|
-
if (document_type == "json" || document_type == "wizard") {
|
|
245
|
-
//create a JSON command
|
|
246
|
-
the_command = "{"
|
|
247
|
-
+ '"add":{ "doc":' + the_document + ","
|
|
248
|
-
+ '"boost":' + boost + ","
|
|
249
|
-
+ '"overwrite":' + overwrite + ","
|
|
250
|
-
+ '"commitWithin":' + commit_within
|
|
251
|
-
+ "}}";
|
|
252
|
-
content_type = "application/json";
|
|
253
|
-
} else if (document_type == "csv") {
|
|
254
|
-
the_command = the_document;
|
|
255
|
-
document_url += "&commitWithin=" + commit_within + "&overwrite=" + overwrite;
|
|
256
|
-
content_type = "application/csv";
|
|
257
|
-
} else if (document_type == "xml") {
|
|
258
|
-
the_command = '<add commitWithin="' + commit_within
|
|
259
|
-
+ '" overwrite="' + overwrite + '"'
|
|
260
|
-
+ ">"
|
|
261
|
-
+ the_document + "</add>";
|
|
262
|
-
content_type = "text/xml";
|
|
263
|
-
} else if (document_type == "upload") {
|
|
264
|
-
doingFileUpload = true;
|
|
265
|
-
} else if (document_type == "solr") {
|
|
266
|
-
//guess content_type
|
|
267
|
-
the_command = the_document;
|
|
268
|
-
if (the_document.indexOf("<") >= 0) {
|
|
269
|
-
//XML
|
|
270
|
-
content_type = "text/xml";
|
|
271
|
-
} else if (the_document.indexOf("{") >= 0) {
|
|
272
|
-
//JSON
|
|
273
|
-
content_type = "application/json";
|
|
274
|
-
} //TODO: do we need to handle others?
|
|
275
|
-
} else {
|
|
276
|
-
//How to handle other?
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
//Handle the submission of the form in the case where we are not uploading a file
|
|
280
|
-
if (doingFileUpload == false) {
|
|
281
|
-
$.ajax(
|
|
282
|
-
{
|
|
283
|
-
url: document_url,
|
|
284
|
-
//dataType : 'json',
|
|
285
|
-
processData: false,
|
|
286
|
-
type: 'POST',
|
|
287
|
-
contentType: content_type,
|
|
288
|
-
data: the_command,
|
|
289
|
-
context: response_element,
|
|
290
|
-
beforeSend: function (xhr, settings) {
|
|
291
|
-
console.log("beforeSend: Vals: " + document_url + " content-type: " + document_type + " the cmd: " + the_command);
|
|
292
|
-
|
|
293
|
-
},
|
|
294
|
-
success: function (response, text_status, xhr) {
|
|
295
|
-
console.log("success: " + response + " status: " + text_status + " xhr: " + xhr.responseText);
|
|
296
|
-
this.html('<div><span class="description">Status</span>: ' + text_status + '</div>'
|
|
297
|
-
+ '<div><span class="description">Response:</span>' + '<pre class="syntax language-json"><code>' + content_generator['json'](xhr.responseText) + "</code></pre></div>");
|
|
298
|
-
result_element.show();
|
|
299
|
-
},
|
|
300
|
-
error: function (xhr, text_status, error_thrown) {
|
|
301
|
-
console.log("error: " + text_status + " thrown: " + error_thrown);
|
|
302
|
-
this.html('<div><span class="description">Status</span>: ' + text_status + '</div><div><span class="description">Error:</span> '
|
|
303
|
-
+ '' + error_thrown
|
|
304
|
-
+ '</div>'
|
|
305
|
-
+ '<div><span class="description">Error</span>:' + '<pre class="syntax language-json"><code>'
|
|
306
|
-
+ content_generator['json'](xhr.responseText) +
|
|
307
|
-
'</code></pre></div>');
|
|
308
|
-
result_element.show();
|
|
309
|
-
},
|
|
310
|
-
complete: function (xhr, text_status) {
|
|
311
|
-
//console.log("complete: " + text_status + " xhr: " + xhr.responseText + " doc type: " + document_type);
|
|
312
|
-
|
|
313
|
-
//alert(text_status + ": " + xhr.responseText);
|
|
314
|
-
/*this
|
|
315
|
-
.removeClass( 'loader' );*/
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
);
|
|
319
|
-
} else {
|
|
320
|
-
//upload the file
|
|
321
|
-
var the_file = $('#the-file', documents_form);
|
|
322
|
-
var erh_params = $('#erh-params', documents_form).val();
|
|
323
|
-
if (erh_params != "") {
|
|
324
|
-
if (erh_params.substring(0,1) != "&"){
|
|
325
|
-
erh_params = "&" + erh_params;
|
|
326
|
-
}
|
|
327
|
-
document_url = document_url + erh_params;
|
|
328
|
-
}
|
|
329
|
-
console.log("uploading file to: " + document_url);
|
|
330
|
-
the_file.ajaxfileupload({
|
|
331
|
-
'action': document_url,
|
|
332
|
-
'validate_extensions': false,
|
|
333
|
-
'upload_now': true,
|
|
334
|
-
'params': {
|
|
335
|
-
'extra': 'info'
|
|
336
|
-
},
|
|
337
|
-
'onComplete': function (response) {
|
|
338
|
-
response = response.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">', "");
|
|
339
|
-
response = response.replace("</pre>", "");
|
|
340
|
-
console.log('completed upload: ' + response);
|
|
341
|
-
response_element.html('<div><span class="description">Response:</span>' + '<pre class="syntax language-json"><code>' + content_generator['json'](response) + "</code></pre></div>");
|
|
342
|
-
result_element.show();
|
|
343
|
-
|
|
344
|
-
},
|
|
345
|
-
'onStart': function () {
|
|
346
|
-
console.log("starting file upload");
|
|
347
|
-
//if (weWantedTo) return false; // cancels upload
|
|
348
|
-
},
|
|
349
|
-
'onCancel': function () {
|
|
350
|
-
console.log('no file selected');
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
)
|
|
359
|
-
}
|
|
360
|
-
)
|
|
361
|
-
/*
|
|
362
|
-
Sample docs:
|
|
363
|
-
<doc boost="2.5">
|
|
364
|
-
<field name="id">05991</field>
|
|
365
|
-
<field name="title" boost="2.0">Bridgewater</field>
|
|
366
|
-
</doc>
|
|
367
|
-
|
|
368
|
-
{"id":"foo","title":"blah"}
|
|
369
|
-
|
|
370
|
-
*/
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
+
contributor license agreements. See the NOTICE file distributed with
|
|
4
|
+
this work for additional information regarding copyright ownership.
|
|
5
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
+
(the "License"); you may not use this file except in compliance with
|
|
7
|
+
the License. You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
//helper for formatting JSON and others
|
|
18
|
+
var content_generator = {
|
|
19
|
+
|
|
20
|
+
_default: function (toEsc) {
|
|
21
|
+
return toEsc.esc();
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
json: function (toEsc) {
|
|
25
|
+
return app.format_json(toEsc);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//Utiltity function for turning on/off various elements
|
|
31
|
+
function toggles(documents_form, show_json, show_file, show_doc, doc_text, show_wizard) {
|
|
32
|
+
var json_only = $('#json-only');
|
|
33
|
+
var the_document = $('#document', documents_form);
|
|
34
|
+
if (show_doc) {
|
|
35
|
+
//console.log("doc: " + doc_text);
|
|
36
|
+
the_document.val(doc_text);
|
|
37
|
+
the_document.show();
|
|
38
|
+
} else {
|
|
39
|
+
the_document.hide();
|
|
40
|
+
}
|
|
41
|
+
if (show_json) {
|
|
42
|
+
json_only.show();
|
|
43
|
+
} else {
|
|
44
|
+
json_only.hide();
|
|
45
|
+
}
|
|
46
|
+
var file_upload = $('#file-upload', documents_form);
|
|
47
|
+
var upload_only = $('#upload-only', documents_form);
|
|
48
|
+
if (show_file) {
|
|
49
|
+
file_upload.show();
|
|
50
|
+
upload_only.show();
|
|
51
|
+
} else {
|
|
52
|
+
file_upload.hide();
|
|
53
|
+
upload_only.hide();
|
|
54
|
+
}
|
|
55
|
+
var wizard = $('#wizard', documents_form);
|
|
56
|
+
if (show_wizard) {
|
|
57
|
+
wizard.show();
|
|
58
|
+
} else {
|
|
59
|
+
wizard.hide();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// #/:core/documents
|
|
63
|
+
|
|
64
|
+
//Utiltity function for setting up the wizard fields
|
|
65
|
+
function addWizardFields(active_core, wizard) {
|
|
66
|
+
var core_basepath = active_core.attr('data-basepath');
|
|
67
|
+
var select_options = "";
|
|
68
|
+
//Populate the select options based off the Fields REST API
|
|
69
|
+
$.getJSON(window.location.protocol + '//' + window.location.host
|
|
70
|
+
+ core_basepath + "/schema/fields").done(
|
|
71
|
+
//TODO: handle dynamic fields
|
|
72
|
+
//TODO: get the unique key, too
|
|
73
|
+
function (data) {
|
|
74
|
+
var field_select = $("#wiz-field-select", wizard);
|
|
75
|
+
field_select.empty();
|
|
76
|
+
$.each(data.fields,
|
|
77
|
+
function (i, item) {
|
|
78
|
+
//console.log("i[" + i + "]=" + item.name);
|
|
79
|
+
if (item.name != "_version_"){
|
|
80
|
+
select_options += '<option name="' + item.name + '">'
|
|
81
|
+
+ item.name + '</option>';
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
//console.log("select_options: " + select_options);
|
|
85
|
+
//fill in the select options
|
|
86
|
+
field_select.append(select_options);
|
|
87
|
+
});
|
|
88
|
+
var wizard_doc = $("#wizard-doc", wizard);
|
|
89
|
+
wizard_doc.die('focusin')
|
|
90
|
+
.live('focusin', function (event) {
|
|
91
|
+
$("#wizard-doc", wizard).text("");
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
//Add the click handler for the "Add Field" target, which
|
|
95
|
+
//takes the field content and moves it into the document target
|
|
96
|
+
var add_field = $("#add-field-href", wizard);
|
|
97
|
+
add_field.die("click")
|
|
98
|
+
.live("click",
|
|
99
|
+
function (event) {
|
|
100
|
+
//take the field and the contents and append it to the document
|
|
101
|
+
var wiz_select = $("#wiz-field-select", wizard);
|
|
102
|
+
var selected = $("option:selected", wiz_select);
|
|
103
|
+
console.log("selected field: " + selected);
|
|
104
|
+
var wiz_doc = $("#wizard-doc", wizard);
|
|
105
|
+
var the_document = $("#document");
|
|
106
|
+
var current_doc = the_document.val();
|
|
107
|
+
console.log("current_text: " + current_doc + " wiz_doc: " + wiz_doc.val());
|
|
108
|
+
var index = current_doc.lastIndexOf("}");
|
|
109
|
+
var new_entry = '"' + selected.val() + '":"' + wiz_doc.val() + '"';
|
|
110
|
+
if (index >= 0) {
|
|
111
|
+
current_doc = current_doc.substring(0, index) + ', ' + new_entry + "}";
|
|
112
|
+
} else {
|
|
113
|
+
//we don't have a doc at all
|
|
114
|
+
current_doc = "{" + new_entry + "}";
|
|
115
|
+
}
|
|
116
|
+
current_doc = content_generator['json'](current_doc);
|
|
117
|
+
the_document.val(current_doc);
|
|
118
|
+
//clear the wiz doc window
|
|
119
|
+
wiz_doc.val("");
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
//console.log("adding " + i + " child: " + child);
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//The main program for adding the docs
|
|
129
|
+
sammy.get
|
|
130
|
+
(
|
|
131
|
+
new RegExp(app.core_regex_base + '\\/(documents)$'),
|
|
132
|
+
function (context) {
|
|
133
|
+
var active_core = this.active_core;
|
|
134
|
+
var core_basepath = active_core.attr('data-basepath');
|
|
135
|
+
var content_element = $('#content');
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
$.post
|
|
139
|
+
(
|
|
140
|
+
'tpl/documents.html',
|
|
141
|
+
function (template) {
|
|
142
|
+
|
|
143
|
+
content_element
|
|
144
|
+
.html(template);
|
|
145
|
+
var documents_element = $('#documents', content_element);
|
|
146
|
+
var documents_form = $('#form form', documents_element);
|
|
147
|
+
var url_element = $('#url', documents_element);
|
|
148
|
+
var result_element = $('#result', documents_element);
|
|
149
|
+
var response_element = $('#response', documents_element);
|
|
150
|
+
var doc_type_select = $('#document-type', documents_form);
|
|
151
|
+
//Since we are showing "example" docs, when the area receives the focus
|
|
152
|
+
// remove the example content.
|
|
153
|
+
$('#document', documents_form).die('focusin')
|
|
154
|
+
.live('focusin',
|
|
155
|
+
function (event) {
|
|
156
|
+
var document_type = $('#document-type', documents_form).val();
|
|
157
|
+
if (document_type != "wizard"){
|
|
158
|
+
//Don't clear the document when in wizard mode.
|
|
159
|
+
var the_document = $('#document', documents_form);
|
|
160
|
+
the_document.text("");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
/*response_element.html("");*/
|
|
166
|
+
//Setup the handlers for toggling the various display options for the "Document Type" select
|
|
167
|
+
doc_type_select
|
|
168
|
+
.die('change')
|
|
169
|
+
.live
|
|
170
|
+
(
|
|
171
|
+
'change',
|
|
172
|
+
function (event) {
|
|
173
|
+
var document_type = $('#document-type', documents_form).val();
|
|
174
|
+
var file_upload = $('#file-upload', documents_form);
|
|
175
|
+
|
|
176
|
+
//need to clear out any old file upload by forcing a redraw so that
|
|
177
|
+
//we don't try to upload an old file
|
|
178
|
+
file_upload.html(file_upload.html());
|
|
179
|
+
if (document_type == "json") {
|
|
180
|
+
toggles(documents_form, true, false, true, '{"id":"change.me","title":"change.me"}', false);
|
|
181
|
+
$("#attribs").show();
|
|
182
|
+
} else if (document_type == "upload") {
|
|
183
|
+
toggles(documents_form, false, true, false, "", false);
|
|
184
|
+
$("#attribs").show();
|
|
185
|
+
} else if (document_type == "csv") {
|
|
186
|
+
toggles(documents_form, false, false, true, "id,title\nchange.me,change.me", false);
|
|
187
|
+
$("#attribs").show();
|
|
188
|
+
} else if (document_type == "solr") {
|
|
189
|
+
toggles(documents_form, false, false, true, '<add>\n' +
|
|
190
|
+
'<doc>\n' +
|
|
191
|
+
'<field name="id">change.me</field>\n' +
|
|
192
|
+
'<field name="title" >chang.me</field>\n' +
|
|
193
|
+
'</doc>\n' +
|
|
194
|
+
'</add>\n', false);
|
|
195
|
+
$("#attribs").hide();
|
|
196
|
+
} else if (document_type == "wizard") {
|
|
197
|
+
var wizard = $('#wizard', documents_form);
|
|
198
|
+
addWizardFields(active_core, wizard);
|
|
199
|
+
//$("#wizard-doc", wizard).text('Enter your field text here and then click "Add Field" to add the field to the document.');
|
|
200
|
+
toggles(documents_form, false, false, true, "", true);
|
|
201
|
+
$("#attribs").show();
|
|
202
|
+
} else if (document_type == "xml") {
|
|
203
|
+
toggles(documents_form, false, false, true, '<doc>\n' +
|
|
204
|
+
'<field name="id">change.me</field>' +
|
|
205
|
+
'<field name="title">change.me</field>' +
|
|
206
|
+
'</doc>', false);
|
|
207
|
+
$("#attribs").show();
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
doc_type_select.chosen().trigger('change');
|
|
213
|
+
//Setup the submit option handling.
|
|
214
|
+
documents_form
|
|
215
|
+
.die('submit')
|
|
216
|
+
.live
|
|
217
|
+
(
|
|
218
|
+
'submit',
|
|
219
|
+
function (event) {
|
|
220
|
+
var form_values = [];
|
|
221
|
+
var handler_path = $('#qt', documents_form).val();
|
|
222
|
+
if ('/' !== handler_path[0]) {
|
|
223
|
+
form_values.push({ name: 'qt', value: handler_path.esc() });
|
|
224
|
+
handler_path = '/update';
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
var document_url = window.location.protocol + '//' + window.location.host
|
|
228
|
+
+ core_basepath + handler_path + '?wt=json';
|
|
229
|
+
|
|
230
|
+
url_element
|
|
231
|
+
.attr('href', document_url)
|
|
232
|
+
.text(document_url)
|
|
233
|
+
.trigger('change');
|
|
234
|
+
var the_document = $('#document', documents_form).val();
|
|
235
|
+
var commit_within = $('#commitWithin', documents_form).val();
|
|
236
|
+
var boost = $('#boost', documents_form).val();
|
|
237
|
+
var overwrite = $('#overwrite', documents_form).val();
|
|
238
|
+
var the_command = "";
|
|
239
|
+
var content_type = "";
|
|
240
|
+
var document_type = $('#document-type', documents_form).val();
|
|
241
|
+
var doingFileUpload = false;
|
|
242
|
+
//Both JSON and Wizard use the same pathway for submission
|
|
243
|
+
//New entries primarily need to fill the_command and set the content_type
|
|
244
|
+
if (document_type == "json" || document_type == "wizard") {
|
|
245
|
+
//create a JSON command
|
|
246
|
+
the_command = "{"
|
|
247
|
+
+ '"add":{ "doc":' + the_document + ","
|
|
248
|
+
+ '"boost":' + boost + ","
|
|
249
|
+
+ '"overwrite":' + overwrite + ","
|
|
250
|
+
+ '"commitWithin":' + commit_within
|
|
251
|
+
+ "}}";
|
|
252
|
+
content_type = "application/json";
|
|
253
|
+
} else if (document_type == "csv") {
|
|
254
|
+
the_command = the_document;
|
|
255
|
+
document_url += "&commitWithin=" + commit_within + "&overwrite=" + overwrite;
|
|
256
|
+
content_type = "application/csv";
|
|
257
|
+
} else if (document_type == "xml") {
|
|
258
|
+
the_command = '<add commitWithin="' + commit_within
|
|
259
|
+
+ '" overwrite="' + overwrite + '"'
|
|
260
|
+
+ ">"
|
|
261
|
+
+ the_document + "</add>";
|
|
262
|
+
content_type = "text/xml";
|
|
263
|
+
} else if (document_type == "upload") {
|
|
264
|
+
doingFileUpload = true;
|
|
265
|
+
} else if (document_type == "solr") {
|
|
266
|
+
//guess content_type
|
|
267
|
+
the_command = the_document;
|
|
268
|
+
if (the_document.indexOf("<") >= 0) {
|
|
269
|
+
//XML
|
|
270
|
+
content_type = "text/xml";
|
|
271
|
+
} else if (the_document.indexOf("{") >= 0) {
|
|
272
|
+
//JSON
|
|
273
|
+
content_type = "application/json";
|
|
274
|
+
} //TODO: do we need to handle others?
|
|
275
|
+
} else {
|
|
276
|
+
//How to handle other?
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
//Handle the submission of the form in the case where we are not uploading a file
|
|
280
|
+
if (doingFileUpload == false) {
|
|
281
|
+
$.ajax(
|
|
282
|
+
{
|
|
283
|
+
url: document_url,
|
|
284
|
+
//dataType : 'json',
|
|
285
|
+
processData: false,
|
|
286
|
+
type: 'POST',
|
|
287
|
+
contentType: content_type,
|
|
288
|
+
data: the_command,
|
|
289
|
+
context: response_element,
|
|
290
|
+
beforeSend: function (xhr, settings) {
|
|
291
|
+
console.log("beforeSend: Vals: " + document_url + " content-type: " + document_type + " the cmd: " + the_command);
|
|
292
|
+
|
|
293
|
+
},
|
|
294
|
+
success: function (response, text_status, xhr) {
|
|
295
|
+
console.log("success: " + response + " status: " + text_status + " xhr: " + xhr.responseText);
|
|
296
|
+
this.html('<div><span class="description">Status</span>: ' + text_status + '</div>'
|
|
297
|
+
+ '<div><span class="description">Response:</span>' + '<pre class="syntax language-json"><code>' + content_generator['json'](xhr.responseText) + "</code></pre></div>");
|
|
298
|
+
result_element.show();
|
|
299
|
+
},
|
|
300
|
+
error: function (xhr, text_status, error_thrown) {
|
|
301
|
+
console.log("error: " + text_status + " thrown: " + error_thrown);
|
|
302
|
+
this.html('<div><span class="description">Status</span>: ' + text_status + '</div><div><span class="description">Error:</span> '
|
|
303
|
+
+ '' + error_thrown
|
|
304
|
+
+ '</div>'
|
|
305
|
+
+ '<div><span class="description">Error</span>:' + '<pre class="syntax language-json"><code>'
|
|
306
|
+
+ content_generator['json'](xhr.responseText) +
|
|
307
|
+
'</code></pre></div>');
|
|
308
|
+
result_element.show();
|
|
309
|
+
},
|
|
310
|
+
complete: function (xhr, text_status) {
|
|
311
|
+
//console.log("complete: " + text_status + " xhr: " + xhr.responseText + " doc type: " + document_type);
|
|
312
|
+
|
|
313
|
+
//alert(text_status + ": " + xhr.responseText);
|
|
314
|
+
/*this
|
|
315
|
+
.removeClass( 'loader' );*/
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
} else {
|
|
320
|
+
//upload the file
|
|
321
|
+
var the_file = $('#the-file', documents_form);
|
|
322
|
+
var erh_params = $('#erh-params', documents_form).val();
|
|
323
|
+
if (erh_params != "") {
|
|
324
|
+
if (erh_params.substring(0,1) != "&"){
|
|
325
|
+
erh_params = "&" + erh_params;
|
|
326
|
+
}
|
|
327
|
+
document_url = document_url + erh_params;
|
|
328
|
+
}
|
|
329
|
+
console.log("uploading file to: " + document_url);
|
|
330
|
+
the_file.ajaxfileupload({
|
|
331
|
+
'action': document_url,
|
|
332
|
+
'validate_extensions': false,
|
|
333
|
+
'upload_now': true,
|
|
334
|
+
'params': {
|
|
335
|
+
'extra': 'info'
|
|
336
|
+
},
|
|
337
|
+
'onComplete': function (response) {
|
|
338
|
+
response = response.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">', "");
|
|
339
|
+
response = response.replace("</pre>", "");
|
|
340
|
+
console.log('completed upload: ' + response);
|
|
341
|
+
response_element.html('<div><span class="description">Response:</span>' + '<pre class="syntax language-json"><code>' + content_generator['json'](response) + "</code></pre></div>");
|
|
342
|
+
result_element.show();
|
|
343
|
+
|
|
344
|
+
},
|
|
345
|
+
'onStart': function () {
|
|
346
|
+
console.log("starting file upload");
|
|
347
|
+
//if (weWantedTo) return false; // cancels upload
|
|
348
|
+
},
|
|
349
|
+
'onCancel': function () {
|
|
350
|
+
console.log('no file selected');
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
/*
|
|
362
|
+
Sample docs:
|
|
363
|
+
<doc boost="2.5">
|
|
364
|
+
<field name="id">05991</field>
|
|
365
|
+
<field name="title" boost="2.0">Bridgewater</field>
|
|
366
|
+
</doc>
|
|
367
|
+
|
|
368
|
+
{"id":"foo","title":"blah"}
|
|
369
|
+
|
|
370
|
+
*/
|