diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e4b6edd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: [ push, pull_request ] + +jobs: + build-and-test: + + name: ${{ matrix.os }} (${{ matrix.configuration }}) + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + configuration: [ Debug, Release ] + os: [ macos-latest, ubuntu-latest, windows-latest ] + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + submodules: 'true' + + - name: Setup MySQL + uses: ankane/setup-mysql@v1 + if : startsWith(matrix.os, 'macos') + + - name: Configure cmake + run: cmake -B${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{ matrix.configuration }} \ No newline at end of file diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000..fd179a3 --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,26 @@ +name: Clang Format Diff + +on: [ push, pull_request ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: install clang-format + run: sudo apt install clang-format + + - name: check-diff + run: | + diff=`git-clang-format --diff HEAD^` + if ! [[ "$diff" = "no modified files to format" || "$diff" = "clang-format did not modify any files" ]]; then + echo "The diff you sent is not formatted correctly." + echo "The suggested format is" + echo "$diff" + exit 1 + fi \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index ba3d8ce..0942e78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,15 @@ cmake_minimum_required(VERSION 3.15) project(feather) -#for mac -#SET(CMAKE_C_COMPILER "/usr/local/bin/gcc-8") -#SET(CMAKE_CXX_COMPILER "/usr/local/bin/g++-8") -#set(CMAKE_BUILD_TYPE Release) - set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) message(STATUS "CXX Standard: ${CMAKE_CXX_STANDARD}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++20") -SET(ENABLE_MYSQL OFF) +SET(ENABLE_MYSQL ON) + SET(ENABLE_PG OFF) -SET(ENABLE_SQLITE3 ON) +SET(ENABLE_SQLITE3 OFF) SET(ENABLE_GZIP OFF) @@ -63,23 +59,28 @@ set(SOURCE_FILES main.cpp ) +if (MSVC) + add_compile_options(/bigobj) +endif () + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines -pthread -std=c++20") #-ftree-slp-vectorize with coroutine cause link error. disable it util gcc fix. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-tree-slp-vectorize") endif() add_subdirectory(ormpp) -add_executable(feather ${SOURCE_FILES}) +add_executable(${PROJECT_NAME} ${SOURCE_FILES}) include_directories("cinatra/include" ${OPENSSL_INCLUDE_DIR}) -target_link_libraries(feather ${Boost_LIBRARIES} uuid -lstdc++fs) - if (ENABLE_MYSQL) - target_link_libraries(feather ${MYSQL_LIBRARY}) - target_include_directories(feather PRIVATE ${MYSQL_INCLUDE_DIR} ormpp) + target_link_libraries(${PROJECT_NAME} ${MYSQL_LIBRARY}) + target_include_directories(${PROJECT_NAME} PRIVATE ${MYSQL_INCLUDE_DIR} ormpp) + if (MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/MD") + endif() endif() if (ENABLE_SQLITE3) @@ -88,20 +89,20 @@ if (ENABLE_SQLITE3) endif() if (ENABLE_PG) - target_link_libraries(feather ${PGSQL_LIBRARY}) - target_include_directories(feather PRIVATE ${PGSQL_INCLUDE_DIR} ormpp) + target_link_libraries(${PROJECT_NAME} ${PGSQL_LIBRARY}) + target_include_directories(${PROJECT_NAME} PRIVATE ${PGSQL_INCLUDE_DIR} ormpp) endif() if (ENABLE_SSL) - target_link_libraries(feather ${OPENSSL_LIBRARIES} pthread -ldl) + target_link_libraries(${PROJECT_NAME} ${OPENSSL_LIBRARIES} pthread -ldl) endif() if (ENABLE_CLIENT_SSL) - target_link_libraries(feather ${OPENSSL_LIBRARIES} pthread -ldl) + target_link_libraries(${PROJECT_NAME} ${OPENSSL_LIBRARIES} pthread -ldl) endif() if (ENABLE_GZIP) - target_link_libraries(feather ${ZLIB_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES}) endif() install(TARGETS feather DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) \ No newline at end of file diff --git a/README.en.md b/README.en.md index 21349e4..aa480d8 100644 --- a/README.en.md +++ b/README.en.md @@ -96,17 +96,11 @@ If you want to use SSL, you also need to install a SSL library. This is not nece **Build** ``` -git clone https://github.com/qicosmos/feather.git +git clone --recurse-submodules https://github.com/qicosmos/feather.git -git submodule update --init +cmake -B build -mkdir build - -cd build - -cmake .. - -make -j +cmake --build build ``` # Example diff --git a/README.md b/README.md index 0b343ce..e93ed0c 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,7 @@ *Read this in other languages: [English](https://github.com/qicosmos/feather/blob/master/README.en.md), [简体中文](https://github.com/qicosmos/feather/blob/master/README.md) -[如何在archlinux上运行feather](https://github.com/qicosmos/feather/blob/master/docs/feather%20compile%20and%20run%20in%20marjaro_archlinux(author-SkyFire).md) - -[如何在win10上运行feather](https://github.com/qicosmos/feather/blob/master/docs/window_build(author-tc).txt) - -[如何在mac上运行feather](https://github.com/qicosmos/feather/blob/master/docs/feather%20Mac%E7%BC%96%E8%AF%91%E6%96%87%E6%A1%A3.md) - -[如何在windows和linux上运行feather](https://github.com/qicosmos/feather/blob/master/docs/featehr%20%E4%BD%BF%E7%94%A8.txt) +[feather使用](https://github.com/qicosmos/feather/blob/master/docs/featehr%20%E4%BD%BF%E7%94%A8.md) Feather是一个适合快速开发的modern c++ web框架,Feather的目标是让使用者以最小的精力和成本来开发一个web网站。 diff --git "a/docs/featehr \344\275\277\347\224\250.md" "b/docs/featehr \344\275\277\347\224\250.md" new file mode 100644 index 0000000..f9786e4 --- /dev/null +++ "b/docs/featehr \344\275\277\347\224\250.md" @@ -0,0 +1,51 @@ +# feather使用说明 + +1. 安装依赖库 + + ```text + mysql + ``` + +2. 编译 + + ```shell + git clone --recurse-submodules https://github.com/qicosmos/feather.git + + cmake -B build + + cmake --build build + ``` + +3. 运行 + +* 创建运行时需要的目录结构 + + 在`feather`目录下执行(此处假设构建目录为`feather/build`): + + ```shell + mkdir runtime + cd runtime + cp -rvt . ../build/feather ../purecpp ../cfg + ``` + + 此时`runtime`目录下应该有文件(目录): + + ```text + cfg/ feather* purecpp/ + ``` + +* 修改配置文件(以下均相对于`runtime`目录) + + 配置文件为`cfg/feather.cfg`,修改其中的数据库用户名和密码为真实数据。 + +* 运行 + + 在`runtime`目录下执行: + + ```shell + ./feather + ``` + +* 访问 + + **注意**:在数据库无数据的时候无法看到页面,可以通过访问:`http://localhost:8080/sign_out_page`注册用户并发表一篇文章。这时其他页面就可以访问了。 \ No newline at end of file diff --git "a/docs/featehr \344\275\277\347\224\250.txt" "b/docs/featehr \344\275\277\347\224\250.txt" deleted file mode 100644 index 50e298c..0000000 --- "a/docs/featehr \344\275\277\347\224\250.txt" +++ /dev/null @@ -1,34 +0,0 @@ -featherʹ˵ - -1. װ - - boost - mysql-connector - mysql - uuid(windowsϲҪװlinuxҪװ) - - װοhttps://github.com/qicosmos/feather/blob/master/feather_en.md - -2. - -Ҫwin vs2017 15.7+, gcc 7.2+, clang 5.0+ - -win±룬mysql-connectorͷļͿĿ¼ - -linux: - -git clone https://github.com/qicosmos/feather.git - -git submodule update --init - -mkdir build - -cd build - -cmake .. - -make -j - -3. - -οhttps://github.com/qicosmos/feather/blob/master/feather%20compile%20and%20run%20in%20archlinux(marjaro).md \ No newline at end of file diff --git "a/docs/feather Mac\347\274\226\350\257\221\346\226\207\346\241\243.md" "b/docs/feather Mac\347\274\226\350\257\221\346\226\207\346\241\243.md" deleted file mode 100644 index c740340..0000000 --- "a/docs/feather Mac\347\274\226\350\257\221\346\226\207\346\241\243.md" +++ /dev/null @@ -1,385 +0,0 @@ -# feather Mac编译文档 by zacklocx(zacklocx@gmail.com) - -#编译环境 - - macOS Mojave 10.14.1 - Xcode 10.1 - -#安装依赖库 - - 安装mysql,这里比较坑 - 首先,不用能brew安装最新版mysql(8.0.3),否则编译不过 - 其次,不能使用 "brew install mysql@5.7" 安装5.7旧版,虽然可以编译过,但是在我这里mysql服务启动异常 - 最终,从这里(https://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.31-osx10.8-x86_64.dmg)下载5.6的安装包,可用 - - 安装好mysql之后,记得在你的.bashrc或者.zshrc中设置路径 - export PATH="/usr/local/mysql/bin:$PATH" - - 使用brew安装其它依赖 - brew install gcc - brew install boost - brew install ossp-uuid - brew install mysql-connector-c - - 安装好以上依赖之后,打开feather项目的CMakeLists.txt,有几处需要修改 - - 1. 打开这里的注释 - #for mac - SET(CMAKE_C_COMPILER "/usr/local/bin/gcc-8") - SET(CMAKE_CXX_COMPILER "/usr/local/bin/g++-8") - set(CMAKE_BUILD_TYPE Release) - - 2. 添加mysql的目录 - - include_directories(/usr/local/mysql/include) - link_directories(/usr/local/mysql/lib) - - 3. 某个库好像用到了Mac的CoreFoundation,因此需要添加该framework - - function(add_framework target framework) - if(APPLE) - find_library(found ${framework}) - - if(${found} STREQUAL "${framework}-NOTFOUND") - message(FATAL_ERROR "ERROR: ${framework} not found (${CMAKE_OSX_SYSROOT})") - endif() - - #message("Found framework ${found}") - - target_link_libraries(${target} ${found}) - endif() - endfunction() - - add_framework(feather CoreFoundation) - -#编译 - - 首先,有一处修改 - feather/ormpp/type_mapping.hpp中, - 将 #include 改为 #include - - 然后 - cd feather - md build - cd build - cmake .. - make - -#组装 - 只是编译完成,还不能直接运行,要把例子跑起来还需要以下步骤: - - * 建立数据库`feather` - * 导入数据库表(以下为`feather_tables.sql`内容) - - ```sql - -- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64) - -- - -- Host: localhost Database: feather - -- ------------------------------------------------------ - -- Server version 5.7.24-0ubuntu0.18.04.1 - - /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; - /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; - /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; - /*!40101 SET NAMES utf8 */; - /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; - /*!40103 SET TIME_ZONE='+00:00' */; - /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; - /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; - /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - - -- - -- Table structure for table `article` - -- - - DROP TABLE IF EXISTS `article`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `article` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `title` text COLLATE utf8mb4_unicode_ci, - `introduce` text COLLATE utf8mb4_unicode_ci, - `user_id` int(11) DEFAULT NULL, - `visible` int(11) DEFAULT NULL, - `create_time` text COLLATE utf8mb4_unicode_ci, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `article_detail` - -- - - DROP TABLE IF EXISTS `article_detail`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `article_detail` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `parant_id` int(11) DEFAULT NULL, - `title` text COLLATE utf8mb4_unicode_ci, - `content` text COLLATE utf8mb4_unicode_ci, - `update_time` text COLLATE utf8mb4_unicode_ci, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `cncppcon2018_user` - -- - - DROP TABLE IF EXISTS `cncppcon2018_user`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `cncppcon2018_user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user_name` text, - `phone` bigint(20) DEFAULT NULL, - `email` text, - `user_group` text, - `join_time` text, - PRIMARY KEY (`id`), - UNIQUE KEY `phone` (`phone`) - ) ENGINE=InnoDB AUTO_INCREMENT=341 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_comment` - -- - - DROP TABLE IF EXISTS `pp_comment`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_comment` ( - `ID` bigint(20) NOT NULL AUTO_INCREMENT, - `user_id` bigint(20) NOT NULL, - `post_id` bigint(20) NOT NULL, - `comment_parant` bigint(20) NOT NULL, - `comment_content` text NOT NULL, - `comment_date` varchar(255) NOT NULL, - `comment_status` varchar(45) DEFAULT NULL, - PRIMARY KEY (`ID`) - ) ENGINE=MyISAM AUTO_INCREMENT=704 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_post_views` - -- - - DROP TABLE IF EXISTS `pp_post_views`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_post_views` ( - `ID` bigint(20) NOT NULL AUTO_INCREMENT, - `type` tinyint(4) NOT NULL, - `count` int(11) NOT NULL, - `period` varchar(255) NOT NULL, - PRIMARY KEY (`type`,`period`,`ID`) - ) ENGINE=MyISAM AUTO_INCREMENT=13284 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_posts` - -- - - DROP TABLE IF EXISTS `pp_posts`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_posts` ( - `ID` bigint(20) NOT NULL AUTO_INCREMENT, - `post_author` bigint(20) NOT NULL, - `post_date` varchar(255) NOT NULL, - `post_title` text NOT NULL, - `post_content` text NOT NULL, - `post_status` varchar(255) NOT NULL, - `post_modified` varchar(255) NOT NULL, - `content_abstract` text NOT NULL, - `url` varchar(255) NOT NULL, - `comment_count` bigint(20) NOT NULL, - `category` varchar(255) NOT NULL, - `raw_content` text NOT NULL, - PRIMARY KEY (`ID`) - ) ENGINE=MyISAM AUTO_INCREMENT=2058 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_sign_out_answer` - -- - - DROP TABLE IF EXISTS `pp_sign_out_answer`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_sign_out_answer` ( - `ID` int(11) NOT NULL AUTO_INCREMENT, - `question` varchar(255) NOT NULL, - `answer` text NOT NULL, - PRIMARY KEY (`ID`) - ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_terms` - -- - - DROP TABLE IF EXISTS `pp_terms`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_terms` ( - `term_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(200) NOT NULL DEFAULT '', - `slug` varchar(200) NOT NULL DEFAULT '', - `term_group` bigint(10) NOT NULL DEFAULT '0', - PRIMARY KEY (`term_id`), - KEY `slug` (`slug`) USING BTREE, - KEY `name` (`name`) USING BTREE - ) ENGINE=MyISAM AUTO_INCREMENT=61 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_user` - -- - - DROP TABLE IF EXISTS `pp_user`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_user` ( - `ID` bigint(20) NOT NULL AUTO_INCREMENT, - `user_login` varchar(255) NOT NULL, - `user_nickname` varchar(255) NOT NULL, - `user_email` varchar(255) NOT NULL, - `user_registered` varchar(255) DEFAULT NULL, - `user_icon` varchar(255) DEFAULT NULL, - `user_pass` varchar(255) NOT NULL, - `user_role` tinyint(4) NOT NULL, - PRIMARY KEY (`ID`) - ) ENGINE=MyISAM AUTO_INCREMENT=2535 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `user` - -- - - DROP TABLE IF EXISTS `user`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user_name` text COLLATE utf8mb4_unicode_ci, - `nick_name` text COLLATE utf8mb4_unicode_ci, - `token` text COLLATE utf8mb4_unicode_ci, - `gender` int(11) DEFAULT NULL, - `role` int(11) DEFAULT NULL, - `avatar` text COLLATE utf8mb4_unicode_ci, - `phone` bigint(20) DEFAULT NULL, - `email` text COLLATE utf8mb4_unicode_ci, - `qq` text COLLATE utf8mb4_unicode_ci, - `location` text COLLATE utf8mb4_unicode_ci, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `visit_counter` - -- - - DROP TABLE IF EXISTS `visit_counter`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `visit_counter` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `save_hour` text, - `counter` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB AUTO_INCREMENT=114 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `wp_term_relationships` - -- - - DROP TABLE IF EXISTS `wp_term_relationships`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `wp_term_relationships` ( - `object_id` bigint(20) unsigned NOT NULL DEFAULT '0', - `term_taxonomy_id` bigint(20) unsigned NOT NULL DEFAULT '0', - `term_order` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`object_id`,`term_taxonomy_id`), - KEY `term_taxonomy_id` (`term_taxonomy_id`) USING BTREE - ) ENGINE=MyISAM DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - - /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; - /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; - /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; - /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; - /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - - -- Dump completed on 2018-12-11 15:01:53 - ``` - - 成功导入后,应该可以看到如下的表结构: - - ```text - +-----------------------+ - | Tables_in_feather | - +-----------------------+ - | article | - | article_detail | - | cncppcon2018_user | - | pp_comment | - | pp_post_views | - | pp_posts | - | pp_sign_out_answer | - | pp_terms | - | pp_user | - | user | - | visit_counter | - | wp_term_relationships | - +-----------------------+ - ``` - - * 插入验证数据。 - - 导入数据库表后,还需要插入两条数据(可参见代码`purecpp_controller.hpp`的`423行`及`522`行的验证逻辑): - - ```sql - insert into pp_sign_out_answer values(1,"args + ...是C++17什么特性?","fold expression,right fold,折叠表达式"),(2,"[](){}是C++11的什么特性?","lambda,Lambda,lambda表达式,Lambda表达式"); - ``` - - 注意这里的`id`分别为`1`和`2`。 - - * 创建运行时需要的目录结构 - - 在`feather`目录下执行(此处假设构建目录为`feather/build`): - - ```shell - mkdir runtime - cd runtime - cp -rvt . ../build/feather ../purecpp ../cfg - ``` - - 此时`runtime`目录下应该有文件(目录): - - ```text - cfg/ feather* purecpp/ - ``` - - * 修改配置文件(以下均相对于`runtime`目录) - - 配置文件为`cfg/feather.cfg`,修改其中的数据库用户名和密码为真实数据。 - - * 运行 - - 在`runtime`目录下执行: - - ```shell - ./feather - ``` - - * 访问 - - **注意**:在数据库无数据的时候无法看到页面,可以通过访问:`http://localhost:8080/sign_out_page`注册用户并发表一篇文章。这时其他页面就可以访问了。 \ No newline at end of file diff --git a/docs/feather compile and run in marjaro_archlinux(author-SkyFire).md b/docs/feather compile and run in marjaro_archlinux(author-SkyFire).md deleted file mode 100644 index d3a1407..0000000 --- a/docs/feather compile and run in marjaro_archlinux(author-SkyFire).md +++ /dev/null @@ -1,452 +0,0 @@ -# feather 使用(majaro/archlinux) - -1. 查看系统版本 - - ```shell - uname -srvmpio - ``` - - 本机输出: - - ```text - Linux 4.14.85-1-MANJARO #1 SMP PREEMPT Sat Dec 1 12:18:09 UTC 2018 x86_64 unknown unknown GNU/Linux - ``` - -2. 安装依赖库 - - ```shell - sudo pacman -S boost libutil-linux mysql libpqxx sqlite zlib openssl libcurl-compat - ``` - -3. 检查依赖 - -4. 拉取代码 - - ```shell - git clone http://github.com/qicosmos/feather - ``` - -4. 安装依赖项(以下均相对于`feather`目录) - - 进入`feather`源码目录,我尝试使用 - - ```shell - git submodule update --init - ``` - - 如果拉取成功就可以忽略下面的这些内容,如果失败了就往下看。 - - 命令拉取依赖模块,但是报出了`fatal: unable to access 'https://github.com/qicosmos/cinatra.git/': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to ...`的错误,于是我修改了`.gitmodules`文件。将其中的`https`全部修改为`http`,以下为修改后的内容: - - ```text - [submodule "cinatra"] - path = cinatra - url = http://github.com/qicosmos/cinatra.git - [submodule "ormpp"] - path = ormpp - url = http://github.com/qicosmos/ormpp.git - [submodule "iguana"] - path = iguana - url = http://github.com/qicosmos/iguana.git - [submodule "render"] - path = render - url = http://github.com/qicosmos/render.git - ``` - - 然后执行: - - ``` - git submodule update --init - ``` - - 可成功拉取子模块。 - -5. 编译 - - 执行命令: - - ```shell - mkdir build - cd build - cmake .. - make - ``` - - 如果发现在`make`过程中报错: - - ```text - In file included from /usr/include/mysql/mysql.h:81, - from /home/skyfire/code/feather_demo/feather/ormpp/type_mapping.hpp:10, - from /home/skyfire/code/feather_demo/feather/ormpp/utility.hpp:7, - from /home/skyfire/code/feather_demo/feather/ormpp/dbng.hpp:13, - from /home/skyfire/code/feather_demo/feather/feather.h:9, - from /home/skyfire/code/feather_demo/feather/main.cpp:5: - /usr/include/mysql/mysql_com.h:1011:10: 致命错误:mysql/udf_registration_types.h:没有那个文件或目录 - #include - ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 编译中断。 - make[2]: *** [CMakeFiles/feather.dir/build.make:63:CMakeFiles/feather.dir/main.cpp.o] 错误 1 - make[1]: *** [CMakeFiles/Makefile2:73:CMakeFiles/feather.dir/all] 错误 2 - make: *** [Makefile:130:all] 错误 2 - - ``` - - 使用`find`搜索文件`udf_registration_types.h` - - ```shell - sudo find / -name udf_registration_types.h - ``` - - 找到文件: - - ```text - /usr/include/mysql/mysql/udf_registration_types.h - ``` - - 于是将`/usr/include/mysql`添加至搜索路径重新编译: - - ```shell - make CXX_FLAGS+="-I/usr/include/mysql" - ``` - - 继续报错,这次错误太多,就不贴完整信息了,翻到最上面的报错信息,发现是关于`string_view`的: - - ```text - feather/cinatra/define.h:20:20: 错误:‘string_view’不是命名空间‘std’中的一个类型名 - inline const std::string_view STAIC_RES = "cinatra_staic_resource"; - ^~~~~~~~~~~ - ``` - - 推测与`c++`标准未指定有关,继续添加编译命令: - - ```shell - make CXX_FLAGS+="-I/usr/include/mysql -std=c++17" - ``` - - 编译通过。 - -7. 运行 - - 到这里了说明编译完成了,恭喜你!请继续加油,我们还需要把feather运行起来,要把例子跑起来还需要以下步骤: - - 你还可以直接导入feather.sql,里面已经准备了一些初始数据,导入之后就可以运行了。 - - 如果你希望一个个去创建表就往下面看。 - - * 建立数据库`feather` - * 导入数据库表(以下为feather数据库的表结构) - - ```sql - -- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64) - -- - -- Host: localhost Database: feather - -- ------------------------------------------------------ - -- Server version 5.7.24-0ubuntu0.18.04.1 - - /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; - /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; - /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; - /*!40101 SET NAMES utf8 */; - /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; - /*!40103 SET TIME_ZONE='+00:00' */; - /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; - /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; - /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - - -- - -- Table structure for table `article` - -- - - DROP TABLE IF EXISTS `article`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `article` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `title` text COLLATE utf8mb4_unicode_ci, - `introduce` text COLLATE utf8mb4_unicode_ci, - `user_id` int(11) DEFAULT NULL, - `visible` int(11) DEFAULT NULL, - `create_time` text COLLATE utf8mb4_unicode_ci, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `article_detail` - -- - - DROP TABLE IF EXISTS `article_detail`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `article_detail` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `parant_id` int(11) DEFAULT NULL, - `title` text COLLATE utf8mb4_unicode_ci, - `content` text COLLATE utf8mb4_unicode_ci, - `update_time` text COLLATE utf8mb4_unicode_ci, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `cncppcon2018_user` - -- - - DROP TABLE IF EXISTS `cncppcon2018_user`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `cncppcon2018_user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user_name` text, - `phone` bigint(20) DEFAULT NULL, - `email` text, - `user_group` text, - `join_time` text, - PRIMARY KEY (`id`), - UNIQUE KEY `phone` (`phone`) - ) ENGINE=InnoDB AUTO_INCREMENT=341 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_comment` - -- - - DROP TABLE IF EXISTS `pp_comment`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_comment` ( - `ID` bigint(20) NOT NULL AUTO_INCREMENT, - `user_id` bigint(20) NOT NULL, - `post_id` bigint(20) NOT NULL, - `comment_parant` bigint(20) NOT NULL, - `comment_content` text NOT NULL, - `comment_date` varchar(255) NOT NULL, - `comment_status` varchar(45) DEFAULT NULL, - PRIMARY KEY (`ID`) - ) ENGINE=MyISAM AUTO_INCREMENT=704 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_post_views` - -- - - DROP TABLE IF EXISTS `pp_post_views`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_post_views` ( - `ID` bigint(20) NOT NULL AUTO_INCREMENT, - `type` tinyint(4) NOT NULL, - `count` int(11) NOT NULL, - `period` varchar(255) NOT NULL, - PRIMARY KEY (`type`,`period`,`ID`) - ) ENGINE=MyISAM AUTO_INCREMENT=13284 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_posts` - -- - - DROP TABLE IF EXISTS `pp_posts`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_posts` ( - `ID` bigint(20) NOT NULL AUTO_INCREMENT, - `post_author` bigint(20) NOT NULL, - `post_date` varchar(255) NOT NULL, - `post_title` text NOT NULL, - `post_content` text NOT NULL, - `post_status` varchar(255) NOT NULL, - `post_modified` varchar(255) NOT NULL, - `content_abstract` text NOT NULL, - `url` varchar(255) NOT NULL, - `comment_count` bigint(20) NOT NULL, - `category` varchar(255) NOT NULL, - `raw_content` text NOT NULL, - PRIMARY KEY (`ID`) - ) ENGINE=MyISAM AUTO_INCREMENT=2058 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_sign_out_answer` - -- - - DROP TABLE IF EXISTS `pp_sign_out_answer`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_sign_out_answer` ( - `ID` int(11) NOT NULL AUTO_INCREMENT, - `question` varchar(255) NOT NULL, - `answer` text NOT NULL, - PRIMARY KEY (`ID`) - ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_terms` - -- - - DROP TABLE IF EXISTS `pp_terms`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_terms` ( - `term_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(200) NOT NULL DEFAULT '', - `slug` varchar(200) NOT NULL DEFAULT '', - `term_group` bigint(10) NOT NULL DEFAULT '0', - PRIMARY KEY (`term_id`), - KEY `slug` (`slug`) USING BTREE, - KEY `name` (`name`) USING BTREE - ) ENGINE=MyISAM AUTO_INCREMENT=61 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `pp_user` - -- - - DROP TABLE IF EXISTS `pp_user`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `pp_user` ( - `ID` bigint(20) NOT NULL AUTO_INCREMENT, - `user_login` varchar(255) NOT NULL, - `user_nickname` varchar(255) NOT NULL, - `user_email` varchar(255) NOT NULL, - `user_registered` varchar(255) DEFAULT NULL, - `user_icon` varchar(255) DEFAULT NULL, - `user_pass` varchar(255) NOT NULL, - `user_role` tinyint(4) NOT NULL, - PRIMARY KEY (`ID`) - ) ENGINE=MyISAM AUTO_INCREMENT=2535 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `user` - -- - - DROP TABLE IF EXISTS `user`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user_name` text COLLATE utf8mb4_unicode_ci, - `nick_name` text COLLATE utf8mb4_unicode_ci, - `token` text COLLATE utf8mb4_unicode_ci, - `gender` int(11) DEFAULT NULL, - `role` int(11) DEFAULT NULL, - `avatar` text COLLATE utf8mb4_unicode_ci, - `phone` bigint(20) DEFAULT NULL, - `email` text COLLATE utf8mb4_unicode_ci, - `qq` text COLLATE utf8mb4_unicode_ci, - `location` text COLLATE utf8mb4_unicode_ci, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `visit_counter` - -- - - DROP TABLE IF EXISTS `visit_counter`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `visit_counter` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `save_hour` text, - `counter` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB AUTO_INCREMENT=114 DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - - -- - -- Table structure for table `wp_term_relationships` - -- - - DROP TABLE IF EXISTS `wp_term_relationships`; - /*!40101 SET @saved_cs_client = @@character_set_client */; - /*!40101 SET character_set_client = utf8 */; - CREATE TABLE `wp_term_relationships` ( - `object_id` bigint(20) unsigned NOT NULL DEFAULT '0', - `term_taxonomy_id` bigint(20) unsigned NOT NULL DEFAULT '0', - `term_order` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`object_id`,`term_taxonomy_id`), - KEY `term_taxonomy_id` (`term_taxonomy_id`) USING BTREE - ) ENGINE=MyISAM DEFAULT CHARSET=utf8; - /*!40101 SET character_set_client = @saved_cs_client */; - /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - - /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; - /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; - /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; - /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; - /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - - -- Dump completed on 2018-12-11 15:01:53 - ``` - - 成功导入后,应该可以看到如下的表结构: - - ```text - +-----------------------+ - | Tables_in_feather | - +-----------------------+ - | article | - | article_detail | - | cncppcon2018_user | - | pp_comment | - | pp_post_views | - | pp_posts | - | pp_sign_out_answer | - | pp_terms | - | pp_user | - | user | - | visit_counter | - | wp_term_relationships | - +-----------------------+ - ``` - - - - * 插入验证数据。 - - 导入数据库表后,还需要插入两条数据(可参见代码`purecpp_controller.hpp`的`423行`及`522`行的验证逻辑): - - ```sql - insert into pp_sign_out_answer values(1,"args + ...是C++17什么特性?","fold expression,right fold,折叠表达式"),(2,"[](){}是C++11的什么特性?","lambda,Lambda,lambda表达式,Lambda表达式"); - ``` - - **注意这里的`id`分别为`1`和`2`。** - - * 创建运行时需要的目录结构 - - 在`feather`目录下执行(此处假设构建目录为`feather/build`): - - ```shell - mkdir runtime - cd runtime - cp -rvt . ../build/feather ../purecpp ../cfg - ``` - - 此时`runtime`目录下应该有文件(目录): - - ```text - cfg/ feather* purecpp/ - ``` - - * 修改配置文件(以下均相对于`runtime`目录) - - 配置文件为`cfg/feather.cfg`,修改其中的数据库用户名和密码为真实数据。 - - * 运行 - - 在`runtime`目录下执行: - - ```shell - ./feather - ``` - - * 访问 - - **注意**:在数据库无数据的时候无法看到页面,可以通过访问:`http://localhost:8080/sign_out_page`注册用户并发表一篇文章。这时其他页面就可以访问了。 \ No newline at end of file diff --git a/docs/window_build(author-tc).txt b/docs/window_build(author-tc).txt deleted file mode 100644 index 238130b..0000000 --- a/docs/window_build(author-tc).txt +++ /dev/null @@ -1,27 +0,0 @@ -뻷windows10רҵ棬VS2017棬boost1.6mysql5.7.24 - -boost룺 -صַhttps://nchc.dl.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.zip -bootstrap.bat -b2 link=static runtime-link=static threading=multi release debug --with-system --with-date_time --with-regex - -mysqlصַhttps://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-win32.zip -mysqlҪ룬ֱʹðװĿ¼µinclude,libļ - -featherأ -git clone https://github.com/qicosmos/feather.git -cd feather -git submodule update --init - -feather룺 -½һյĹ:feather -main.cppļ -cinatra/response.hppļͷļ #include - -> c/c++ -> Ԥ->Ԥ ORMPP_ENABLE_MYSQL, _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS, _CRT_SECURE_NO_WARNINGS - -> c/c++ -> ->ѡ /std:c++17 -úboost,mysqlͷļLIBĿ¼mysqlҪlibmysql.libļ -ɺִļҪpurecppcfgͬһĿ¼ - -ݿã -½һݿfeatherfeather.sqlhttps://github.com/qicosmos/feather/blob/master/feather.sqlļ޸cfg/feather.cfgݿز - diff --git a/feather.vcxproj b/feather.vcxproj deleted file mode 100644 index ae75fc8..0000000 --- a/feather.vcxproj +++ /dev/null @@ -1,152 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {7E7DDDCB-897D-49B6-9B2A-616E3D2E34BA} - feather - 10.0 - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - iguana;D:\ormpp_deps\mysql;$(IncludePath) - D:\ormpp_deps\mysql\lib;$(LibraryPath) - - - iguana;D:\ormpp_deps\mysql;$(IncludePath) - D:\ormpp_deps\mysql\lib;$(LibraryPath) - - - - Level3 - Disabled - true - true - stdcpp17 - 4996;%(DisableSpecificWarnings) - - - Console - - - - - Level3 - Disabled - true - true - stdcpp17 - 4996;%(DisableSpecificWarnings) - ORMPP_ENABLE_MYSQL;%(PreprocessorDefinitions) - /bigobj %(AdditionalOptions) - - - Console - libmysql_x64.lib;%(AdditionalDependencies) - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpp17 - 4996;%(DisableSpecificWarnings) - - - Console - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpp17 - 4996;%(DisableSpecificWarnings) - ORMPP_ENABLE_MYSQL;%(PreprocessorDefinitions) - /bigobj %(AdditionalOptions) - - - Console - true - true - libmysql_x64.lib;%(AdditionalDependencies) - - - - - - - - - \ No newline at end of file diff --git a/feather.vcxproj.filters b/feather.vcxproj.filters deleted file mode 100644 index 048f37d..0000000 --- a/feather.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - 源文件 - - - \ No newline at end of file