### Start MySQL Service and Retrieve Temporary Password Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md The 'service mysqld start' command initiates the MySQL server. After starting, 'grep' is used to find the temporary root password generated by MySQL, which is required for initial login and securing the installation. ```Shell service mysqld start ``` ```Shell grep 'temporary password' /var/log/mysqld.log ``` -------------------------------- ### Start JPress Application (After Configuration) Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md Command to start the JPress application after applying necessary configuration fixes, such as file format correction and host binding, leading to a successful foreground launch. ```Shell ./jpress.sh start ``` -------------------------------- ### Start JPress Application (Initial Attempt) Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md The initial command used to start the JPress application via its shell script. This attempt might fail due to configuration issues. ```Shell ./jpress.sh start ``` -------------------------------- ### Modify JPress Startup Script for Background Execution Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md Shows the original and modified 'start()' function within 'jpress.sh' to enable background execution using 'nohup', redirecting output to '/dev/null'. ```Shell function start() { java -Djava.awt.headless=true -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} & } ``` ```Shell function start() { nohup java -Djava.awt.headless=true -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} >/dev/null 2>&1 & } ``` -------------------------------- ### Install MySQL Repository and Server Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md First, the downloaded RPM package is installed to add the MySQL repository to yum's sources. Then, 'yum install mysql-server' is used to install the MySQL database server. This process may require importing a GPG key if an error occurs. ```Shell rpm -ivh mysql57-community-release-el7-7.noarch.rpm ``` ```Shell yum install mysql-server ``` -------------------------------- ### Check for Existing MySQL Installation Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md This command uses 'rpm' to query installed packages and 'grep' to filter for 'mysql'. It helps determine if MySQL or related components are already present on the system before proceeding with a new installation. ```Shell rpm -qa | grep mysql ``` -------------------------------- ### Install Unzip Utility on Linux Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md This command installs both 'unzip' and 'zip' utilities using yum. These tools are essential for compressing and decompressing .zip archives on a Linux system, which might be needed for project files. ```Shell yum install -y unzip zip ``` -------------------------------- ### Secure MySQL Installation and Login Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md The 'mysql_secure_installation' script guides you through setting a new root password, removing anonymous users, disallowing remote root login, and removing test databases. After securing, 'mysql -uroot -p' allows you to log in to the MySQL client. ```Shell mysql_secure_installation ``` ```Shell mysql -uroot -p ``` -------------------------------- ### Install Baota Panel on Cloud Server Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/ces_bt_config.md This shell command is used to install the Baota (bt.cn) panel on a Linux cloud server. It first installs `wget` if not present, then downloads the Baota installation script, and finally executes it. This process sets up the web-based control panel for server management. ```Shell yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh ``` -------------------------------- ### Import MySQL GPG Key for Installation Error Resolution Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md If you encounter GPG key errors during MySQL installation, this command imports the necessary public key. After importing, retry the 'yum install mysql-server' command to complete the installation successfully. ```Shell rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 ``` -------------------------------- ### Configure JDK Environment Variables in /etc/profile Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md These commands set up the JAVA_HOME, CLASSPATH, and PATH environment variables for the JDK. This allows Java commands to be executed from any directory. Remember to replace '/usr/local/jdk/jdk1.8' with your actual JDK installation path. ```Shell vim /etc/profile ``` ```Shell #set java enviroment JAVA_HOME=/usr/local/jdk/jdk1.8 CLASSPATH=.:$JAVA_HOME/lib.tools.jar PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME CLASSPATH PATH ``` -------------------------------- ### Package JPress Project with Maven Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md Command to clean and package the JPress project into a deployable archive (e.g., 'starter-4.0.zip') using Maven. ```Shell mvn clean package ``` -------------------------------- ### Apply and Verify JDK Environment Changes Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md After modifying '/etc/profile', the 'source' command reloads the environment variables without requiring a system reboot. The 'java -version' command then verifies that JDK is correctly installed and configured. ```Shell source /etc/profile ``` ```Shell java -version ``` -------------------------------- ### HTML Toolbox Widget Example Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/development/module/toolkit.md This HTML snippet defines a small box widget for the JPress toolbox, displaying 'Jpress 岗位导入' (JPress Job Import) and providing a link to start using it. It utilizes Bootstrap's `small-box` class and Font Awesome icons for styling and visual representation. ```html

Jpress 岗位导入

