mirror of https://github.com/IoTcat/sakura2.git
parent
ff9a63f593
commit
5fbfc541c7
13 changed files with 480 additions and 203 deletions
@ -1,24 +1,29 @@ |
||||
<div id="comments" class="comments"> |
||||
<?php if ( post_password_required() ) : ?> |
||||
<p><?php esc_html_e( 'Post is password protected. Enter the password to view any comments.', 'html5blank' ); ?></p>
|
||||
<?php if (post_password_required()): ?> |
||||
<p><?php esc_html_e('Post is password protected. Enter the password to view any comments.', 'html5blank');?></p>
|
||||
</div> |
||||
|
||||
<?php return; endif; ?> |
||||
<?php return;endif;?> |
||||
|
||||
<?php if ( have_comments() ) : ?> |
||||
<?php if (have_comments()): ?> |
||||
|
||||
<h2><?php comments_number(); ?></h2>
|
||||
<h2><?php comments_number();?></h2>
|
||||
|
||||
<ul> |
||||
<?php wp_list_comments( 'type=comment&callback=html5blankcomments' ); // Custom callback in functions.php. ?>
|
||||
</ul> |
||||
<!-- TODO: also generate a copy in php side for SEO --> |
||||
<ul id="comment-list-ul" class="comment-list"></ul> |
||||
|
||||
<?php elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) : ?> |
||||
<template id="comment-list-li-template"> |
||||
<li> |
||||
<img class="avatar"> |
||||
<div class="name"></div> |
||||
<div class="content"><div> |
||||
</li> |
||||
</template> |
||||
|
||||
<p><?php esc_html_e( 'Comments are closed here.', 'html5blank' ); ?></p>
|
||||
<?php elseif (!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')): ?> |
||||
|
||||
<?php endif; ?> |
||||
<p><?php esc_html_e('Comments are closed here.', 'sakura');?></p>
|
||||
|
||||
<?php comment_form(); ?> |
||||
<?php endif;?> |
||||
|
||||
</div> |
||||
|
@ -0,0 +1,237 @@ |
||||
import { getPostCommentByPostId } from '../utils/graphql' |
||||
import ApolloClient from 'apollo-boost' |
||||
|
||||
const getCommentData = function (callback: Function) { |
||||
const theCommentQuery: getPostCommentByPostId = new getPostCommentByPostId(1, 5) |
||||
const client: ApolloClient = new ApolloClient() |
||||
client.query(theCommentQuery.query) |
||||
.then(data => callback(data)) |
||||
.catch(error => console.log(error)) |
||||
} |
||||
|
||||
const pushNewCommentItem = function (data: object) { |
||||
let li = document.querySelector('#comment-list-li-template'), |
||||
ul = document.querySelector('#comment-list-ul') |
||||
|
||||
li.content.querySelector('.name').textContent = data.name |
||||
li.content.querySelector('.content').innerHTML = data.content.trim() |
||||
|
||||
let clone = document.importNode(li.content, true) |
||||
ul.appendChild(clone) |
||||
} |
||||
|
||||
const getCommentDataCallback = function (data: object) { |
||||
//single item data
|
||||
interface CommentItem { |
||||
name: string, |
||||
content: string |
||||
} |
||||
|
||||
for (let edge: object in data.data.postBy.comments.edges) { |
||||
let node: object = data.data.postBy.comments.edges[edge].node |
||||
let stata: CommentItem = { |
||||
name: node.author.name, |
||||
content: node.content |
||||
} |
||||
pushNewCommentItem(stata) |
||||
} |
||||
} |
||||
|
||||
const main = async function () { |
||||
getCommentData(getCommentDataCallback) |
||||
// dev(getCommentDataCallback)
|
||||
} |
||||
|
||||
export default main |
||||
|
||||
const dev = function (callback: Function) { |
||||
const data: object = { |
||||
"data": { |
||||
"postBy": { |
||||
"id": "cG9zdDox", |
||||
"postId": 1, |
||||
"comments": { |
||||
"edges": [{ |
||||
"node": { |
||||
"date": "2019-12-05 15:15:21", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>dsgssdg<\/p>\n", |
||||
"commentId": 20, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [{ |
||||
"date": "2019-12-05 15:30:27", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>re:fsadgfbad<\/p>\n", |
||||
"commentId": 24, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}, { |
||||
"date": "2019-12-05 15:30:19", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>re:24325<\/p>\n", |
||||
"commentId": 23, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}, { |
||||
"date": "2019-12-05 15:29:56", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>reply233<\/p>\n", |
||||
"commentId": 21, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [{ |
||||
"date": "2019-12-05 15:30:09", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>re:re:2333<\/p>\n", |
||||
"commentId": 22, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}, |
||||
"__typename": "PostToCommentConnectionEdge" |
||||
}, { |
||||
"node": { |
||||
"date": "2019-12-05 15:15:18", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>asfadsfgasg<\/p>\n", |
||||
"commentId": 19, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}, |
||||
"__typename": "PostToCommentConnectionEdge" |
||||
}, { |
||||
"node": { |
||||
"date": "2019-12-05 15:15:15", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>asfasfas<\/p>\n", |
||||
"commentId": 18, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}, |
||||
"__typename": "PostToCommentConnectionEdge" |
||||
}, { |
||||
"node": { |
||||
"date": "2019-12-05 15:15:12", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>safassfs<\/p>\n", |
||||
"commentId": 17, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}, |
||||
"__typename": "PostToCommentConnectionEdge" |
||||
}, { |
||||
"node": { |
||||
"date": "2019-12-05 15:15:08", |
||||
"agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/78.0.3904.108 Safari\/537.36", |
||||
"content": "<p>adfasf<\/p>\n", |
||||
"commentId": 16, |
||||
"author": { |
||||
"email": "adadam@qq.com", |
||||
"name": "mashiro", |
||||
"url": null, |
||||
"__typename": "User" |
||||
}, |
||||
"authorIp": "101.87.249.108", |
||||
"__typename": "Comment", |
||||
"children": { |
||||
"nodes": [], |
||||
"__typename": "CommentToCommentConnection" |
||||
} |
||||
}, |
||||
"__typename": "PostToCommentConnectionEdge" |
||||
}], |
||||
"pageInfo": { |
||||
"endCursor": "YXJyYXljb25uZWN0aW9uOjE2", |
||||
"hasNextPage": true, |
||||
"hasPreviousPage": false, |
||||
"startCursor": "YXJyYXljb25uZWN0aW9uOjIw", |
||||
"__typename": "WPPageInfo" |
||||
}, |
||||
"__typename": "PostToCommentConnection" |
||||
}, |
||||
"__typename": "Post" |
||||
} |
||||
} |
||||
} |
||||
callback(data) |
||||
} |
@ -1,13 +1,8 @@ |
||||
import { getPostCommentByPostId } from '../utils/graphql' |
||||
import commentBoxInit from './commentbox' |
||||
|
||||
/** |
||||
* Site top bar handler when page scroll |
||||
*/ |
||||
export default function () { |
||||
export default async function () { |
||||
if (!document.querySelector('article').classList.contains('markdown')) { |
||||
return |
||||
} |
||||
let theComment = new getPostCommentByPostId(1, 5) |
||||
console.log(theComment.query()) |
||||
console.log('test') |
||||
commentBoxInit() |
||||
} |
@ -0,0 +1,139 @@ |
||||
const path = require('path'); |
||||
const autoprefixer = require('autoprefixer'); |
||||
const TerserPlugin = require('terser-webpack-plugin'); |
||||
const CopyPlugin = require('copy-webpack-plugin'); |
||||
const RemovePlugin = require('remove-files-webpack-plugin'); |
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
||||
const Chunks2JsonPlugin = require('chunks-2-json-webpack-plugin'); |
||||
|
||||
// const OutputPath = process.env.ENV_MODE
|
||||
|
||||
module.exports = [{ |
||||
mode: "development", // "production" | "development" | "none"
|
||||
entry: { |
||||
main: ['./src/ts/index.ts', './src/scss/index.scss'] |
||||
}, |
||||
output: { |
||||
path: path.resolve(__dirname, './dist'), |
||||
filename: './js/bundle_[hash].js' |
||||
}, |
||||
devtool: 'inline-source-map', |
||||
devServer: { |
||||
contentBase: path.join(__dirname, './dist'), |
||||
publicPath: '/', |
||||
port: 8080, |
||||
host: '0.0.0.0', |
||||
compress: true, |
||||
}, |
||||
watchOptions: { |
||||
aggregateTimeout: 300, |
||||
ignored: /node_modules/ |
||||
}, |
||||
module: { |
||||
rules: [{ |
||||
test: /\.(png|jpg|gif|svg)$/, |
||||
exclude: [ |
||||
path.resolve(__dirname, './node_modules'), |
||||
], |
||||
use: { |
||||
loader: 'file-loader', |
||||
options: { |
||||
name: '../images/[hash].[ext]' |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
test: /\.scss$/, |
||||
use: [{ |
||||
loader: MiniCssExtractPlugin.loader |
||||
}, |
||||
{ |
||||
loader: 'css-loader' |
||||
}, |
||||
{ |
||||
loader: 'postcss-loader', |
||||
options: { |
||||
plugins: () => [autoprefixer()] |
||||
} |
||||
}, |
||||
{ |
||||
loader: 'sass-loader', |
||||
options: { |
||||
sourceMap: true, |
||||
sassOptions: { |
||||
includePaths: ['./node_modules'] |
||||
}, |
||||
} |
||||
}, |
||||
] |
||||
}, |
||||
{ |
||||
test: /\.tsx?$/, |
||||
use: [{ |
||||
loader: 'babel-loader', |
||||
query: { |
||||
presets: ['@babel/preset-typescript'], |
||||
}, |
||||
}], |
||||
exclude: /node_modules/ |
||||
}, |
||||
{ |
||||
test: /\.(graphql|gql)$/, |
||||
exclude: /node_modules/, |
||||
loader: 'graphql-tag/loader' |
||||
} |
||||
] |
||||
}, |
||||
resolve: { |
||||
extensions: ['.tsx', '.ts', '.js'] |
||||
}, |
||||
// optimization: {
|
||||
// minimize: true,
|
||||
// minimizer: [new TerserPlugin({
|
||||
// sourceMap: false,
|
||||
// })],
|
||||
// },
|
||||
plugins: [ |
||||
new CopyPlugin([{ |
||||
from: './src/package.scss', |
||||
to: './style.css', |
||||
toType: 'file', |
||||
}, |
||||
{ |
||||
from: './src/screenshot.png', |
||||
to: './screenshot.png', |
||||
toType: 'file', |
||||
}, |
||||
{ |
||||
from: './src/images/', |
||||
to: './images/[hash].[ext]', |
||||
toType: 'template', |
||||
}, |
||||
{ |
||||
from: './src/php/*.php', |
||||
to: './[name].[ext]', |
||||
toType: 'template', |
||||
}, |
||||
{ |
||||
from: './src/php/*/*.php', |
||||
to: './[1]/[2].[ext]', |
||||
test: /src\/php\/([^/]+)\/(.+)\.php$/, |
||||
} |
||||
]), |
||||
new RemovePlugin({ |
||||
before: { |
||||
include: ['./dist'] |
||||
}, |
||||
after: { |
||||
include: ['./images'] |
||||
} |
||||
}), |
||||
new MiniCssExtractPlugin({ |
||||
filename: "./css/bundle_[hash].css", |
||||
}), |
||||
new Chunks2JsonPlugin({ |
||||
outputDir: 'dist/', |
||||
filename: 'manifest.json' |
||||
}) |
||||
], |
||||
}]; |
@ -1,154 +1,17 @@ |
||||
const path = require('path'); |
||||
const autoprefixer = require('autoprefixer'); |
||||
const TerserPlugin = require('terser-webpack-plugin'); |
||||
const CopyPlugin = require('copy-webpack-plugin'); |
||||
const RemovePlugin = require('remove-files-webpack-plugin'); |
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
||||
const Chunks2JsonPlugin = require('chunks-2-json-webpack-plugin'); |
||||
const merge = require("webpack-merge") |
||||
const commonConfig = require("./webpack.common") |
||||
const devConfig = require("./webpack.dev") |
||||
const prodConfig = require("./webpack.prod") |
||||
const i18nConfig = require("./webpack/webpack.i18n") |
||||
|
||||
// const OutputPath = process.env.ENV_MODE
|
||||
|
||||
module.exports = [{ |
||||
mode: "development", // "production" | "development" | "none"
|
||||
entry: { |
||||
main: ['./src/ts/index.ts', './src/scss/index.scss'] |
||||
}, |
||||
output: { |
||||
path: path.resolve(__dirname, './dist'), |
||||
filename: './js/bundle_[hash].js' |
||||
}, |
||||
devtool: 'inline-source-map', |
||||
devServer: { |
||||
contentBase: path.join(__dirname, './dist'), |
||||
publicPath: '/', |
||||
port: 8080, |
||||
host: '0.0.0.0', |
||||
// proxy: {},
|
||||
compress: true, |
||||
// historyApiFallback: true,
|
||||
}, |
||||
watchOptions: { |
||||
aggregateTimeout: 300, |
||||
//poll: 1000, // specifying a poll interval in milliseconds
|
||||
ignored: /node_modules/ |
||||
}, |
||||
module: { |
||||
rules: [{ |
||||
test: /\.(png|jpg|gif|svg)$/, |
||||
exclude: [ |
||||
path.resolve(__dirname, './node_modules'), |
||||
], |
||||
use: { |
||||
loader: 'file-loader', |
||||
options: { |
||||
// name(file) {
|
||||
// return './images/[name].[ext]';
|
||||
// },
|
||||
name: '../images/[hash].[ext]' |
||||
// outputPath: './images',
|
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
test: /\.scss$/, |
||||
use: [{ |
||||
loader: MiniCssExtractPlugin.loader |
||||
}, |
||||
{ |
||||
loader: 'css-loader' |
||||
}, |
||||
{ |
||||
loader: 'postcss-loader', |
||||
options: { |
||||
plugins: () => [autoprefixer()] |
||||
} |
||||
}, |
||||
{ |
||||
loader: 'sass-loader', |
||||
options: { |
||||
sourceMap: true, |
||||
sassOptions: { |
||||
includePaths: ['./node_modules'] |
||||
}, |
||||
} |
||||
}, |
||||
] |
||||
}, |
||||
{ |
||||
test: /\.tsx?$/, |
||||
use: [{ |
||||
loader: 'babel-loader', |
||||
query: { |
||||
presets: ['@babel/preset-typescript'], |
||||
}, |
||||
}, ], |
||||
exclude: /node_modules/ |
||||
}, |
||||
{ |
||||
test: /\.(graphql|gql)$/, |
||||
exclude: /node_modules/, |
||||
loader: 'graphql-tag/loader' |
||||
} |
||||
] |
||||
}, |
||||
resolve: { |
||||
extensions: ['.tsx', '.ts', '.js'] |
||||
}, |
||||
// optimization: {
|
||||
// minimize: true,
|
||||
// minimizer: [new TerserPlugin({
|
||||
// sourceMap: false,
|
||||
// })],
|
||||
// },
|
||||
plugins: [ |
||||
new CopyPlugin([{ |
||||
from: './src/package.scss', |
||||
to: './style.css', |
||||
toType: 'file', |
||||
}, |
||||
{ |
||||
from: './src/screenshot.png', |
||||
to: './screenshot.png', |
||||
toType: 'file', |
||||
}, |
||||
{ |
||||
from: './src/images/', |
||||
to: './images/[hash].[ext]', |
||||
toType: 'template', |
||||
}, |
||||
// {
|
||||
// from: './src/*.html',
|
||||
// to: './[name].[ext]',
|
||||
// toType: 'template',
|
||||
// },
|
||||
{ |
||||
from: './src/php/*.php', |
||||
to: './[name].[ext]', |
||||
toType: 'template', |
||||
}, |
||||
{ |
||||
from: './src/php/*/*.php', |
||||
to: './[1]/[2].[ext]', |
||||
test: /src\/php\/([^/]+)\/(.+)\.php$/, |
||||
} |
||||
]), |
||||
new RemovePlugin({ |
||||
before: { |
||||
include: ['./dist'] |
||||
}, |
||||
after: { |
||||
include: ['./images'] |
||||
} |
||||
}), |
||||
new MiniCssExtractPlugin({ |
||||
// Options similar to the same options in webpackOptions.output
|
||||
// both options are optional
|
||||
filename: "./css/bundle_[hash].css", |
||||
// chunkFilename: "[id].css"
|
||||
}), |
||||
new Chunks2JsonPlugin({ |
||||
outputDir: 'dist/', |
||||
filename: 'manifest.json' |
||||
}) |
||||
], |
||||
}]; |
||||
module.exports = mode => { |
||||
// if (mode === "production") {
|
||||
// return merge(commConfig, prodConfig, {
|
||||
// mode
|
||||
// })
|
||||
// }
|
||||
// return merge(commonConfig, {
|
||||
// mode: "development", // "production" | "development" | "none"
|
||||
// })
|
||||
return commonConfig |
||||
} |
@ -0,0 +1,26 @@ |
||||
const path = require("path"); |
||||
const glob = require("glob"); |
||||
const I18nPlugin = require("i18n-webpack-plugin"); |
||||
|
||||
const PATHS = { |
||||
build: path.join(__dirname, "i18n-build"), |
||||
i18nDemo: path.join(__dirname, "app", "i18n.js"), |
||||
}; |
||||
|
||||
const TRANSLATIONS = [{ language: "en" }].concat( |
||||
glob.sync("./languages/*.json").map(file => ({ |
||||
language: path.basename(file, path.extname(file)), |
||||
translation: require(file), |
||||
})) |
||||
); |
||||
|
||||
module.exports = TRANSLATIONS.map(({ language, translation }) => ({ |
||||
entry: { |
||||
index: PATHS.i18nDemo, |
||||
}, |
||||
output: { |
||||
path: PATHS.build, |
||||
filename: `[name].${language}.js`, |
||||
}, |
||||
plugins: [new I18nPlugin(translation)], |
||||
})); |
Loading…
Reference in new issue