chatterbot 2.0.0.pre → 2.1.0

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.
Files changed (96) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +19 -0
  3. data/Gemfile +9 -17
  4. data/README.markdown +27 -34
  5. data/Rakefile +2 -18
  6. data/bin/chatterbot-register +6 -2
  7. data/chatterbot.gemspec +11 -12
  8. data/docs/Gemfile +3 -0
  9. data/docs/README.md +3 -0
  10. data/docs/_config.yml +37 -0
  11. data/docs/_includes/footer.html +3 -0
  12. data/docs/_includes/header.html +4 -0
  13. data/docs/_includes/navigation.html +23 -0
  14. data/docs/_layouts/default.html +98 -0
  15. data/docs/_layouts/page.html +11 -0
  16. data/docs/_posts/.gitkeep +0 -0
  17. data/docs/_site/Gemfile +3 -0
  18. data/docs/_site/advanced.html +465 -0
  19. data/docs/_site/configuration.html +436 -0
  20. data/docs/_site/contributing.html +414 -0
  21. data/docs/_site/css/main.css +58 -0
  22. data/docs/_site/css/syntax.css +61 -0
  23. data/docs/_site/deploying.html +451 -0
  24. data/docs/_site/examples.html +559 -0
  25. data/docs/_site/features.html +496 -0
  26. data/docs/_site/images/01-create-application.png +0 -0
  27. data/docs/_site/images/02-application-permissions.png +0 -0
  28. data/docs/_site/images/03-mobile-number.png +0 -0
  29. data/docs/_site/images/04-access-token.png +0 -0
  30. data/docs/_site/index.html +461 -0
  31. data/docs/_site/javascripts/main.js +1 -0
  32. data/docs/_site/other-tools.html +419 -0
  33. data/docs/_site/params.json +1 -0
  34. data/docs/_site/rdoc.html +409 -0
  35. data/docs/_site/setup.html +491 -0
  36. data/docs/_site/stylesheets/pygment_trac.css +68 -0
  37. data/docs/_site/stylesheets/stylesheet.css +247 -0
  38. data/docs/_site/tut.html +402 -0
  39. data/docs/_site/twitter-docs.html +409 -0
  40. data/docs/_site/walkthrough.html +447 -0
  41. data/docs/advanced.md +62 -0
  42. data/docs/basics.md +12 -0
  43. data/docs/bin/jekyll-page +109 -0
  44. data/docs/configuration.md +32 -0
  45. data/docs/contributing.md +14 -0
  46. data/docs/css/main.css +58 -0
  47. data/docs/css/syntax.css +61 -0
  48. data/docs/deploying.md +47 -0
  49. data/docs/examples.md +120 -0
  50. data/docs/features.md +88 -0
  51. data/docs/images/01-create-application.png +0 -0
  52. data/docs/images/02-application-permissions.png +0 -0
  53. data/docs/images/03-mobile-number.png +0 -0
  54. data/docs/images/04-access-token.png +0 -0
  55. data/docs/index.md +69 -0
  56. data/docs/javascripts/main.js +1 -0
  57. data/docs/other-tools.md +17 -0
  58. data/docs/params.json +1 -0
  59. data/docs/rdoc.md +6 -0
  60. data/docs/setup.md +84 -0
  61. data/docs/stylesheets/pygment_trac.css +68 -0
  62. data/docs/stylesheets/stylesheet.css +247 -0
  63. data/docs/tips.md +22 -0
  64. data/docs/tut.md +6 -0
  65. data/docs/twitter-docs.md +6 -0
  66. data/docs/walkthrough.md +46 -0
  67. data/ext/mkrf_conf.rb +28 -0
  68. data/lib/chatterbot.rb +0 -1
  69. data/lib/chatterbot/bot.rb +7 -63
  70. data/lib/chatterbot/client.rb +6 -12
  71. data/lib/chatterbot/config.rb +2 -2
  72. data/lib/chatterbot/config_manager.rb +7 -1
  73. data/lib/chatterbot/dsl.rb +20 -47
  74. data/lib/chatterbot/home_timeline.rb +1 -2
  75. data/lib/chatterbot/search.rb +26 -3
  76. data/lib/chatterbot/skeleton.rb +1 -3
  77. data/lib/chatterbot/tweet.rb +14 -3
  78. data/lib/chatterbot/ui.rb +88 -20
  79. data/lib/chatterbot/version.rb +1 -1
  80. data/spec/bot_spec.rb +2 -77
  81. data/spec/client_spec.rb +2 -6
  82. data/spec/config_manager_spec.rb +6 -5
  83. data/spec/config_spec.rb +4 -1
  84. data/spec/dsl_spec.rb +10 -35
  85. data/spec/fixtures/update_with_media.png +0 -0
  86. data/spec/search_spec.rb +40 -1
  87. data/spec/spec_helper.rb +1 -4
  88. data/spec/tweet_spec.rb +75 -38
  89. data/templates/skeleton.txt +26 -56
  90. metadata +84 -141
  91. data/.document +0 -5
  92. data/.travis.yml +0 -8
  93. data/examples/streaming_bot.rb +0 -48
  94. data/examples/tweet_logger.rb +0 -68
  95. data/lib/chatterbot/streaming.rb +0 -60
  96. data/spec/streaming_spec.rb +0 -170
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7333d751e027fb23ffd45e3df6a2602d271af411
4
- data.tar.gz: 29e07ecf21574c314f0603a16b6f7b65cf2af4ce
2
+ SHA256:
3
+ metadata.gz: 6b63ff09167dad5630abae41f3734aa861d4b4ad96c1cb643497bfc9ddc93483
4
+ data.tar.gz: bb89622d8d90d9e43ee7dddff4bedbb9854bb529bbe523a201a082b7a5a6383a
5
5
  SHA512:
