• Stars
    star
    264
  • Rank 155,103 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

skeleton generation tool

awesome-skeleton

NPM version Build status Dependency status

Skeleton generation tool

English | 简体中文

Contributors


zivyangll

Effect preview

View online effects: Kaola cart:

kaola skeleton

Description

  • skeleton generation component, only for the node side. This component provides two capabilities for skeleton generation and skeleton template injection.
  • Skeletal diagram generation logic: Open the page address by using the Puppeteer headless browser by passing in the page address, perform gray background processing on the first screen image and text of the page, and then take a screenshot of the first screen of the page to generate a compressed base64 png image.

Installation

Global installation

$ npm i awesome-skeleton -g

Installation in the project

$ npm i awesome-skeleton -D

Instructions

Adding a configuration file

skeleton.config.json:

{
  "pageName": "baidu",
  "pageUrl": "https://www.baidu.com",
  "openRepeatList": false,
  "device": "iPhone X",
  "minGrayBlockWidth": 80,
  "minGrayPseudoWidth": 10,
  "debug": true,
  "debugTime": 3000,
  "cookies": [
    {
      "domain": ".baidu.com",
      "expirationDate": 1568267131.555328,
      "hostOnly": false,
      "httpOnly": false,
      "name": "BDORZ",
      "path": "/",
      "sameSite": "unspecified",
      "secure": false,
      "session": false,
      "storeId": "0",
      "value": "yyyyyyyyy",
      "id": 2
    }
  ]
}

Globally generated skeleton

$ skeleton -c ./skeleton.config.json

After the page DomReady, a red button appears at the top of the page: Start generating the skeleton screen.

After the build is complete, a skeleton-output file is generated in the run directory, which includes the skeleton screen png image, base64 text, and html file:

  • base64-baidu.png # skeleton picture
  • base64-baidu.txt # skeleton diagram Base64 encoding
  • base64-baidu.html # Final HTML generationL

The html file can be used directly, copy the following location:

<html>
  <head>
    <!--- skeleton html code -->
  </head>
</html>

note:

  • The skeleton is destroyed by default after onload event.
  • Manual destruction method:
window.SKELETON && SKELETON.destroy();

Of course, you can also use the generated Base64 image directly in your project

Creating a skeleton screen in the project

Add a script to package.json :

"scripts": {
   "skeleton": "skeleton -c ./skeleton.config.json"
}

Generate skeleton screen::

$ npm run skeleton

Solve the login status

If the page requires a login, you'll need to download the Chrome plugin [EditThisCookie] (https://chrome.google.com/webstore/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg) to copy the cookie into the configuration parameters.

Parameters

Parameter Name Required Default Description
pageUrl Yes - Page address (this address must be accessible)
pageName no output page name (English only)
cookies no page cookies to resolve login status issues
OutputPath no skeleton-output skeleton file output folder path, default to project skeleton-output
openRepeatList no true by default will copy the first item of each list
device no empty for PC reference puppeteer/DeviceDescriptors.js, can be set to 'iPhone 6 Plus'
debug no false turn on debug switch
debugTime No 0 Time in the debug mode, the page stays in the skeleton
minGrayBlockWidth No 0 Minimum processing width of gray blocks
minGrayPseudoWidth No 0 Minimum processing pseudo-class width

dom node attribute

This is the main point of obtaining a high-quality skeleton. By setting the following dom node attributes, some nodes are removed, ignored, and specified in the skeleton to remove the interference of redundant nodes, thus making the skeleton effect Get the best.

Parameter Name Description
data-skeleton-remove Specifies the dom node properties to remove
data-skeleton-bgcolor Specify the background color added in a dom node
data-skeleton-ignore Specifies to ignore dom node properties without any processing
data-skeleton-empty Set a dom's innerHTML to an empty string

Example:

<div data-skeleton-remove><span>abc</span></div>
<div data-skeleton-bgcolor="#EE00EE"><span>abc</span></div>
<div data-skeleton-ignore><span>abc</span></div>
<div data-skeleton-empty><span>abc</span></div>

