Skip to content

Instantly share code, notes, and snippets.

View easing's full-sized avatar

Gregory N! easing

View GitHub Profile
@easing
easing / _wikijs-index.md
Last active April 17, 2024 11:00
How to create index of contents in Wiki.js

Wiki.js Index / TOC / Sitemap

This gist shows the way to build the index of contents for Wiki.js instance.

Why this might be needed

With Index you can quickly review informational architecture of your knowledge base, find folders without attached pages, detect missed or inactual/outdated parts, find branches in pages tree which should be rebalanced and so on.

By default all branches rendered expanded but you can collapse some if needed (uncheck checkbox before branch name to do it).

@easing
easing / async-fetcher.js
Created April 4, 2017 13:29
async data middleware
/**
* Express'овский middleware для сбора из разных источников данных,
* необходимых для отображения страниц: навигация, ссылки в подвале и т.п.
* Сам сбор данных описан в модулях в ./sources
*/
const Promise = require('godocker').Promise;
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
@easing
easing / dropdown.html
Last active April 4, 2017 12:40
input field with autocomplete and keyboard navigation
<div class="edu-dropdown">
<div class="edu-dropdown__query">
<div class="edu-dropdown-query"
ng-class="{'is-focused': vm.focused}"
ng-focus="vm.onFocus()"
ng-form="vm.form"
ng-submit="vm.reload()">
<input ng-model="vm.q"
@easing
easing / multiapps.js
Created April 4, 2017 12:36
angular multiapps
/**
* Тут мы снова хачим ангуляр, который по умолчанию не разрешает вкладывать разные приложения друг в друга.
*
* Сначала запускаем корневой модуль на весь документ (в котором наши контролы для формочек и т.п.),
* потом находим все заглушки - элементы с атрибутом `angular-app="appName"` и производим магические пассы руками:
* 1. Создаем пустой <div />,
* 2. копируем в него разметку заглушки,
* 3. инициализируем приложение,
* 4. заменяем внутренности заглушки на запущенное приложение.
* 5. PROFIT!
@easing
easing / action_view_patch.rb
Created November 1, 2016 11:08
Кириллица в id simple_form
# При построении атрибута `:id` для html-тэгов Rails дропает всё кроме латиницы.
# Из-за этого form_for/simple_form не может нормально построить id/for для лейблов и полей ввода,
# если мы отправлем в него не AR-модели, а простые строки (нужно иногда)
# config/initializers/action_view_patch.rb
ActionView::Helpers::Tags::Base.class_eval do
private def sanitized_value(value)
I18n.transliterate(value.to_s).gsub(/\s/, '_').gsub(/[^-\w]/, '_').downcase
end
end
@easing
easing / wc-archive.php
Last active February 7, 2016 05:05
wc-archive.php
<?php
/**
* Исправляем баг WooCommerce с загрузкой неверного шаблона архива
* http://stackoverflow.com/a/25995961
*/
add_filter( 'template_include', 'cotton_wc_include_template_function', 100 );
function cotton_wc_include_template_function( $template_path ) {
@easing
easing / seo-lazy-images.html
Created January 18, 2016 12:08
seo lazy images
<figure>
<img data-src="/images/photo.jpg">
<noscript>
<img src="/images/photo.jpg" alt="">
</noscript>
</figure>
@easing
easing / buttons.html
Last active October 6, 2015 05:33
button html
<div class="btn-group">
<div class="btn btn-default active">Все тикеты</div>
<div class="btn btn-danger">Новые</div>
<div class="btn btn-warning">Открытые</div>
<div class="btn btn-info">В обработке</div>
<div class="btn btn-success">Закрытые</div>
</div>
@easing
easing / edit.blade.php
Created July 29, 2015 15:17
views/users/edit.blade.php
@extends('layouts.master')
@section('content')
<h1>{{ $user->name }}</h1>
{!! form($form) !!}
@endsection
@easing
easing / UsersController.php
Created July 29, 2015 15:17
UsersController
<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Requests;
use Illuminate\Http\Request;
use Kris\LaravelFormBuilder\FormBuilder;
class UsersController extends Controller