开始使用
``` -------------------------------- ### Configure Undertow Host Binding in jpress.sh Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md Instructions and the specific JVM argument to add to the 'jpress.sh' startup script, ensuring Undertow binds to all network interfaces (0.0.0.0) for external accessibility. ```Shell vim jpress.sh ``` ```Java -Dundertow.host=0.0.0.0 ``` ```Vim :wq ``` -------------------------------- ### Download MySQL 5.7 Repository for CentOS 7 Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md CentOS 7's default yum repositories do not include MySQL. This command downloads the official MySQL 5.7 community repository package, which is necessary to install MySQL via yum. ```Shell wget http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm ``` -------------------------------- ### JPress Plugin Installation Page Template and Logic Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/addon/install.html This snippet encompasses the complete front-end implementation for a JPress plugin installation page. It includes the JPress template directives, embedded CSS for styling the upload area, JavaScript for handling file uploads with jQuery File Upload, and the main HTML content for user interaction and instructions. It manages progress display and post-upload notifications. ```CSS #uploader { height: 230px; } .myPanel { font-size: 25px; color: #ccc; text-align: center; padding-top: 60px; } ``` ```JavaScript $('#cfile').fileupload({ dropZone: $('#uploader'), url: '#(CPATH)/admin/addon/doUploadAndInstall', sequentialUploads: true, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $(".myPanel").text("上传进度:" + progress + "%") }, done: function (e, data) { $(".myPanel").text("或者拖动插件文件到这里进行安装..."); if (data.result.state == "ok") { toastr.options.onHidden = function () { location.href = "#(CPATH)/admin/addon/list"; } toastr.success(" 插件安装成功 ") } else { toastr.error(data.result.message) } } }); ``` ```HTML 插件安装 首页 / 插件 / 插件安装 =================== 选择插件文件... 或者拖动插件文件到这里进行安装... ``` -------------------------------- ### jQuery File Upload Configuration for Template Installation Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/template/install.html Configures the jQuery File Upload plugin to handle template file uploads. It sets the drop zone, upload URL, enables sequential uploads, and defines callbacks for submission, progress updates, and completion. Upon successful installation, it redirects the user; otherwise, it displays an error message. ```JavaScript $('#cfile').fileupload({ dropZone: $('#uploader'), url: '#(CPATH)/admin/template/doInstall', sequentialUploads: true, submit:function (e,data){ data.formData = {type:getInstallType()} return true; }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $(".myPanel").text("上传进度:" + progress + "%") }, done: function (e, data) { $(".myPanel").text("或者模板文件到这里进行安装..."); if (data.result.state == "ok") { toastr.options.onHidden = function () { location.href = "#(CPATH)/admin/template/list"; } toastr.success(" 模板安装成功 ") } else { toastr.error(data.result.message) } } }); ``` -------------------------------- ### CSS Styles for Uploader and Panel Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/template/install.html Defines basic CSS styles for the file uploader drop zone and a panel used to display messages or progress. ```CSS #uploader { height: 230px; } .myPanel { font-size: 25px; color: #ccc; text-align: center; padding-top: 60px; } ``` -------------------------------- ### Example JSON Response for Paginated Job List Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/development/api/api_job.md An example JSON payload demonstrating the structure of a successful `Ret` response for paginated job data, including the `Page` object with pagination metadata and a list of `Job` entities. ```json { "state":"ok", "page":{ "pageSize":10, "totalPage":1, "totalRow":2, "firstPage":true, "lastPage":true, "pageNumber":1, "list":[ { "id":100, "title":"职位名称或者标题", "content":"描述", "department":"对应部门", "categoryId":100, "addressId":100, "ageLimitStart":100, "ageLimitEnd":100, "education":100, "yearsLimitType":100, "withNotify":true, "notifyEmails":"通知的邮箱", "notifyTitle":"通知的邮件标题", "notifyContent":"通知的邮件内容", "withRemote":true, "withApply":true, "withHurry":true, "workType":100, "recruitType":100, "recruitNumbers":100, "expiredTo":"2022-08-30 09:20:32", "metaTitle":"SEO标题", "metaKeywords":"SEO关键字", "metaDescription":"SEO描述信息", "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "siteId":100 }, { "id":100, "title":"职位名称或者标题", "content":"描述", "department":"对应部门", "categoryId":100, "addressId":100, "ageLimitStart":100, "ageLimitEnd":100, "education":100, "yearsLimitType":100, "withNotify":true, "notifyEmails":"通知的邮箱", "notifyTitle":"通知的邮件标题", "notifyContent":"通知的邮件内容", "withRemote":true, "withApply":true, "withHurry":true, "workType":100, "recruitType":100, "recruitNumbers":100, "expiredTo":"2022-08-30 09:20:32", "metaTitle":"SEO标题", "metaKeywords":"SEO关键字", "metaDescription":"SEO描述信息", "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "siteId":100 } ] } } ``` -------------------------------- ### JFinal Template for Latest Articles Display Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-article/module-article-web/src/main/webapp/WEB-INF/views/admin/article/_dashboard_box.html Illustrates how to use JFinal Template syntax to iterate over a collection of articles, display their creation date, title, and generate a clickable link to the article's URL. ```jfinal-template #for(article : articles) #end #date(article.created ??) [#(article.title ??)](#(article.url ??)) ``` -------------------------------- ### Example JSON Response for Non-Paginated Job List Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/development/api/api_job.md An example JSON payload demonstrating the structure of a successful `Ret` response containing a direct list of `Job` entities, typically used for non-paginated results. ```json { "state":"ok", "list":[ { "id":100, "title":"职位名称或者标题", "content":"描述", "department":"对应部门", "categoryId":100, "addressId":100, "ageLimitStart":100, "ageLimitEnd":100, "education":100, "yearsLimitType":100, "withNotify":true, "notifyEmails":"通知的邮箱", "notifyTitle":"通知的邮件标题", "notifyContent":"通知的邮件内容", "withRemote":true, "withApply":true, "withHurry":true, "workType":100, "recruitType":100, "recruitNumbers":100, "expiredTo":"2022-08-30 09:20:32", "metaTitle":"SEO标题", "metaKeywords":"SEO关键字", "metaDescription":"SEO描述信息", "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "siteId":100 }, { "id":100, "title":"职位名称或者标题", "content":"描述", "department":"对应部门", "categoryId":100, "addressId":100, "ageLimitStart":100, "ageLimitEnd":100, "education":100, "yearsLimitType":100, "withNotify":true, "notifyEmails":"通知的邮箱", "notifyTitle":"通知的邮件标题", "notifyContent":"通知的邮件内容", "withRemote":true, "withApply":true, "withHurry":true, "workType":100, "recruitType":100, "recruitNumbers":100, "expiredTo":"2022-08-30 09:20:32", "metaTitle":"SEO标题", "metaKeywords":"SEO关键字", "metaDescription":"SEO描述信息", "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "siteId":100 } ] } ``` -------------------------------- ### Extract JDK Archive on Linux Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md This command extracts the downloaded JDK tarball on a Linux system. Ensure the tar.gz file is in the current directory or provide the full path. ```Shell tar -xvf jdk-8u202-linux-x64.tar.gz ``` -------------------------------- ### Check MySQL User Permissions Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md This SQL query retrieves the username and host for all users in the 'mysql.user' table. It's useful for verifying existing user permissions and identifying which hosts are allowed to connect. ```SQL select user ,host from mysql.user; ``` -------------------------------- ### Example JSON Response for Paginated Articles Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/development/api/api_article.md A sample JSON payload demonstrating the `Ret` and `Page` data models when returning a paginated list of `Article` objects, including all their detailed fields. ```json { "state":"ok", "page":{ "pageSize":10, "totalPage":1, "totalRow":2, "firstPage":true, "lastPage":true, "pageNumber":1, "list":[ { "id":100, "pid":100, "slug":"slug", "title":"标题", "author":"作者", "content":"内容", "editMode":"编辑模式,默认为html,其他可选项包括html,markdown ..", "summary":"摘要", "linkTo":"连接到(常用于谋文章只是一个连接)", "thumbnail":"缩略图", "style":"样式", "userId":100, "orderNumber":100, "status":"状态", "commentStatus":true, "commentCount":100, "commentTime":"2022-08-30 09:20:32", "viewCount":100, "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "flag":"标识,通常用于对某几篇文章进行标识,从而实现单独查询", "metaTitle":"SEO标题", "metaKeywords":"SEO关键字", "metaDescription":"SEO描述信息", "withRecommend":true, "withTop":true, "withHot":true, "withLeadNews":true, "withAllowSearch":true, "options":"json 扩展", "siteId":100 }, { "id":100, "pid":100, "slug":"slug", "title":"标题", "author":"作者", "content":"内容", "editMode":"编辑模式,默认为html,其他可选项包括html,markdown ..", "summary":"摘要", "linkTo":"连接到(常用于谋文章只是一个连接)", "thumbnail":"缩略图", "style":"样式", "userId":100, "orderNumber":100, "status":"状态", "commentStatus":true, "commentCount":100, "commentTime":"2022-08-30 09:20:32", "viewCount":100, "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "flag":"标识,通常用于对某几篇文章进行标识,从而实现单独查询", "metaTitle":"SEO标题", "metaKeywords":"SEO关键字", "metaDescription":"SEO描述信息", "withRecommend":true, "withTop":true, "withHot":true, "withLeadNews":true, "withAllowSearch":true, "options":"json 扩展", "siteId":100 } ] } } ``` -------------------------------- ### Unzip JPress Deployment Archive Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md Command to decompress the JPress application archive on a Linux server, extracting its contents into a specified directory. ```Shell unzip starter-4.0.zip -d starter-4.0 ``` -------------------------------- ### Handle JPress Plugin Management Actions with jQuery and LayUI Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/addon/list.html This JavaScript snippet utilizes jQuery to bind click events to various plugin management buttons. It initiates AJAX requests to backend endpoints for actions such as deleting, uninstalling, installing, starting, and stopping plugins. Additionally, it integrates with the LayUI 'layer' component to open dynamic modal windows for displaying plugin readme and changelog content, constructing URLs using templated paths and data attributes. ```javascript $(".addon-del").on("click", function () { ajaxGet("#(CPATH)/admin/addon/doDel?id=" + $(this).attr("data-id")) }) $(".addon-unisntall").on("click", function () { if (confirm('确定要卸载该插件吗?卸载后该插件的所有数据将被删除,不可恢复。')) { ajaxGet("#(CPATH)/admin/addon/doUninstall?id=" + $(this).attr("data-id")) } }) $(".addon-install").on("click", function () { ajaxGet("#(CPATH)/admin/addon/doInstall?id=" + $(this).attr("data-id")) }) $(".addon-start").on("click", function () { ajaxGet("#(CPATH)/admin/addon/doStart?id=" + $(this).attr("data-id")) }) $(".addon-stop").on("click", function () { ajaxGet("#(CPATH)/admin/addon/doStop?id=" + $(this).attr("data-id")) }) $(".readme-browser").on("click", function () { var id = $(this).attr("data-id"); var title = $(this).attr("data-title"); layer.open({ type: 2, title: '【' + title+'】详情', anim: 2, shadeClose: true, shade: 0.3, area: ['90%', '90%'], content: jpress.cpath + '/admin/addon/readme?id='+id, }); }) $(".changelog-browser").on("click", function () { var id = $(this).attr("data-id"); var title = $(this).attr("data-title"); layer.open({ type: 2, title: '【' + title+'】更新日志', anim: 2, shadeClose: true, shade: 0.3, area: ['90%', '90%'], content: jpress.cpath + '/admin/addon/changelog?id='+id, }); }) ``` -------------------------------- ### Diagnose and Fix Shell Script File Format in Vim Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md Commands used within the 'vi' editor to check and then change the file format of 'jpress.sh' from DOS to Unix, resolving common script execution errors on Linux. ```Shell vi jpress.sh ``` ```Vim :set ff ``` ```Vim :set ff=unix ``` ```Vim :wq ``` -------------------------------- ### JPress Template Loop and Variable Display Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-form/module-form-web/src/main/webapp/WEB-INF/views/admin/form/components/radio.html Demonstrates basic looping over a collection and displaying a variable within a JPress template. It iterates through 'options' and prints the 'text' property of each 'option', along with a standalone 'label' variable. ```JPress Template #(label ??) #for(option : options) #(option.text ??) #end ``` -------------------------------- ### Basic JPress Template File Example Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-template/src/main/webapp/templates/JPressPortal/page.html This snippet illustrates the fundamental components of a JPress template. It shows how to include a parent layout, define a CSS block, and create a content block where dynamic variables like page title and content are rendered. ```JPress Template #include("./layout.html") #@layout() #define css() #end #define content() #(page.title ??) ---------------- #(page.content ??) #end ``` -------------------------------- ### JFinal Template for Page Layout and Dynamic Content Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-template/src/main/webapp/templates/JPressPortal/page_leftbar.html This JFinal template defines a comprehensive page structure, integrating a layout, defining CSS and content blocks, and dynamically rendering a list of pages. It showcases JFinal's directives for includes, layout application, content block definition, iteration over collections, and variable output for page titles and content. ```JFinal Template #include("./layout.html") #@layout() #define css() #end #define content() #pages(flag = 'leftbar') #for(page : pages) [#(page.title ??)](#\(page.url ??\)) #end #end #(page.title ??) ---------------- #(page.content ??) #end ``` -------------------------------- ### JPress Template Pagination Macro and Loop Usage Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/ucenter/_layout/_paginate.html This snippet illustrates the definition of a custom pagination macro (`_ucenter_paginate`) and its subsequent usage with the `#adminPaginate()` helper. It demonstrates iterating over a collection of `pages` using a `#for` loop, accessing properties like `text` and `url` for dynamic link generation within the JPress templating environment. ```JPress Template #define _ucenter_paginate() #adminPaginate() #for(page : pages)* [#(page.text??)](#\\(page.url??\\)) #end #end #end ``` -------------------------------- ### JPress Addon Upgrade Page HTML Content Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/addon/upgrade.html Defines the main structural HTML content for the JPress addon upgrade page, including a heading and instructions for users to select or drag and drop new plugin files for installation. This HTML content is defined within a JFinal template content block and includes template variables. ```HTML