development

Installation dependencies

$ git clone [email protected]:kaola-fed/awesome-skeleton.git
$ cd awesome-skeleton && npm i

Running the project

Since the code that generates the skeleton is inserted through dynamic scripts, the code in src/script needs to be packaged into src/script/dist/index.js by Rollup.

$ npm run dev

Modify the configuration in demo/index.js to generate a skeleton of the different pages:

$ cd demo
$ node index.js

Thanks

More Repositories

1

megalo

基于 Vue 的小程序开发框架
JavaScript
1,634
star
2

blog

kaola blog
JavaScript
722
star
3

megalo-demo

megalo-demo
Vue
104
star
4

foxman

🍥 an extensible mock server
JavaScript
81
star
5

octoparse

octoparse是一款html解析转换工具。可以将html解析成对象并转换成其他文本。支持html转微信小程序、支付宝小程序与百度小程序。
JavaScript
45
star
6

nek-ui

UI components based on RegularJS
JavaScript
44
star
7

mpregular

基于 RegularJS 实现的小程序开发框架
JavaScript
42
star
8

RDE

一种基于Docker的前端生态集成解决方案
TypeScript
28
star
9

freemarker

Freemarker integration for NodeJS
HTML
26
star
10

dubbo.js

TypeScript
23
star
11

console-agent

console 平台是完整的 node 监控平台,由 agent + connection + cron + web 组成。agent 是其中的 「采集/上报」模块。其余部分暂未开源
JavaScript
10
star
12

megalo-aot

JavaScript
9
star
13

kagent

Probes for Node.js monitor
JavaScript
7
star
14

rds-vue

rde组件库,包含Components、Mixins、Directives、Filters、Utils
JavaScript
6
star
15

nejc

Convert nej module style to CommonJs module style
JavaScript
6
star
16

antd-theme-kaola

Ant design theme for Kaola
JavaScript
6
star
17

dionysus

Snippets of nek-ui && kmui which support for VSCode & Atom & Sumlime Text
JavaScript
5
star
18

element-style

Custom styles for ElementUI
CSS
4
star
19

mpregular-loader

JavaScript
4
star
20

eslint-config-kaola

ESLint rules for Kaola
JavaScript
4
star
21

zookeeper-querier

JavaScript
4
star
22

jMockr

Mock server for front end develop
CSS
3
star
23

NEK

Nice easy Kaola project toolkit
JavaScript
3
star
24

regular-analysis

3
star
25

template-vue-ui

template for vue-ui
JavaScript
3
star
26

mpregular-template-compiler

JavaScript
3
star
27

nej.js

cjs version for nej
JavaScript
3
star
28

template-vue-spa

template-vue-spa
JavaScript
3
star
29

git-jira-cli

JavaScript
2
star
30

egg-console-agent

console-agent for Egg
JavaScript
2
star
31

megalo-examples

megalo-examples
JavaScript
2
star
32

apollo

atom package for nek-ui && kmui
JavaScript
2
star
33

react-category-select

React component for category select
JavaScript
2
star
34

parse-nej-logs

JavaScript
1
star
35

regular-doc

[unofficial] Documents for RegularJS
CSS
1
star
36

nek-server

Server for NEK
JavaScript
1
star
37

css3Animation

animation effeacts by pure css
CSS
1
star
38

eslint-plugin-kaola

JavaScript
1
star
39

ci-runner

A simple CI runner based on Docker
JavaScript
1
star
40

rdc-nut

JavaScript
1
star
41

vue-cli-preset-megalo

vue-clie@3 preset for megalo
JavaScript
1
star
42

url-shortener-extension

Chrome Extension for URL Shortener
JavaScript
1
star
43

url-shortener

URL Shortener
HTML
1
star
44

kaola-ui

⬡ [ work in progress ] kaola mobile ui toolkit for consistent user experience and rapid prototyping
JavaScript
1
star