6
- metadata.gz: 92e31e5c24e929fe2ecca7e9a8f01b1bfdc9dfb56754817bd44ce3dcf29a2bf3beb5c8e1a259059e31b4bb1d6f005e1c5f795ac573cef52478711005dd55c2b2
7
- data.tar.gz: ae42ada56f4635ea488e3996e3f7643aa5fcac79fd724a88512e0b4c39d3683189a3f9b21803411227464265981fb051f2697750ba23b4d7b74e38ea25e9eb9a
6
+ metadata.gz: 1be88671b540eabdac657837ede78bc7ff376902fd3252fcde201bc5dac7d4e68153b875a611127eea83053c6d3e2434534c43b12ed265a578bd04cc8c09bc6c
7
+ data.tar.gz: fe5c7963868895b81ace0c6a9f66449442a8cc6d183b84107e7a6486ca674fb8433637cb3539b8ba694cd4caa46a48f90c247505fe6aea1e2b7b6592acc0a375
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: Run tests
3
+ on: [push, pull_request]
4
+ jobs:
5
+ build:
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ os: [ubuntu-latest, macos-latest, windows-latest]
10
+ ruby: [2.5, 2.6, 2.7]
11
+ runs-on: ${{ matrix.os }}
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: ${{ matrix.ruby }}
17
+ bundler-cache: true
18
+ - name: rspec
19
+ run: bundle exec rake
data/Gemfile CHANGED
@@ -2,29 +2,21 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- #gem "twitter_oauth"
6
- #gem "sequel"
5
+ gem 'rake'
6
+ gem 'yard'
7
7
 
8
8
  # Add dependencies to develop your gem here.
9
9
  # Include everything needed to run rake, tests, features, etc.
10
10
  group :development do
11
- #gem 'simplecov', :require => false, :group => :test
12
-
13
- #gem "shoulda", ">= 0"
14
- #gem "rspec"
15
- #gem "rake"
16
- #gem "twitter", "~> 4.4.0"
17
-
18
- #gem "watchr"
11
+ gem 'pry'
19
12
  end
20
13
 
21
- gem "pry"
22
14
 
23
- #
24
- # couple extra gems for testing db connectivity
25
- #
26
15
  group :test do
