crabfarm 0.4.0 → 0.4.1

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.
@@ -0,0 +1,83 @@
1
+ div.crabfarm_overlay {
2
+ position: fixed !important;
3
+ top: 0 !important;
4
+ left: 0 !important;
5
+ width: 100% !important;
6
+ height: 100% !important;
7
+ z-index: 999999999 !important;
8
+ background: rgba(0,0,0,0.6) !important;
9
+ }
10
+
11
+ div.crabfarm_dialog {
12
+ position: relative !important;
13
+ margin: auto !important;
14
+ margin-top: 15% !important;
15
+ width: 80% !important;
16
+ min-height: 60% !important;
17
+ border-radius: 4px !important;
18
+
19
+ background: white !important;
20
+ }
21
+
22
+ div.crabfarm_dialog h1,
23
+ div.crabfarm_dialog h3,
24
+ div.crabfarm_dialog a {
25
+ color: white;
26
+ }
27
+
28
+ div.crabfarm_dialog.crabfarm_dialog_success {
29
+ border: 6px solid #009000;
30
+ background: #009000 !important;
31
+ }
32
+
33
+ div.crabfarm_dialog.crabfarm_dialog_error {
34
+ border: 6px solid #DD0000;
35
+ background: #DD0000 !important;
36
+ }
37
+
38
+ div.crabfarm_dialog .crabfarm_dialog_container {
39
+ padding: 10px !important;
40
+ }
41
+
42
+ div.crabfarm_dialog h1,
43
+ div.crabfarm_dialog h3 {
44
+ margin: 0;
45
+ margin-bottom: 5px;
46
+ padding: 0;
47
+ border: 0;
48
+ font: inherit;
49
+ font-size: 20px;
50
+ font-weight: bold;
51
+ vertical-align: baseline;
52
+ }
53
+
54
+ div.crabfarm_dialog h3 {
55
+ font-size: 14px;
56
+ font-weight: normal;
57
+ }
58
+
59
+ div.crabfarm_dialog .crabfarm_dialog_content {
60
+ margin: 10px;
61
+ border: none;
62
+ background: #DDD;
63
+ }
64
+
65
+ div.crabfarm_dialog .crabfarm_dialog_content pre {
66
+ max-height: 600px;
67
+ overflow: scroll;
68
+ color: black;
69
+ }
70
+
71
+ div.crabfarm_dialog .crabfarm_dialog_close {
72
+ position: absolute !important;
73
+ top: 5px !important;
74
+ right: 9px !important;
75
+ border: none !important;
76
+ text-decoration: none !important;
77
+ }
78
+
79
+ div.crabfarm_dialog .string { color: green; }
80
+ div.crabfarm_dialog .number { color: darkorange; }
81
+ div.crabfarm_dialog .boolean { color: blue; }
82
+ div.crabfarm_dialog .null { color: magenta; }
83
+ div.crabfarm_dialog .key { color: red; }
@@ -0,0 +1,93 @@
1
+ if(!window.crabfarm) {
2
+
3
+ var syntaxHighlight = function(json) {
4
+ if (typeof json != 'string') {
5
+ json = JSON.stringify(json, undefined, 4);
6
+ }
7
+
8
+ json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
9
+ return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
10
+ var cls = 'number';
11
+ if (/^"/.test(match)) {
12
+ if (/:$/.test(match)) {
13
+ cls = 'key';
14
+ } else {
15
+ cls = 'string';
16
+ }
17
+ } else if (/true|false/.test(match)) {
18
+ cls = 'boolean';
19
+ } else if (/null/.test(match)) {
20
+ cls = 'null';
21
+ }
22
+ return '<span class="' + cls + '">' + match + '</span>';
23
+ });
24
+ };
25
+
26
+ var buildResultDialog = function(_styleClass, _title, _subtitle, _content) {
27
+ var overlay = jQuerySG('<div>')
28
+ .addClass('selectorgadget_ignore')
29
+ .addClass('crabfarm_overlay');
30
+
31
+ var dialog = jQuerySG('<div>')
32
+ .addClass('crabfarm_dialog')
33
+ .addClass(_styleClass);
34
+
35
+ var container = jQuerySG('<div>')
36
+ .addClass('crabfarm_dialog_container');
37
+
38
+ var button = jQuerySG('<a href="javascript:void(0);">')
39
+ .addClass('crabfarm_dialog_close')
40
+ .text('x');
41
+
42
+ var removeOverlay = function() {
43
+ overlay.remove();
44
+ window.crabfarm.showSelectorGadget();
45
+ };
46
+
47
+ overlay.bind("click", removeOverlay);
48
+ button.bind("click", removeOverlay);
49
+
50
+ var content = jQuerySG('<div>')
51
+ .addClass('crabfarm_dialog_content')
52
+ .append(_content);
53
+
54
+ container.append(jQuerySG('<h1>').text(_title));
55
+ container.append(jQuerySG('<h3>').text(_subtitle));
56
+ container.append(content);
57
+
58
+ dialog.append(button);
59
+ dialog.append(container);
60
+ overlay.append(dialog);
61
+
62
+ jQuerySG('body').append(overlay);
63
+ };
64
+
65
+ window.crabfarm = {
66
+ showResults: function(_data, _elapsed) {
67
+ _data = JSON.parse(_data);
68
+
69
+ buildResultDialog(
70
+ 'crabfarm_dialog_success',
71
+ 'Navigation completed!',
72
+ 'The page was scrapped in ' + _elapsed + ' seconds',
73
+ jQuerySG('<pre>').html(syntaxHighlight(_data))
74
+ );
75
+ },
76
+
77
+ showError: function(_error, _trace) {
78
+ buildResultDialog(
79
+ 'crabfarm_dialog_error',
80
+ 'Navigation error!',
81
+ _error,
82
+ jQuerySG('<pre>').text(_trace)
83
+ );
84
+ },
85
+
86
+ showSelectorGadget: function() {
87
+ var gadget = new SelectorGadget();
88
+ gadget.makeInterface();
89
+ gadget.clearEverything();
90
+ gadget.setMode('interactive');
91
+ }
92
+ };
93
+ }
@@ -1,3 +1,3 @@
1
1
  module Crabfarm
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crabfarm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignacio Baixas
@@ -482,6 +482,10 @@ files:
482
482
  - lib/crabfarm/version.rb
483
483
  - lib/crabfarm.rb
484
484
  - bin/crabfarm
485
+ - assets/live-tools/selectorgadget_combined.css
486
+ - assets/live-tools/selectorgadget_combined.js
487
+ - assets/live-tools/tools.css
488
+ - assets/live-tools/tools.js
485
489
  homepage: https://github.com/platanus/crabfarm-gem
486
490
  licenses:
487
491
  - MIT