插件升级 Addon Upgrade

选择新的插件文件... 或者将新的#(addon.title ??)插件文件 拖动到这里进行安装... ``` -------------------------------- ### Get Template Installation Type Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/template/install.html A JavaScript function that retrieves the selected installation type (e.g., '全新安装' or '覆盖安装') from a dropdown list with the ID 'installType'. This value is used as part of the form data during the template upload process. ```JavaScript function getInstallType(){ return $("#installType option:selected").val(); } ``` -------------------------------- ### Create Aliyun Live Stream Player Instance Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/attachment/video_add.html This function initializes an Aliplayer instance for live stream playback. It prioritizes a direct `source` URL but can fall back to creating a VOD player using `liveCloudVid` and `liveCloudPlayAuth` if no source is provided. It configures the player for live content with specific dimensions and settings. ```javascript function createLivePlayer(source, liveCloudVid, liveCloudPlayAuth) { if (source != "") { var player = new Aliplayer({ "id": "livePlayer", "source": source, // "playauth": playauth, // "qualitySort": "asc", // "format": "mp4", // "mediaType": "video", "width": "100%", "height": "100%", "videoWidth": "100%", "videoHeight": "100%", "autoplay": false, "isLive": true, // "cover": "缩略图", "rePlay": false, "playsinline": true, "preload": false, "controlBarVisibility": "hover", "useH5Prism": true, "useFlashPrism": false }, function (player) { console.log("The player is created"); }); return player; } else { return createVideoPlayer(liveCloudVid, liveCloudPlayAuth, "livePlayer"); } } ``` -------------------------------- ### Initialize Video Player on Page Load Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-product/module-product-web/src/main/webapp/WEB-INF/views/admin/product/product_edit.html Executes on document ready. If a product video ID is present (from template variables), it creates a video container using `createdVideoContainer` and inserts it into the `.video` element, then initializes the JPress video player. ```JavaScript $(function () { if ('#(product.video_id ??)' != null && '#(product.video_id ??)' != '' && '#(product.video_id ??)' != undefined) { let videoElement = createdVideoContainer('#(product.video_id ??)', '#(attachmentVideo.cover ??)'); $(".video").html(videoElement.outerHTML); initJPressVideo(); } }); ``` -------------------------------- ### JFTL Display Record Field Value with Null-Safe Operator Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-form/module-form-web/src/main/webapp/WEB-INF/views/admin/form/form_data_excel.html Illustrates how to retrieve and display a specific field's value from a record object in JFinal Template Language. The 'get()' method is used to access the field by its name, and the '??' operator handles potential null values gracefully, preventing runtime errors in the template. ```JFTL #(record.get(field.fieldName) ??) ``` -------------------------------- ### Create Aliyun VOD Player Instance Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/attachment/video_add.html This JavaScript function initializes an Aliplayer instance for playing video-on-demand (VOD) content. It takes a video ID (`vid`), play authentication token (`playauth`), and an optional container ID (`id`) as parameters, configuring the player with specified dimensions and playback options. ```javascript function createVideoPlayer(vid, playauth, id) { if (vid != "" && playauth != "") { id = id || "player" var player = new Aliplayer({ "id": id, "vid": vid, "playauth": playauth, // "qualitySort": "asc", // "format": "mp4", // "mediaType": "video", "width": "100%", "height": "100%", "videoWidth": "100%", "videoHeight": "100%", "autoplay": false, "isLive": false, // "cover": "缩略图", "rePlay": false, "playsinline": true, "preload": false, "controlBarVisibility": "hover", "useH5Prism": true }, function (player) { console.log("The player is created"); }); return player; } } ``` -------------------------------- ### JPress Template Layout and Script Initialization Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-template/src/main/webapp/templates/JPressPortal/article.html This snippet defines the overall page layout using #include and #@layout directives. It also sets up placeholders for CSS and JavaScript, specifically initializing highlight.js for code syntax highlighting. ```JFinal Template #include("./layout.html") #@layout() #define css() #end #define script() hljs.initHighlightingOnLoad(); #end #define content() ``` ```JavaScript hljs.initHighlightingOnLoad(); ``` -------------------------------- ### Define Ret API Response Object Structure and Example Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/development/api/api_article.md This snippet defines the common `Ret` API response object, detailing its `state` and `list` fields. It also provides a comprehensive JSON example illustrating the structure of the `Ret` object, including nested `Article` objects with various properties such as ID, title, author, content, and metadata. ```APIDOC Ret Object: state: String - Status, ok for success, fail for failure list: List
- List of articles ``` ```json { "state":"ok", "list":[ { "id":100, "pid":100, "slug":"slug", "title":"标题", "author":"作者", "content":"内容", "editMode":"编辑模式,默认为html,其他可选项包括html,markdown ..", "summary":"摘要", "linkTo":"连接到(常用于谋文章只是一个连接)", "thumbnail":"缩略图", "style":"样式", "userId":100, "orderNumber":100, "status":"状态", "commentStatus":true, "commentCount":100, "commentTime":"2022-08-30 09:20:32", "viewCount":100, "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "flag":"标识,通常用于对某几篇文章进行标识,从而实现单独查询", "metaTitle":"SEO标题", "metaKeywords":"SEO关键字", "metaDescription":"SEO描述信息", "withRecommend":true, "withTop":true, "withHot":true, "withLeadNews":true, "withAllowSearch":true, "options":"json 扩展", "siteId":100 }, { "id":100, "pid":100, "slug":"slug", "title":"标题", "author":"作者", "content":"内容", "editMode":"编辑模式,默认为html,其他可选项包括html,markdown ..", "summary":"摘要", "linkTo":"连接到(常用于谋文章只是一个连接)", "thumbnail":"缩略图", "style":"样式", "userId":100, "orderNumber":100, "status":"状态", "commentStatus":true, "commentCount":100, "commentTime":"2022-08-30 09:20:32", "viewCount":100, "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "flag":"标识,通常用于对某几篇文章进行标识,从而实现单独查询", "metaTitle":"SEO标题", "metaKeywords":"SEO关键字", "metaDescription":"SEO描述信息", "withRecommend":true, "withTop":true, "withHot":true, "withLeadNews":true, "withAllowSearch":true, "options":"json 扩展", "siteId":100 } ] } ``` -------------------------------- ### Open Video Selection Layer and Process Result Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-product/module-product-web/src/main/webapp/WEB-INF/views/admin/product/product_edit.html Opens a layer (modal) for selecting a video from the admin attachment browser. Upon selection, it retrieves the video's UID, type, and cover, then creates and inserts a video container into the DOM, initializing the JPress video player. ```JavaScript function chooseVideo() { layer.open({ type: 2, title: '选择视频', anim: 2, shadeClose: true, shade: 0.3, area: ['90%', '90%'], content: jpress.cpath + '/admin/attachment/video/browse?uititle=视频', end: function () { if (layer.data.uid != null) { var uid = layer.data.uid; var cloudType = layer.data.type; var cover = layer.data.cover; if (cloudType != null) { let videoContainer = createdVideoContainer(uid, cover); $(".video").html(videoContainer.outerHTML); initJPressVideo(); $("#videoId").val(uid); } } } }); } ``` -------------------------------- ### JavaScript: Configure and Initialize Aliyun VOD Uploader Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/attachment/video_add.html This function creates and configures an Aliyun VOD (Video On Demand) uploader instance. It sets essential parameters such as user ID, region, part size, parallel uploads, and retry logic. Crucially, it defines the 'onUploadstarted' callback, which dynamically fetches or refreshes upload authentication credentials from the backend (via AJAX calls to `doRefreshVideoAuth` or `doGetUploadVideoAuth`) before the upload begins, ensuring secure and authorized uploads. ```JavaScript function createVideoUploader(fileName, title) { var uploader = new AliyunUpload.Vod({ //userID,必填,只需有值即可。 userId: "ACCOUNT.id", //上传到视频点播的地域,默认值为'cn-shanghai', //eu-central-1,ap-southeast-1 region: "cn-beijing", //分片大小默认1 MB,不能小于100 KB,此参数单位默认为 B partSize: 1048576, //并行上传分片个数,默认5 parallel: 5, //网络原因失败时,重新上传次数,默认为3 retryCount: 3, //网络原因失败时,重新上传间隔时间,默认为2秒 retryDuration: 2, //开始上传,需要设置(或者刷新)凭证 'onUploadstarted': function (uploadInfo) { console.log("onUploadStarted:" + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object); if(!title){ title = uploadInfo.file.name; $('#videoTitle').val(uploadInfo.file.name); } if (uploadInfo.videoId) { //需要刷新上传凭证 $.get(jpress.cpath+'/admin/attachment/video/doRefreshVideoAuth?videoId=' + uploadInfo.videoId, function (data) { var uploadAuth = data.UploadAuth var uploadAddress = data.UploadAddress var videoId = data.VideoId uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress, videoId) }, 'json') } else { //获取上传凭证 $.get(jpress.cpath+'/admin/attachment/video/doGetUploadVideoAuth?fileName=' + fileName + '&title=' + title, function (data) { var uploadAuth = data.UploadAuth var uploadAddress = data.UploadAddress var videoId = data.VideoId uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress, videoId) //获取凭证失败 if(data.state == "fail"){ //清除文件选择 $('#videoInputFile').val('') } }, 'json') } } }); return uploader; } ``` -------------------------------- ### JPress Product Page Template Definition Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-template/src/main/webapp/templates/lightlog/product.html This template snippet defines the structure of a product detail page in JPress, leveraging JFinal Template syntax. It includes a base layout, defines empty 'script' and 'css' sections, and a 'content' section. Within the 'content' section, it renders default product header and comment components, and displays the product's main content. ```JFinal Template #include("./layout.html") #@layout() #define script() #end #define css() #end #define content() #@defaultProductHeader() #(product.content) #@defaultProductCommentPage() #end ``` -------------------------------- ### Get Job Category Detail Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/development/api/api_job_category.md Retrieves the detailed information for a specific job category by its ID. The ID is passed as a form-urlencoded parameter. The response includes the full JobCategory object. ```APIDOC Endpoint: /api/job/category/detail Method: GET (Implied) Content-Type: application/x-www-form-urlencoded Request Parameters: - id: Name: 岗位分类ID (Job Category ID) Type: Long Required: No (Note: ID cannot be empty) Submission: * Description: The ID of the job category. Response (Ret): - state: Type: String Description: Status, "ok" for success, "fail" for failure. - detail: Type: JobCategory Description: Detailed information of the job category. JobCategory Object Schema: - id: Type: Long Description: Unique identifier for the category. - type: Type: String Description: Type of the category: category, address. - pid: Type: Long Description: Parent ID of the category. - title: Type: String Description: Category name. - summary: Type: String Description: Brief summary or description of the category. - count: Type: Long Description: Number of jobs associated with this category. - orderNumber: Type: Integer Description: Sorting code for display order. - flag: Type: String Description: An identifier flag. - created: Type: Date Description: Date and time of creation. - modified: Type: Date Description: Date and time of last modification. - siteId: Type: Long Description: The ID of the site this category belongs to. ``` ```json { "state":"ok", "detail":{ "id":100, "type":"分类的类型:category、address", "pid":100, "title":"分类名称", "summary":"摘要", "count":100, "orderNumber":100, "flag":"标识", "created":"2022-08-30 09:20:32", "modified":"2022-08-30 09:20:32", "siteId":100 } } ``` -------------------------------- ### Get User Details API Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/development/api/api_user.md This API retrieves detailed information for a specific user. It requires a user ID and returns the user's full profile, including various personal and account-related fields. ```APIDOC Path: /api/user/detail Data Type: application/x-www-form-urlencoded Request Parameters: id: Long (required) - User ID Response: Ret Ret: state: String - Status, 'ok' for success, 'fail' for failure user: User - User information User: id: Long - Primary Key ID username: String - Login name nickname: String - Nickname realname: String - Real name identity: String - Identity password: String - Password salt: String - Salt anonym: String - Anonymous ID email: String - Email emailStatus: String - Email status (e.g., verified) mobile: String - Mobile phone mobileStatus: String - Mobile status (e.g., verified) gender: String - Gender signature: String - Signature birthday: Date - Birthday company: String - Company occupation: String - Position, occupation address: String - Address zipcode: String - Postal code site: String - Personal website graduateschool: String - Graduate school education: String - Education avatar: String - Avatar idcardtype: String - ID type: ID card, passport, military ID, etc. idcard: String - ID number remark: String - Remarks status: String - Status created: Date - Creation date createSource: String - User source (e.g., OAuth third-party) logged: Date - Last login time activated: Date - Activation time ``` ```JSON { "state":"ok", "user":{ "id":100, "username":"登录名", "nickname":"昵称", "realname":"实名", "identity":"身份", "password":"密码", "salt":"盐", "anonym":"匿名ID", "email":"邮件", "emailStatus":"邮箱状态(是否认证等)", "mobile":"手机电话", "mobileStatus":"手机状态(是否认证等)", "gender":"性别", "signature":"签名", "birthday":"2022-08-30 09:20:32", "company":"公司", "occupation":"职位、职业", "address":"地址", "zipcode":"邮政编码", "site":"个人网址", "graduateschool":"毕业学校", "education":"学历", "avatar":"头像", "idcardtype":"证件类型:身份证 护照 军官证等", "idcard":"证件号码", "remark":"备注", "status":"状态", "created":"2022-08-30 09:20:32", "createSource":"用户来源(可能来之oauth第三方)", "logged":"2022-08-30 09:20:32", "activated":"2022-08-30 09:20:32" } } ``` -------------------------------- ### Product Preview Function Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-product/module-product-web/src/main/webapp/WEB-INF/views/admin/product/product_edit.html A function to trigger product preview. If the current element's href attribute is empty, it calls the `doSubmit` function with `true` to save the product and open the preview window. ```javascript function previewProduce($this){ if(!$this.href){ doSubmit(true); } } ``` -------------------------------- ### JPress Template Variable Display and Loop Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-form/module-form-web/src/main/webapp/WEB-INF/views/admin/form/components/checkbox.html This snippet demonstrates fundamental JPress template syntax for displaying variables with a default fallback and iterating over a collection of items. It showcases how to access properties within the loop. ```JPress Template #(label ??) #for(option : options) #(option.text ??) #end ``` -------------------------------- ### JPress Template Layout and Script Definition Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-template/src/main/webapp/templates/lightlog/article.html Defines the overall page structure by including 'layout.html', sets up empty CSS and content blocks, and includes a JavaScript call to initialize Highlight.js for syntax highlighting within the 'script' block. ```JFinal Template #include("./layout.html") #@layout() #define css() #end #define script() hljs.initHighlightingOnLoad(); #end #define content() ``` -------------------------------- ### Rename JDK Directory on Linux Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/manual/linux_undertow_deploy.md After extraction, this command renames the JDK directory to a simpler name for easier referencing in environment variables. Adjust the original directory name if your JDK version differs. ```Shell mv jdk1.8.0_202 jdk1.8 ``` -------------------------------- ### Initialize Video Uploader and Player on Page Load Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/attachment/video_add.html This `window.onload` function dynamically sets IDs for video input elements based on a `cloudType` value, enabling different upload mechanisms (Aliyun, Tencent, Local). It also initializes a Tencent Cloud Player (TCPlayer) for video playback, either with existing video details (`aid`, `vid`) for editing or as a new player instance. ```javascript window.onload = function() { var cloudType = document.getElementById("cloudType").value; if(cloudType == '1'){ $(".chooseVideoFile").attr("id","videoInputFile"); $(".chooseVideoFileLable").attr("for","videoInputFile"); } else if(cloudType == '2'){ $(".chooseVideoFile").attr("id","tcentVideoInputFile"); $(".chooseVideoFileLable").attr("for","tcentVideoInputFile"); } else if(cloudType == '4'){ document.getElementById("uploader").setAttribute("onclick","uploadLocalVideo()"); } //初始化 //视频 var aid = $("#appId").val(); var vid = $("#vodVid").val(); var player =null; if((aid != null && aid != "") && (vid != null && vid != "") ){ //编辑 player = TCPlayer('player-container-id', { fileID: vid, appID: aid, autoplay: false }); }else{ //新增 player = TCPlayer('player-container-id', {}); } } ``` -------------------------------- ### Delete JPress Article Comment via AJAX Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-article/module-article-web/src/main/webapp/WEB-INF/views/admin/article/comment_list.html This JavaScript function prompts the user for confirmation before sending an AJAX GET request to permanently delete an article comment. It requires the comment's ID as a parameter. ```JavaScript function doDelComment(id) { if (confirm("确定要删除这条评论吗?删除后不可恢复")) { ajaxGet("#(CPATH)/admin/article/comment/doDel?id=" + id) } } ``` -------------------------------- ### JPress Product Display and Pagination Template Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-template/src/main/webapp/templates/calmlog/prolist.html A JFinal template engine snippet demonstrating how to iterate through a list of products, display their images, titles, prices, and sales counts. It also includes links to product details, applies text truncation, and incorporates pagination for product listings. The template integrates with a main layout and a right sidebar. ```JFinal Template #include("./layout.html") #@layout() #define content() #productPage() #for(product : productPage.list) ![](#(product.showImage)) ### [#(product.title ??)] (#\(product.url\)) #maxLength(product.text,100) ¥ #number(product.price) #(product.sales_count ?? 0) 人已购买 [查看宝贝 >](#\(product.url\)) #end #productPaginate() #for(page : pages)* [#(page.text)](#\(page.url ??\)) #end #end #end #include("./_rightbar.html") #end ``` -------------------------------- ### JPress Template for Dynamic Page Listing and Pagination Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-template/src/main/webapp/templates/BonHumeur/pagelist.html This snippet illustrates a JPress template file (likely an HTML template) that dynamically renders a list of single pages and a general list of pages. It includes directives for layout inclusion, content block definition, looping through page data, displaying page attributes like title, creation date, view count, and truncated text, and handling pagination. It also demonstrates linking to page URLs using the template's specific syntax. ```JFinal Template #include("./layout.html") #@layout(true) #define content() #include("header.html") #pageList() #for(page : singlePages.list) [ ### #(page.title ??) #date(page.created) #(page.view\_count) #maxLength(page.text,100) ](#\(page.url ??\)) #end #pagePaginate(firstGotoIndex=true) #for(page : pages)* [#(page.text ??)](#\(page.url ??\)) #end #end #end #end ``` -------------------------------- ### Date Formatting in JPress Enjoy Template Source: https://github.com/jpressprojects/jpress/blob/v5.x/doc/development/template/template_grammar.md Formats and outputs date values. The first example uses a default format ('yyyy-MM-dd HH:mm'), while the second allows specifying a custom format string. ```JFinal Enjoy Template #date(account.createAt) ``` ```JFinal Enjoy Template #date(account.createAt, "yyyy-MM-dd HH:mm:ss") ``` -------------------------------- ### Tencent Cloud Video Upload and Stream Configuration Source: https://github.com/jpressprojects/jpress/blob/v5.x/jpress-web/src/main/webapp/WEB-INF/views/admin/attachment/video_add.html This JavaScript snippet demonstrates how to initiate a video upload to Tencent Cloud using a custom loader, handling success, error, and progress callbacks. Upon successful upload, it also makes an AJAX call to configure adaptive bitrate streaming for the uploaded video. ```javascript loader.start({ videoFile : videoFile, getSignature : getSignature, allowAudio : 1, isTranscode: 1, success : function(result) { // alert("上传成功"); //清除文件选择 $('#tcentVideoInputFile').val('') console.log("上传成功,返回的结果=="+result) }, error : function(result) { alert("上传失败"+result.msg); console.log("上传失败,返回的结果==") console.log(result) }, progress : function(result) { if(result.curr < 1){ $("#videoInputFileLable").text("腾讯云-视频上传中...." + Math.ceil(result.curr * 100) + "% (总大小:" + (videoFile.size / 1024 / 1024).toFixed(2) + "MB)"); }else if(result.curr == 1){ $("#videoInputFileLable").text("腾讯云-视频上传成功!(总大小:" + (videoFile.size / 1024 / 1024).toFixed(2) + "MB)"); } appId = result.cos.appid; // console.log("上传进度:" + result.curr); }, finish : function(result) { //视频id fileId= $("#tcVod").val(result.fileId); $("#vodVid").val(result.fileId); //通过url播放(直播、点播) player.src(result.videoUrl); $.ajax({ //通过任务流设置自适应码流 url : jpress.cpath+"/admin/attachment/video/setTaskStream?"+"fileId="+result.fileId, type : "POST", success : function(result) { console.log("设置自适应码流:"+result); } }); console.log("上传完成,返回的结果:"+result); } }); ``` -------------------------------- ### Change JPress Article Comment Status via AJAX Source: https://github.com/jpressprojects/jpress/blob/v5.x/module-article/module-article-web/src/main/webapp/WEB-INF/views/admin/article/comment_list.html This JavaScript function sends an AJAX GET request to update the status of a specific article comment. It requires the comment's ID and the new status as parameters. ```JavaScript function doChangeStatus(id, status) { ajaxGet("#(CPATH)/admin/article/comment/doChangeStatus?id=" + id + "&status=" + status) } ```