27
- gem "sequel"
28
- gem "mysql"
29
- gem "sqlite3"
16
+ gem 'rspec', '~> 3.10.0'
17
+ gem 'rspec-mocks', '~> 3.10.0'
18
+ gem 'simplecov', '>= 0'
19
+ gem 'observr', '>= 0'
30
20
  end
21
+
22
+
data/README.markdown CHANGED
@@ -1,6 +1,11 @@
1
1
  Chatterbot
2
2
  ===========
3
3
 
4
+ Hey! This is Chatterbot 2.0. There have been some breaking changes
5
+ from older versions of the library, and it doesn't support MySQL
6
+ anymore. If you are looking for the old version,
7
+ you can try the [1.0 branch](https://github.com/muffinista/chatterbot/tree/1.0.2)
8
+
4
9
  Chatterbot is a Ruby library for making bots on Twitter. It's
5
10
  great for rapid development of bot ideas. It handles all of the basic
6
11
  Twitter API features -- searches, replies, tweets, retweets, etc. and has
@@ -17,7 +22,6 @@ Features
17
22
  * Simple blocklist system to limit your annoyance of users
18
23
  * Avoid your bot making a fool of itself by ignoring tweets with
19
24
  certain bad words
20
- * Basic Streaming API support
21
25
 
22
26
 
23
27
  Using Chatterbot
@@ -51,7 +55,7 @@ A bot using chatterbot can be as simple as this:
51
55
 
52
56
  ```
53
57
  exclude "http://"
54
- blacklist "mean_user, private_user"
58
+ blocklist "mean_user, private_user"
55
59
 
56
60
  puts "checking my timeline"
57
61
  home_timeline do |tweet|
@@ -71,14 +75,16 @@ end
71
75
  ```
72
76
 
73
77
  Or you can write a bot using more traditional ruby classes, extend it if needed, and use it like so:
74
-
75
- class MyBot < Chatterbot::Bot
78
+ ```
79
+ class MyBot < Chatterbot::Bot
76
80
  def do_stuff
77
- search("'surely you must be joking'") do |tweet|
78
- reply "@#{tweet_user(tweet)} I am serious, and don't call me Shirley!", tweet
81
+ home_timeline do |tweet|
82
+ puts "I like to favorite things"
83
+ favorite tweet
79
84
  end
80
85
  end
81
86
  end
87
+ ```
82
88
 
83
89
  Chatterbot can actually generate a template bot file for you, and will
84
90
  walk you through process of getting a bot authorized with Twitter.
@@ -95,25 +101,12 @@ that you should just be using the Twitter gem directly.
95
101
  Streaming
96
102
  ---------
97
103
 
98
- Chatterbot has some basic support for the Streaming API. If you want
99
- to do something complicated, you should probably consider using the
100
- [Twitter gem](https://github.com/sferik/twitter#streaming) directly.
101
-
102
- Basic usage is very straightforward:
103
-
104
- streaming true
105
- home_timeline do |tweet|
106
- puts "someone i follow tweeted! #{tweet.text}"
107
- end
108
-
109
-
110
- You can also run a search:
111
-
112
- streaming true
113
- search("pizza") do |tweet|
114
- puts "someone is talking about pizza! #{tweet.text}"
115
- end
116
-
104
+ Chatterbot used to have some basic support for the Streaming API, but
105
+ I've removed it because Twitter is removing and/or restricting access
106
+ to those APIs. If you need the Streaming API, I highly recommend using
107
+ the the [Twitter
108
+ gem](https://github.com/sferik/twitter#streaming). Chatterbot is built
109
+ on the Twitter gem, it works great, and has support for streaming.
117
110
 
118
111
 
119
112
  What Can I Do?
@@ -167,7 +160,7 @@ person who sent the original tweet.
167
160
 
168
161
  ```rb
169
162
  search "xyzzy" do |tweet|
170
- retweet(tweet[:id])
163
+ retweet(tweet.id)
171
164
  end
172
165
  ```
173
166
 
@@ -177,11 +170,11 @@ person who sent the original tweet.
177
170
 
178
171
  (NOTE: you'll need to make sure your bot has permission to send DMs)
179
172
 
180
- **blacklist** -- you can use this to specify a list of users you don't
173
+ **blocklist** -- you can use this to specify a list of users you don't
181
174
  want to interact with. If you put the following line at the top of
182
175
  your bot:
183
176
 
184
- blacklist "user1, user2, user3"
177
+ blocklist "user1, user2, user3"
185
178
 
186
179
  None of those users will trigger your bot if they come up in a
187
180
  search. However, if a user replies to one of your tweets or mentions
@@ -307,7 +300,7 @@ loop do
307
300
  search "twitter" do |tweet|
308
301
  # here you could do something with a tweet
309
302
  # if you want to retweet
310
- retweet(tweet[:id])
303
+ retweet(tweet.id)
311
304
  end
312
305
 
313
306
  replies do |tweet|
@@ -319,16 +312,16 @@ end
319
312
  ```
320
313
 
321
314
 
322
- Blacklists
315
+ Blocklists
323
316
  ----------
324
317
 
325
318
  Not everyone wants to hear from your bot. To keep annoyances to a
326
- minimum, Chatterbot has a simple blacklist tool. Using it is as simple as:
319
+ minimum, Chatterbot has a simple blocklist tool. Using it is as simple as:
327
320
 
328
- blacklist "mean_user, private_user"
321
+ blocklist "mean_user, private_user"
329
322
 
330
323
  You should really respect the wishes of users who don't want to hear
331
- from your bot, and add them to your blacklist whenever requested.
324
+ from your bot, and add them to your blocklist whenever requested.
332
325
 
333
326
  There's also an 'exclude' method which can be used to add
334
327
  words/phrases you might want to ignore -- for example, if you wanted
@@ -348,7 +341,7 @@ I can work with you on that.
348
341
  Copyright/License
349
342
  -----------------
350
343
 
351
- Copyright (c) 2015 Colin Mitchell. Chatterbot is distributed under the
344
+ Copyright (c) 2018 Colin Mitchell. Chatterbot is distributed under the
352
345
  MIT licence -- Please see LICENSE.txt for further details.
353
346
 
354
347
  http://muffinlabs.com
data/Rakefile CHANGED
@@ -1,30 +1,12 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require "chatterbot/version"
5
-
6
4
  require 'rspec/core'
7
5
  require 'rspec/core/rake_task'
8
6
  RSpec::Core::RakeTask.new(:spec) do |spec|
9
7
  spec.pattern = FileList['spec/**/*_spec.rb']
10
8
  end
11
9
 
12
- RSpec::Core::RakeTask.new(:rcov) do |spec|
13
- spec.pattern = 'spec/**/*_spec.rb'
14
- spec.rcov_opts = %w{--exclude .bundler,.rvm}
15
- spec.rcov = true
16
- end
17
-
18
- task :default => :spec
19
-
20
- require 'rdoc/task'
21
- Rake::RDocTask.new do |rdoc|
22
- rdoc.main = "README.rdoc"
23
- rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
24
- rdoc.rdoc_dir = 'rdoc'
25
- rdoc.title = "'chatterbot #{Chatterbot::VERSION}'"
26
- end
27
-
28
10
  task :console do
29
11
  require 'irb'
30
12
  require 'irb/completion'
@@ -32,3 +14,5 @@ task :console do
32
14
  ARGV.clear
33
15
  IRB.start
34
16
  end
17
+
18
+ task :default => :spec
@@ -58,6 +58,7 @@ end
58
58
  @bot.config.delete(:token)
59
59
  @bot.require_login(false)
60
60
 
61
+
61
62
  unless @bot.screen_name.nil?
62
63
  if @botname == "tmp_bot_name"
63
64
  puts "change botname to #{@bot.screen_name}"
@@ -66,8 +67,11 @@ unless @bot.screen_name.nil?
66
67
 
67
68
  puts "Storing config info"
68
69
  puts @bot.config.inspect
69
- @bot.update_config
70
- @bot.config = nil
70
+
71
+ config_src = File.join(Dir.getwd, "tmp_bot_name.yml")
72
+ config_dest = File.join(Dir.getwd, "#{@bot.botname}.yml")
73
+ File.rename(config_src, config_dest)
74
+
71
75
 
72
76
  if @skeleton
73
77
  skel_dest = File.join(Dir.getwd, "#{@bot.botname}.rb")
data/chatterbot.gemspec CHANGED
@@ -1,5 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ #$:.push File.expand_path("../lib", __FILE__)
3
6
  require "chatterbot/version"
4
7
 
5
8
  Gem::Specification.new do |s|
@@ -20,18 +23,14 @@ Gem::Specification.new do |s|
20
23
  s.require_paths = ["lib"]
21
24
  s.licenses = ["MIT"]
22
25
 
23
- s.add_development_dependency(%q<redcarpet>, [">= 0"])
24
- s.add_runtime_dependency(%q<oauth>, [">= 0.4.7"])
25
- s.add_runtime_dependency(%q<twitter>, ["5.14.0"])
26
+ # load activesupport but check ruby version along the way
27
+ s.extensions << 'ext/mkrf_conf.rb'
28
+
29
+ s.add_runtime_dependency(%q<oauth>, ["~> 0.5.6"])
30
+ s.add_runtime_dependency(%q<twitter>, ["~> 7"])
26
31
  s.add_runtime_dependency(%q<launchy>, [">= 2.4.2"])
27
32
  s.add_runtime_dependency(%q<colorize>, [">= 0.7.3"])
28
- s.add_development_dependency(%q<yard>, [">= 0"])
29
- s.add_development_dependency(%q<shoulda>, [">= 0"])
30
- s.add_development_dependency(%q<rake>, [">= 0"])
31
- s.add_development_dependency(%q<rspec>, ["~> 3.0.0"])
32
- s.add_development_dependency(%q<rspec-mocks>, ["~> 3.0.2"])
33
- s.add_development_dependency(%q<rdoc>, [">= 0"])
34
- s.add_development_dependency(%q<simplecov>, [">= 0"])
35
- s.add_development_dependency(%q<observr>, [">= 0"])
33
+
34
+ s.add_development_dependency 'bundler', '~> 2.0'
36
35
  end
37
36
 
data/docs/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem 'github-pages'
3
+
data/docs/README.md ADDED
@@ -0,0 +1,3 @@
1
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/bruth/jekyll-docs-template/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
2
+
3
+ Read the docs: http://bruth.github.io/jekyll-docs-template
data/docs/_config.yml ADDED
@@ -0,0 +1,37 @@
1
+ # Site title and subtitle. This is used in _includes/header.html
2
+ title: 'chatterbot'
3
+ subtitle: 'twitter bots in ruby'
4
+
5
+ # Enable/show navigation. There are there options:
6
+ # 0 - always hide
7
+ # 1 - always show
8
+ # 2 - show only if posts are present
9
+ navigation: 1
10
+
11
+ # URL to source code, used in _includes/footer.html
12
+ codeurl: 'https://github.com/muffinista/chatterbot'
13
+
14
+ # Default categories (in order) to appear in the navigation
15
+ sections: [
16
+ ['tut', 'Getting Started'],
17
+ ['doc', 'Documentation'],
18
+ ['dev', 'Developers'],
19
+ ['links', 'Resources']
20
+ ]
21
+
22
+ # Keep as an empty string if served up at the root. If served up at a specific
23
+ # path (e.g. on GitHub pages) leave off the trailing slash, e.g. /my-project
24
+ baseurl: '/chatterbot'
25
+
26
+ # Dates are not included in permalinks
27
+ permalink: none
28
+
29
+ # Syntax highlighting
30
+ highlighter: 'rouge'
31
+
32
+ # Since these are pages, it doesn't really matter
33
+ future: true
34
+
35
+ # Exclude non-site files
36
+ exclude: ['bin', 'README.md']
37
+
@@ -0,0 +1,3 @@
1
+ <!--
2
+ Documentation for <a href="{% if site.codeurl %}{{ site.codeurl }}{% else %}{{ site.baseurl }}{% endif %}">{{ site.title }}</a>
3
+ -->
@@ -0,0 +1,4 @@
1
+ <h4><a class=brand href="{{ site.baseurl }}/">{{ site.title }}</a>
2
+ {% if site.subtitle %}<small>{{ site.subtitle }}</small>{% endif %}
3
+ </h4>
4
+
@@ -0,0 +1,23 @@
1
+ <ul class="nav nav-list">
2
+ <li><a href="{{ site.baseurl }}/">Home</a></li>
3
+ {% for section in site.sections %}
4
+ {% assign attr = section[0] %}
5
+ {% assign label = section[1] %}
6
+ <li class=nav-header>{{ label }}</li>
7
+ {% for page in site.pages %}
8
+ {% if page.published != false %}
9
+ {% if page.category == attr %}
10
+ <li data-order="{{ page.order }}">
11
+ {% if page.link %}
12
+ <a href="{{ page.link }}">{{ page.title }}</a>
13
+ {% else %}
14
+ <a href="{{ site.baseurl }}{{ page.url }}">{{ page.title }}</a>
15
+ {% endif %}
16
+ </li>
17
+ {% endif %}
18
+ {% endif %}
19
+ {% endfor %}
20
+ {% endfor %}
21
+ <!-- List additional links. It is recommended to add a divider
22
+ e.g. <li class=divider></li> first to break up the content. -->
23
+ </ul>
@@ -0,0 +1,98 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <meta name="viewport" content="width=device-width">
7
+
8
+ <title>{{ site.title }}{% if page.title %} : {{ page.title }}{% endif %}</title>
9
+ <meta name="description" content="{{ site.subtitle }}">
10
+
11
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
12
+ <link rel="stylesheet" href="{{ site.baseurl }}/css/syntax.css">
13
+ <link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">
14
+ </head>
15
+ <body>
16
+
17
+ <div class="container">
18
+ <div class=row-fluid>
19
+ <div id=header class=span12>
20
+ {% include header.html %}
21
+ </div>
22
+ </div>
23
+
24
+ <div class=row-fluid>
25
+ {% assign post_count = site.posts|size %}
26
+ {% if site.navigation != 0 and site.navigation == 1 or post_count > 0 %}
27
+ <div id=navigation class=span2>
28
+ {% include navigation.html %}
29
+ </div>
30
+
31
+ <div id=content class=span10>
32
+ {{ content }}
33
+ </div>
34
+ {% else %}
35
+ <div id=content class=span12>
36
+ {{ content }}
37
+ </div>
38
+ {% endif %}
39
+ </div>
40
+
41
+ <div class=row-fluid>
42
+ <div id=footer class=span12>
43
+ {% include footer.html %}
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+ <script>
49
+ function orderNav() {
50
+ var list,
51
+ section,
52
+ header,
53
+ sections = [],
54
+ lists = {},
55
+ headers = {};
56
+
57
+ var navUl = document.querySelectorAll('#navigation ul')[0],
58
+ navLis = document.querySelectorAll('#navigation ul li');
59
+
60
+ if (!navUl) return;
61
+
62
+ for (var i = 0; i < navLis.length; i++) {
63
+ var order, li = navLis[i];
64
+
65
+ if (li.classList.contains('nav-header')) {
66
+ section = li.textContent || li.innerText;
67
+ sections.push(section);
68
+ headers[section] = li;
69
+ continue;
70
+ }
71
+
72
+ if (!lists[section]) {
73
+ lists[section] = [];
74
+ }
75
+
76
+ order = parseFloat(li.getAttribute('data-order'))
77
+ lists[section].push([order, li]);
78
+ }
79
+
80
+ for (var i = 0; i < sections.length; i++) {
81
+ section = sections[i];
82
+ list = lists[section].sort(function(a, b) {
83
+ return a[0] - b[0];
84
+ });
85
+
86
+ if (header = headers[section]) {
87
+ navUl.appendChild(header);
88
+ }
89
+ for (var j = 0; j < list.length; j++) {
90
+ navUl.appendChild(list[j][1]);
91
+ }
92
+ }
93
+ }
94
+
95
+ if (document.querySelectorAll) orderNav();
96
+ </script>
97
+ </body>
98
+ </html>