Sotaro KARASAWA %!s(int64=10) %!d(string=hai) anos
pai
achega
f7c9c60ed4

+ 16 - 62
gulpfile.js

@@ -9,7 +9,7 @@ var rename = require('gulp-rename');
 var uglify = require('gulp-uglify');
 var uglify = require('gulp-uglify');
 var jshint = require('gulp-jshint');
 var jshint = require('gulp-jshint');
 var source = require('vinyl-source-stream');
 var source = require('vinyl-source-stream');
-var browserify = require('browserify');
+var webpack = require('webpack-stream');
 
 
 var stylish = require('jshint-stylish');
 var stylish = require('jshint-stylish');
 
 
@@ -37,35 +37,12 @@ var css = {
 };
 };
 
 
 var js = {
 var js = {
-  browserify: {
-    crowi: 'resource/js/crowi.js', // => crowi-bundled.js
-    crowiPresentation: 'resource/js/crowi-presentation.js', // => crowi-presentation.js
-  },
-  src: [
-    'node_modules/jquery/dist/jquery.js',
-    'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js',
-    'node_modules/inline-attachment/src/inline-attachment.js',
-    'node_modules/socket.io-client/socket.io.js',
-    'node_modules/jquery.cookie/jquery.cookie.js',
-    'node_modules/diff/dist/diff.js',
-    'resource/thirdparty-js/jquery.selection.js',
-    dirs.jsDist + '/crowi-bundled.js',
-  ],
-  dist: dirs.jsDist + '/crowi.js',
-  revealSrc: [
-    'node_modules/reveal.js/lib/js/head.min.js',
-    'node_modules/reveal.js/lib/js/html5shiv.js',
-    dirs.jsDist + '/crowi-presentation.js',
-  ],
-  revealDist: dirs.jsDist + '/crowi-reveal.js',
-  formSrc: [
-    'resource/js/crowi-form.js'
-  ],
-  formDist: dirs.jsDist + '/crowi-form.js',
-  adminSrc: [
-    'resource/js/crowi-admin.js'
-  ],
-  adminDist: dirs.jsDist + '/crowi-admin.js',
+  src:          dirs.jsSrc + '/app.js',
+  dist:         dirs.jsDist + '/crowi.js',
+  admin:        dirs.jsDist + '/admin.js',
+  form:         dirs.jsDist + '/form.js',
+  presentation: dirs.jsDist + '/presentation.js',
+  app:          dirs.jsDist + '/app.js',
   clientWatch: ['resource/js/**/*.js'],
   clientWatch: ['resource/js/**/*.js'],
   watch: ['test/**/*.test.js', 'app.js', 'lib/**/*.js'],
   watch: ['test/**/*.test.js', 'app.js', 'lib/**/*.js'],
   lint: ['app.js', 'lib/**/*.js'],
   lint: ['app.js', 'lib/**/*.js'],
@@ -78,48 +55,25 @@ var cssIncludePaths = [
   'node_modules/reveal.js/css'
   'node_modules/reveal.js/css'
 ];
 ];
 
 
-gulp.task('js:browserify', function() {
-  browserify({entries: js.browserify.crowiPresentation})
-    .bundle()
-    .pipe(source('crowi-presentation.js'))
-    .pipe(gulp.dest(dirs.jsDist));
-
-  return browserify({entries: js.browserify.crowi})
-    .bundle()
-    .pipe(source('crowi-bundled.js'))
-    .pipe(gulp.dest(dirs.jsDist));
-});
-
-gulp.task('js:concat', ['js:browserify'], function() {
-  gulp.src(js.revealSrc)
-    .pipe(concat('crowi-reveal.js'))
-    .pipe(gulp.dest(dirs.jsDist));
-
-  gulp.src(js.adminSrc)
-    .pipe(concat('crowi-admin.js'))
-    .pipe(gulp.dest(dirs.jsDist));
-
-  gulp.src(js.formSrc)
-    .pipe(concat('crowi-form.js'))
-    .pipe(gulp.dest(dirs.jsDist));
-
+// move task for css and js to webpack over time.
+gulp.task('webpack', function() {
   return gulp.src(js.src)
   return gulp.src(js.src)
-    .pipe(concat('crowi.js'))
+    .pipe(webpack(require('./webpack.config.js')))
     .pipe(gulp.dest(dirs.jsDist));
     .pipe(gulp.dest(dirs.jsDist));
 });
 });
 
 
-gulp.task('js:min', ['js:concat'], function() {
-  gulp.src(js.revealDist)
+gulp.task('js:min', ['webpack'], function() {
+  gulp.src(js.presentation)
     .pipe(uglify())
     .pipe(uglify())
     .pipe(rename({suffix: '.min'}))
     .pipe(rename({suffix: '.min'}))
     .pipe(gulp.dest(dirs.jsDist));
     .pipe(gulp.dest(dirs.jsDist));
 
 
-  gulp.src(js.formDist)
+  gulp.src(js.form)
     .pipe(uglify())
     .pipe(uglify())
     .pipe(rename({suffix: '.min'}))
     .pipe(rename({suffix: '.min'}))
     .pipe(gulp.dest(dirs.jsDist));
     .pipe(gulp.dest(dirs.jsDist));
 
 
-  gulp.src(js.adminDist)
+  gulp.src(js.admin)
     .pipe(uglify())
     .pipe(uglify())
     .pipe(rename({suffix: '.min'}))
     .pipe(rename({suffix: '.min'}))
     .pipe(gulp.dest(dirs.jsDist));
     .pipe(gulp.dest(dirs.jsDist));
@@ -189,7 +143,7 @@ gulp.task('watch', function() {
 
 
   var cssWatcher = gulp.watch(css.watch, ['css:concat']);
   var cssWatcher = gulp.watch(css.watch, ['css:concat']);
   cssWatcher.on('change', watchLogger);
   cssWatcher.on('change', watchLogger);
-  var jsWatcher = gulp.watch(js.clientWatch, ['js:concat']);
+  var jsWatcher = gulp.watch(js.clientWatch, ['webpack']);
   jsWatcher.on('change', watchLogger);
   jsWatcher.on('change', watchLogger);
   var testWatcher = gulp.watch(js.watch, ['test']);
   var testWatcher = gulp.watch(js.watch, ['test']);
   testWatcher.on('change', watchLogger);
   testWatcher.on('change', watchLogger);
@@ -197,4 +151,4 @@ gulp.task('watch', function() {
 
 
 gulp.task('css', ['css:sass', 'css:concat',]);
 gulp.task('css', ['css:sass', 'css:concat',]);
 gulp.task('default', ['css:min', 'js:min',]);
 gulp.task('default', ['css:min', 'js:min',]);
-gulp.task('dev', ['css:concat', 'js:concat','jshint', 'test']);
+gulp.task('dev', ['css:concat', 'webpack', 'jshint', 'test']);

+ 1 - 1
lib/views/_form.html

@@ -59,5 +59,5 @@
   </div>
   </div>
   <div class="file-module hidden">
   <div class="file-module hidden">
   </div>
   </div>
-  <script src="/js/crowi-form{% if env  == 'production' %}.min{% endif %}.js"></script>
 </div>
 </div>
+<script src="/js/form{% if env  == 'production' %}.min{% endif %}.js"></script>

+ 1 - 2
lib/views/admin/users.html

@@ -57,7 +57,7 @@
 
 
       {% set createdUser = req.flash('createdUser') %}
       {% set createdUser = req.flash('createdUser') %}
       {% if createdUser.length %}
       {% if createdUser.length %}
-      <div class="modal fade in" id="createdUserModal">
+      <div class="modal modal-open" id="createdUserModal">
         <div class="modal-dialog">
         <div class="modal-dialog">
           <div class="modal-content">
           <div class="modal-content">
 
 
@@ -78,7 +78,6 @@
           </div><!-- /.modal-content -->
           </div><!-- /.modal-content -->
         </div><!-- /.modal-dialog -->
         </div><!-- /.modal-dialog -->
       </div><!-- /.modal -->
       </div><!-- /.modal -->
-      <script>$(function() { $('#createdUserModal').modal('show'); });</script>
       {% endif %}
       {% endif %}
 
 
       <h2>ユーザー一覧</h2>
       <h2>ユーザー一覧</h2>

+ 0 - 36
lib/views/layout/2column.html

@@ -54,20 +54,6 @@
         <a href="" id="notif-opener">
         <a href="" id="notif-opener">
           <i class="fa fa-globe"></i> <span class="badge badge-danger">6</span>
           <i class="fa fa-globe"></i> <span class="badge badge-danger">6</span>
         </a>
         </a>
-        <script>
-$('#notif-opener').popover({
-  placement: 'bottom',
-  trigger: 'manual',
-  html: 'true',
-  content: function () {
-    return '<div></div>';
-  }
-});
-$('#notif-opener').click(function(e) {
-  $('#notif-opener').popover('show');
-  return false;
-});
-        </script>
       </li>
       </li>
       #}
       #}
       <li id="login-user">
       <li id="login-user">
@@ -105,21 +91,6 @@ $('#notif-opener').click(function(e) {
 {% block layout_sidebar %}
 {% block layout_sidebar %}
 
 
 <a href="" class=" hidden-xs hidden-sm layout-control" id="toggle-sidebar"><i class="fa fa-chevron-right"></i> <span class="hide-on-affix-top"></span></a>
 <a href="" class=" hidden-xs hidden-sm layout-control" id="toggle-sidebar"><i class="fa fa-chevron-right"></i> <span class="hide-on-affix-top"></span></a>
-<script>
-$(function() {
-  $('#toggle-sidebar').click(function(e) {
-    var $mainContainer = $('.main-container');
-    if ($mainContainer.hasClass('aside-hidden')) {
-      $('.main-container').removeClass('aside-hidden');
-      $.cookie('aside-hidden', 0, { expires: 30, path: '/' });
-    } else {
-      $mainContainer.addClass('aside-hidden');
-      $.cookie('aside-hidden', 1, { expires: 30, path: '/' });
-    }
-    return false;
-  });
-});
-</script>
 <aside class="sidebar col-md-3 hidden-xs hidden-sm hidden-print">
 <aside class="sidebar col-md-3 hidden-xs hidden-sm hidden-print">
 
 
   {% block side_header %}
   {% block side_header %}
@@ -143,13 +114,6 @@ $(function() {
 </aside>
 </aside>
 {% include '../modal/widget_help.html' %}
 {% include '../modal/widget_help.html' %}
 
 
-<script>
-$(function() {
-  if ($.cookie('aside-hidden') == 1) {
-    $('.main-container').addClass('aside-hidden');
-  }
-});
-</script>
 {% endblock %} {# layout_sidebar #}
 {% endblock %} {# layout_sidebar #}
 
 
 {% block layout_main %}
 {% block layout_main %}

+ 1 - 1
lib/views/layout/admin.html

@@ -1,6 +1,6 @@
 {% extends '2column.html' %}
 {% extends '2column.html' %}
 
 
 {% block footer %}
 {% block footer %}
-  <script src="/js/crowi-admin{% if env  == 'production' %}.min{% endif %}.js"></script>
+  <script src="/js/admin{% if env  == 'production' %}.min{% endif %}.js"></script>
 {% endblock footer %}
 {% endblock footer %}
 
 

+ 3 - 3
lib/views/layout/layout.html

@@ -12,13 +12,12 @@
   <meta name="viewport" content="width=device-width,initial-scale=1">
   <meta name="viewport" content="width=device-width,initial-scale=1">
 
 
   <link rel="stylesheet" href="/css/crowi{% if env  == 'production' %}.min{% endif %}.css">
   <link rel="stylesheet" href="/css/crowi{% if env  == 'production' %}.min{% endif %}.css">
-  <script src="/js/crowi{% if env  == 'production' %}.min{% endif %}.js"></script>
   <link href='//fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
   <link href='//fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
 </head>
 </head>
 {% endblock %}
 {% endblock %}
 
 
 {% block html_body %}
 {% block html_body %}
-<body class="crowi main-container {% block html_base_css %}{% endblock %}">
+<body class="crowi main-container {% block html_base_css %}{% endblock %}" data-me="{{ user._id.toString() }}">
 <div id="fb-root"></div>
 <div id="fb-root"></div>
 <script>
 <script>
   window.fbAsyncInit = function() {
   window.fbAsyncInit = function() {
@@ -71,7 +70,7 @@
 {% endblock %} {# layout_sidebar #}
 {% endblock %} {# layout_sidebar #}
 
 
 {% block layout_main %}
 {% block layout_main %}
-<div id="main" class="main col-md-9" ng-controller="WikiPageController">
+<div id="main" class="main col-md-9">
   <article>
   <article>
   {% block content_head %}
   {% block content_head %}
     <header>
     <header>
@@ -109,5 +108,6 @@
 {% endblock %}
 {% endblock %}
 
 
 <script src="/js/app.js"></script>
 <script src="/js/app.js"></script>
+<script src="/js/crowi{% if env  == 'production' %}.min{% endif %}.js"></script>
 </html>
 </html>
 
 

+ 2 - 69
lib/views/login.html

@@ -74,7 +74,7 @@
     </div>
     </div>
 
 
     {% if config.crowi['security:registrationMode'] != 'Closed' %}
     {% if config.crowi['security:registrationMode'] != 'Closed' %}
-    <p class="bottom-text"><a href="#register" onclick="$('#login-dialog').addClass('to-flip'); return false;"><i class="fa fa-pencil"></i> 新規登録はこちら</a></p>
+    <p class="bottom-text"><a href="#register"><i class="fa fa-pencil"></i> 新規登録はこちら</a></p>
     {% endif %}
     {% endif %}
   </div>
   </div>
 
 
@@ -187,7 +187,7 @@
       {% endif %}
       {% endif %}
     </div>
     </div>
 
 
-    <p class="bottom-text"><a href="#login" onclick="$('#login-dialog').removeClass('to-flip'); return false;"><i class="fa fa-sign-out"></i> ログインはこちら</a></p>
+    <p class="bottom-text"><a href="#login"><i class="fa fa-sign-out"></i> ログインはこちら</a></p>
   </div>
   </div>
   {% endif %} {# if registrationMode == Closed #}
   {% endif %} {# if registrationMode == Closed #}
 
 
@@ -201,71 +201,4 @@
 </div>
 </div>
 #}
 #}
 
 
-<script>
-$(function() {
-  $('#btn-login-facebook').click(function(e)
-  {
-    var afterLogin = function(response) {
-      if (response.status !== 'connected') {
-        $('#login-form-errors').html('<p class="alert alert-danger">Facebookでのログインに失敗しました。</p>');
-      } else {
-        location.href = '/login/facebook';
-      }
-    };
-    FB.getLoginStatus(function(response) {
-      if (response.status === 'connected') {
-        afterLogin(response);
-      } else {
-        FB.login(function(response) {
-          afterLogin(response);
-        }, {scope: 'email'});
-      }
-    });
-  });
-
-  $('#register-form input[name="registerForm[username]"]').change(function(e) {
-    var username = $(this).val();
-    $('#input-group-username').removeClass('has-error');
-    $('#help-block-username').html("");
-
-    $.getJSON('/_api/check_username', {username: username}, function(json) {
-      if (!json.valid) {
-        $('#help-block-username').html('<i class="fa fa-warning"></i>このユーザーIDは利用できません。<br>');
-        $('#input-group-username').addClass('has-error');
-      }
-    });
-  });
-
-  $('#btn-register-facebook').click(function(e)
-  {
-    var afterLogin = function(response) {
-      if (response.status !== 'connected') {
-        $('#register-form-errors').html('<p class="alert alert-danger">Facebookでのログインに失敗しました。</p>');
-
-      } else {
-        var authR = response.authResponse;
-        $('#register-form input[name="registerForm[fbId]"]').val(authR.userID);
-        FB.api('/me?fields=name,username,email', function(res) {
-          $('#register-form input[name="registerForm[name]"]').val(res.name);
-          $('#register-form input[name="registerForm[username]"]').val(res.username || '');
-          $('#register-form input[name="registerForm[email]"]').val(res.email);
-
-          $('#register-form .facebook-info').remove();
-          $('#register-form').prepend('<div class="facebook-info"><img src="//graph.facebook.com/' + res.id + '/picture?size=square" width="25"> <i class="fa fa-facebook-square"></i> ' + res.name + 'さんとして登録します</div>');
-        });
-      }
-    };
-    FB.getLoginStatus(function(response) {
-      if (response.status === 'connected') {
-        afterLogin(response);
-      } else {
-        FB.login(function(response) {
-          afterLogin(response);
-        }, {scope: 'email'});
-      }
-    });
-  });
-});
-</script>
-
 {% endblock %}
 {% endblock %}

+ 0 - 36
lib/views/page.html

@@ -157,19 +157,6 @@
   {% endif %}
   {% endif %}
 
 
 <div id="notifPageEdited" class="fk-notif fk-notif-danger"><i class="fa fa-exclamation-triangle"></i> <span class="edited-user"></span>さんがこのページを編集しました。 <a href="javascript:location.reload();"><i class="fa fa-angle-double-right"></i> 最新版を読み込む</a></div>
 <div id="notifPageEdited" class="fk-notif fk-notif-danger"><i class="fa fa-exclamation-triangle"></i> <span class="edited-user"></span>さんがこのページを編集しました。 <a href="javascript:location.reload();"><i class="fa fa-angle-double-right"></i> 最新版を読み込む</a></div>
-<script>
-  $(function() {
-    var me = {{ user|json|safe }};
-    var socket = io();
-    socket.on('page edited', function (data) {
-      if (data.user._id != me._id
-        && data.page.path == {{ page.path|json|safe }}) {
-        $('#notifPageEdited').show();
-        $('#notifPageEdited .edited-user').html(data.user.name);
-      }
-    });
-  });
-</script>
 </div>
 </div>
 
 
 {% block content_main_after %}
 {% block content_main_after %}
@@ -211,27 +198,4 @@
   <div id="presentation-layer" class="fullscreen-layer">
   <div id="presentation-layer" class="fullscreen-layer">
     <div id="presentation-container"></div>
     <div id="presentation-container"></div>
   </div>
   </div>
-  <script>
-    $(function() {
-      var presentaionInitialized = false
-        , $b = $('body');
-
-      $(document).on('click', '.toggle-presentation', function(e) {
-        var $a = $(this);
-
-        e.preventDefault();
-        $b.toggleClass('overlay-on');
-
-        if (!presentaionInitialized) {
-          presentaionInitialized = true;
-
-          $('<iframe />').attr({
-            src: $a.attr('href')
-          }).appendTo($('#presentation-container'));
-        }
-      }).on('click', '.fullscreen-layer', function() {
-        $b.toggleClass('overlay-on');
-      });
-    });
-  </script>
 {% endblock %}
 {% endblock %}

+ 1 - 23
lib/views/page_list.html

@@ -38,8 +38,6 @@
 {% block content_main_before %}
 {% block content_main_before %}
 {% endblock %}
 {% endblock %}
 
 
-<div id="xxx"></div>
-
 <div class="page-list content-main {% if req.body.pageForm %}on-edit{% endif %}"
 <div class="page-list content-main {% if req.body.pageForm %}on-edit{% endif %}"
   id="content-main"
   id="content-main"
   data-path="{{ path }}"
   data-path="{{ path }}"
@@ -81,13 +79,7 @@
     <div class="wiki tab-pane {% if not req.body.pageForm %}active{% endif %}" id="revision-body-content">{{ page.revision.body|nl2br|safe }}</div>
     <div class="wiki tab-pane {% if not req.body.pageForm %}active{% endif %}" id="revision-body-content">{{ page.revision.body|nl2br|safe }}</div>
 
 
     <script type="text/template" id="raw-text-original">{{ page.revision.body }}</script>
     <script type="text/template" id="raw-text-original">{{ page.revision.body }}</script>
-    <script type="text/javascript">
-      $(function(){
-          var renderer = new Crowi.renderer($('#raw-text-original').html());
-          renderer.render();
-          Crowi.correctHeaders('#revision-body-content');
-      });
-    </script>
+
     <div class="tab-pane edit-form portal-form {% if req.body.pageForm %}active{% endif %}" id="edit-form">
     <div class="tab-pane edit-form portal-form {% if req.body.pageForm %}active{% endif %}" id="edit-form">
       {% include '_form.html' with {forceGrant: 1} %}
       {% include '_form.html' with {forceGrant: 1} %}
     </div>
     </div>
@@ -139,20 +131,6 @@
   </div>
   </div>
 </div>
 </div>
 
 
-  <script type="text/javascript">
-    $(function(){
-        $('#view-timeline .timeline-body').each(function()
-        {
-          var id = $(this).attr('id');
-          var contentId = '#' + id + ' > script';
-          var revisionBody = '#' + id + ' .revision-body';
-          var revisionPath = '#' + id + ' .revision-path';
-          var renderer = new Crowi.renderer($(contentId).html(), $(revisionBody));
-          renderer.render();
-        });
-        //$('.tooltip .tabs').tabs();
-    });
-  </script>
 
 
 </div> {# /.content-main #}
 </div> {# /.content-main #}
 {% include 'modal/widget_what_is_portal.html' %}
 {% include 'modal/widget_what_is_portal.html' %}

+ 2 - 2
lib/views/page_presentation.html

@@ -8,7 +8,7 @@
 
 
 
 
     <link rel="stylesheet" type="text/css" href="/css/crowi-reveal{% if env  == 'production' %}.min{% endif %}.css">
     <link rel="stylesheet" type="text/css" href="/css/crowi-reveal{% if env  == 'production' %}.min{% endif %}.css">
-    <link rel="stylesheet" type="text/css" href="/js/reveal.js/lib/css/zenburn.css">
+    <link rel="stylesheet" type="text/css" href="/js/reveal/lib/css/zenburn.css">
 
 
     <title>{{ path|path2name }} | {{ path }}</title>
     <title>{{ path|path2name }} | {{ path }}</title>
   </head>
   </head>
@@ -28,6 +28,6 @@
     </div>
     </div>
 
 
     <script src="/js/crowi{% if env  == 'production' %}.min{% endif %}.js"></script>
     <script src="/js/crowi{% if env  == 'production' %}.min{% endif %}.js"></script>
-    <script src="/js/crowi-reveal{% if env  == 'production' %}.min{% endif %}.js"></script>
+    <script src="/js/presentation{% if env  == 'production' %}.min{% endif %}.js"></script>
   </body>
   </body>
 </html>
 </html>

+ 2 - 2
lib/views/widget/page_side_content.html

@@ -12,7 +12,7 @@
 
 
 <h3><i class="fa fa-comment"></i> Comments</h3>
 <h3><i class="fa fa-comment"></i> Comments</h3>
 <div class="page-comments">
 <div class="page-comments">
-  <form class="form page-comment-form" id="page-comment-form">
+  <form class="form page-comment-form" id="page-comment-form" onsubmit="return false;">
     <div class="comment-form">
     <div class="comment-form">
       <div class="comment-form-main">
       <div class="comment-form-main">
         <div class="comment-write" id="comment-write">
         <div class="comment-write" id="comment-write">
@@ -22,7 +22,7 @@
           <input type="hidden" name="commentForm[page_id]" value="{{ page._id.toString() }}">
           <input type="hidden" name="commentForm[page_id]" value="{{ page._id.toString() }}">
           <input type="hidden" name="commentForm[revision_id]" value="{{ revision._id.toString() }}">
           <input type="hidden" name="commentForm[revision_id]" value="{{ revision._id.toString() }}">
           <span class="text-danger" id="comment-form-message"></span>
           <span class="text-danger" id="comment-form-message"></span>
-          <input type="submit" id="commenf-form-button" value="Comment" class="btn btn-primary btn-sm form-inline">
+          <input type="submit" id="comment-form-button" value="Comment" class="btn btn-primary btn-sm form-inline">
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>

+ 2 - 1
package.json

@@ -92,7 +92,8 @@
     "swig": "~1.4.0",
     "swig": "~1.4.0",
     "time": "~0.11.0",
     "time": "~0.11.0",
     "vinyl-source-stream": "~1.1.0",
     "vinyl-source-stream": "~1.1.0",
-    "webpack": "~1.13.0"
+    "webpack": "~1.13.0",
+    "webpack-stream": "^3.1.0"
   },
   },
   "devDependencies": {
   "devDependencies": {
     "chai": "~1.10.0",
     "chai": "~1.10.0",

+ 0 - 0
public/js/reveal.js → public/js/reveal


+ 6 - 1
resource/js/app.js

@@ -17,4 +17,9 @@ class Crowi extends React.Component {
   }
   }
 }
 }
 
 
-ReactDOM.render(<Hello />, document.getElementById('xxx'));
+var xxx = document.getElementById('xxx');
+if (xxx) {
+  $(function() {
+    ReactDOM.render(<Crowi />, xxx);
+  });
+}

+ 6 - 0
resource/js/components/Header/SearchBox.js

@@ -1,4 +1,10 @@
 import React from 'react';
 import React from 'react';
 
 
 export class SearchBox extends React.Component {
 export class SearchBox extends React.Component {
+
+  render() {
+    return (
+      <h1>Hello</h1>
+    );
+  }
 }
 }

+ 5 - 2
resource/js/crowi-form.js

@@ -2,6 +2,10 @@ $(function() {
   var pageId = $('#content-main').data('page-id');
   var pageId = $('#content-main').data('page-id');
   var pagePath= $('#content-main').data('path');
   var pagePath= $('#content-main').data('path');
 
 
+  require('inline-attachment/src/inline-attachment');
+  require('jquery.selection');
+  require('bootstrap-sass');
+
   // show/hide
   // show/hide
   function FetchPagesUpdatePostAndInsert(path) {
   function FetchPagesUpdatePostAndInsert(path) {
     $.get('/_api/pages.updatePost', {path: path}, function(res) {
     $.get('/_api/pages.updatePost', {path: path}, function(res) {
@@ -22,6 +26,7 @@ $(function() {
   }
   }
 
 
   $('a[data-toggle="tab"][href="#edit-form"]').on('show.bs.tab', function() {
   $('a[data-toggle="tab"][href="#edit-form"]').on('show.bs.tab', function() {
+    console.log('Event fiered');
     $('.content-main').addClass('on-edit');
     $('.content-main').addClass('on-edit');
 
 
     if (slackConfigured) {
     if (slackConfigured) {
@@ -39,8 +44,6 @@ $(function() {
     $('.content-main').removeClass('on-edit');
     $('.content-main').removeClass('on-edit');
   });
   });
 
 
-  $('[data-toggle="popover"]').popover();
-
   // preview watch
   // preview watch
   var originalContent = $('#form-body').val();
   var originalContent = $('#form-body').val();
   var prevContent = "";
   var prevContent = "";

+ 9 - 6
resource/js/crowi-presentation.js

@@ -1,5 +1,8 @@
 var Reveal = require('reveal.js');
 var Reveal = require('reveal.js');
 
 
+require('reveal.js/lib/js/head.min.js');
+require('reveal.js/lib/js/html5shiv.js');
+
 if (!window) {
 if (!window) {
   window = {};
   window = {};
 }
 }
@@ -14,12 +17,12 @@ Reveal.initialize({
 
 
   // Optional libraries used to extend on reveal.js
   // Optional libraries used to extend on reveal.js
   dependencies: [
   dependencies: [
-    { src: '/js/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
-    { src: '/js/reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
-    { src: '/js/reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
-    { src: '/js/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
-    { src: '/js/reveal.js/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
-    { src: '/js/reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
+    { src: '/js/reveal/lib/js/classList.js', condition: function() { return !document.body.classList; } },
+    { src: '/js/reveal/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
+    { src: '/js/reveal/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
+    { src: '/js/reveal/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
+    { src: '/js/reveal/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
+    { src: '/js/reveal/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
   ]
   ]
 });
 });
 
 

+ 153 - 18
resource/js/crowi.js

@@ -1,11 +1,15 @@
 /* jshint browser: true, jquery: true */
 /* jshint browser: true, jquery: true */
-/* global FB, marked */
 /* Author: Sotaro KARASAWA <sotarok@crocos.co.jp>
 /* Author: Sotaro KARASAWA <sotarok@crocos.co.jp>
 */
 */
 
 
 var hljs = require('highlight.js');
 var hljs = require('highlight.js');
 var jsdiff = require('diff');
 var jsdiff = require('diff');
 var marked = require('marked');
 var marked = require('marked');
+var io = require('socket.io-client');
+
+require('bootstrap-sass');
+require('jquery.cookie');
+
 var Crowi = {};
 var Crowi = {};
 
 
 if (!window) {
 if (!window) {
@@ -219,21 +223,21 @@ Crowi.userPicture = function (user) {
 };
 };
 
 
 
 
-CrowiSearcher = function(path, $el) {
-  this.$el = $el;
-  this.path = path;
-  this.searchResult = {};
-};
-CrowiSearcher.prototype.querySearch = function(keyword, option) {
-};
-CrowiSearcher.prototype.search = function(keyword) {
-  var option = {};
-  this.querySearch(keyword, option);
-  this.$el.html(this.render());
-};
-CrowiSearcher.prototype.render = function() {
-  return $('<div>');
-};
+//CrowiSearcher = function(path, $el) {
+//  this.$el = $el;
+//  this.path = path;
+//  this.searchResult = {};
+//};
+//CrowiSearcher.prototype.querySearch = function(keyword, option) {
+//};
+//CrowiSearcher.prototype.search = function(keyword) {
+//  var option = {};
+//  this.querySearch(keyword, option);
+//  this.$el.html(this.render());
+//};
+//CrowiSearcher.prototype.render = function() {
+//  return $('<div>');
+//};
 
 
 
 
 $(function() {
 $(function() {
@@ -246,9 +250,25 @@ $(function() {
 
 
   Crowi.linkPath();
   Crowi.linkPath();
 
 
+  $('[data-toggle="popover"]').popover();
   $('[data-toggle="tooltip"]').tooltip();
   $('[data-toggle="tooltip"]').tooltip();
   $('[data-tooltip-stay]').tooltip('show');
   $('[data-tooltip-stay]').tooltip('show');
 
 
+  $('#toggle-sidebar').click(function(e) {
+    var $mainContainer = $('.main-container');
+    if ($mainContainer.hasClass('aside-hidden')) {
+      $('.main-container').removeClass('aside-hidden');
+      $.cookie('aside-hidden', 0, { expires: 30, path: '/' });
+    } else {
+      $mainContainer.addClass('aside-hidden');
+      $.cookie('aside-hidden', 1, { expires: 30, path: '/' });
+    }
+    return false;
+  });
+
+  if ($.cookie('aside-hidden') == 1) {
+    $('.main-container').addClass('aside-hidden');
+  }
 
 
   $('.copy-link').on('click', function () {
   $('.copy-link').on('click', function () {
     $(this).select();
     $(this).select();
@@ -330,6 +350,88 @@ $(function() {
     $link.html(path.replace(new RegExp(shortPath + '(/)?$'), '<strong>' + shortPath + '$1</strong>'));
     $link.html(path.replace(new RegExp(shortPath + '(/)?$'), '<strong>' + shortPath + '$1</strong>'));
   });
   });
 
 
+  // for list page
+  $('#view-timeline .timeline-body').each(function()
+  {
+    var id = $(this).attr('id');
+    var contentId = '#' + id + ' > script';
+    var revisionBody = '#' + id + ' .revision-body';
+    var revisionPath = '#' + id + ' .revision-path';
+    var renderer = new Crowi.renderer($(contentId).html(), $(revisionBody));
+    renderer.render();
+  });
+
+  // login
+  $('#register').on('click', function() {
+    $('#login-dialog').addClass('to-flip');
+    return false;
+  });
+  $('#login').on('click', function() {
+    $('#login-dialog').removeClass('to-flip');
+    return false;
+  });
+  $('#btn-login-facebook').click(function(e)
+  {
+    var afterLogin = function(response) {
+      if (response.status !== 'connected') {
+        $('#login-form-errors').html('<p class="alert alert-danger">Facebookでのログインに失敗しました。</p>');
+      } else {
+        location.href = '/login/facebook';
+      }
+    };
+    FB.getLoginStatus(function(response) {
+      if (response.status === 'connected') {
+        afterLogin(response);
+      } else {
+        FB.login(function(response) {
+          afterLogin(response);
+        }, {scope: 'email'});
+      }
+    });
+  });
+
+  $('#register-form input[name="registerForm[username]"]').change(function(e) {
+    var username = $(this).val();
+    $('#input-group-username').removeClass('has-error');
+    $('#help-block-username').html("");
+
+    $.getJSON('/_api/check_username', {username: username}, function(json) {
+      if (!json.valid) {
+        $('#help-block-username').html('<i class="fa fa-warning"></i>このユーザーIDは利用できません。<br>');
+        $('#input-group-username').addClass('has-error');
+      }
+    });
+  });
+
+  $('#btn-register-facebook').click(function(e)
+  {
+    var afterLogin = function(response) {
+      if (response.status !== 'connected') {
+        $('#register-form-errors').html('<p class="alert alert-danger">Facebookでのログインに失敗しました。</p>');
+
+      } else {
+        var authR = response.authResponse;
+        $('#register-form input[name="registerForm[fbId]"]').val(authR.userID);
+        FB.api('/me?fields=name,username,email', function(res) {
+          $('#register-form input[name="registerForm[name]"]').val(res.name);
+          $('#register-form input[name="registerForm[username]"]').val(res.username || '');
+          $('#register-form input[name="registerForm[email]"]').val(res.email);
+
+          $('#register-form .facebook-info').remove();
+          $('#register-form').prepend('<div class="facebook-info"><img src="//graph.facebook.com/' + res.id + '/picture?size=square" width="25"> <i class="fa fa-facebook-square"></i> ' + res.name + 'さんとして登録します</div>');
+        });
+      }
+    };
+    FB.getLoginStatus(function(response) {
+      if (response.status === 'connected') {
+        afterLogin(response);
+      } else {
+        FB.login(function(response) {
+          afterLogin(response);
+        }, {scope: 'email'});
+      }
+    });
+  });
 
 
   if (pageId) {
   if (pageId) {
 
 
@@ -444,7 +546,7 @@ $(function() {
 
 
     // post comment event
     // post comment event
     $('#page-comment-form').on('submit', function() {
     $('#page-comment-form').on('submit', function() {
-      $button = $('#commenf-form-button');
+      var $button = $('#comment-form-button');
       $button.attr('disabled', 'disabled');
       $button.attr('disabled', 'disabled');
       $.post('/_api/comments.add', $(this).serialize(), function(data) {
       $.post('/_api/comments.add', $(this).serialize(), function(data) {
         $button.removeAttr('disabled');
         $button.removeAttr('disabled');
@@ -693,7 +795,40 @@ $(function() {
         $(diffView).click();
         $(diffView).click();
       }
       }
     });
     });
-  }
+
+    // presentation
+    var presentaionInitialized = false
+      , $b = $('body');
+
+    $(document).on('click', '.toggle-presentation', function(e) {
+      var $a = $(this);
+
+      e.preventDefault();
+      $b.toggleClass('overlay-on');
+
+      if (!presentaionInitialized) {
+        presentaionInitialized = true;
+
+        $('<iframe />').attr({
+          src: $a.attr('href')
+        }).appendTo($('#presentation-container'));
+      }
+    }).on('click', '.fullscreen-layer', function() {
+      $b.toggleClass('overlay-on');
+    });
+
+    //
+    var me = $('body').data('me');
+    var socket = io();
+    socket.on('page edited', function (data) {
+      if (data.user._id != me
+        && data.page.path == pagePath) {
+        $('#notifPageEdited').show();
+        $('#notifPageEdited .edited-user').html(data.user.name);
+      }
+    });
+  } // end if pageId
 
 
   // for search
   // for search
+  //
 });
 });

+ 8 - 3
webpack.config.js

@@ -4,6 +4,10 @@ var webpack = require('webpack');
 module.exports = {
 module.exports = {
   entry: {
   entry: {
     app: './resource/js/app.js',
     app: './resource/js/app.js',
+    crowi: './resource/js/crowi.js',
+    presentation: './resource/js/crowi-presentation.js',
+    form: './resource/js/crowi-form.js',
+    admin: './resource/js/crowi-admin.js',
   },
   },
   output: {
   output: {
     path: path.join(__dirname + "/public/js"),
     path: path.join(__dirname + "/public/js"),
@@ -11,7 +15,7 @@ module.exports = {
   },
   },
   resolve: {
   resolve: {
     modulesDirectories: [
     modulesDirectories: [
-      './node_modules',
+      './node_modules', './resource/thirdparty-js',
     ],
     ],
   },
   },
   module: {
   module: {
@@ -30,7 +34,8 @@ module.exports = {
     new webpack.ProvidePlugin({
     new webpack.ProvidePlugin({
       jQuery: "jquery",
       jQuery: "jquery",
       $: "jquery",
       $: "jquery",
-      jquery: "jquery"
-    })
+      jqeury: "jquery",
+    }),
+    //new webpack.optimize.DedupePlugin(),
   ]
   ]
 };
 };