Web page style generation method and device, web page generation method and device
By generating a unique random identity for each component style file and adding it to the page style file, the problem of component style conflict in the prior art is solved, and the individual modification and editing of component styles is realized, and component style conflicts are avoided.
Patent Information
- Application Number
- CN201810525487.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-05-28
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2038-05-28
AI Technical Summary
When the existing page editing system uses the same component on multiple pages or multiple times on the same page, it causes component style conflicts, making it difficult to modify or edit the style of a certain component separately without affecting other pages or components.
Create page style files by generating unique random identifiers for each component style file, adding component style files to the page style file separately, and rendering web pages with the template engine to avoid component style conflicts.
It effectively avoids style conflicts when the same component is used in multiple pages or in the same page, and realizes separate reading and editing of component styles, ensuring that modifying one component does not affect the style of other components.
Smart Images

Figure CN110543298B_ABST
Abstract
Description
Background Art
[0002] With the rapid development of Internet technology, various websites adjust page content according to the needs of various types of promotional activities, or change page style according to content requirements. Therefore, it is necessary to frequently change or edit website pages, such as changes in page layout, page display content and display style.
[0003] To cope with the above situation, most of the existing technologies use page editing systems to implement page editing and modification. Although the existing page editing systems can better meet the needs of page modification, they still have certain defects and deficiencies. For example, when the same component is used in multiple pages and the same component is used multiple times on the same page, when one of the multiple components is modified, multiple components are modified, resulting in component style conflicts.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The purpose of the present disclosure is to provide a web page generation method, a web page generation device, a storage medium and an electronic terminal, thereby overcoming one or more problems caused by limitations and defects of related technologies at least to a certain extent.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0007] According to a first aspect of the present disclosure, a method for generating a web page style is provided, comprising:
[0008] Get the component style files of each component in the page;
[0009] A page style file of the page is created according to each component style file; wherein the page style file includes a plurality of style items, and a style item ID of the style item includes a random identifier.
[0010] In an exemplary embodiment of the present disclosure, creating the page style file of the page according to each component style file includes:
[0011] The component style file path of the component style file corresponding to the component ID;
[0012] Reading the style items in the component style file according to the component style file path, and generating a style item ID for each style item; wherein the style item ID includes a prefix identifier and a random identifier;
[0013] The page style file path is read and a page style entry node is created, and the style entry containing the random identifier is saved to the page style entry node to obtain the page style file.
[0014] In an exemplary embodiment of the present disclosure, when generating a style entry ID for a style entry, the method further includes:
[0015] A component style file ID is generated for the component style file corresponding to the style entry; wherein the component style file ID includes a prefix identifier and a random identifier.
[0016] In an exemplary embodiment of the present disclosure, the random identifier includes a random character string.
[0017] In an exemplary embodiment of the present disclosure, the component style file includes a plurality of style entries, and the random identifiers of the style entries are the same.
[0018] In an exemplary embodiment of the present disclosure, the method further includes:
[0019] Get the modified style entry and the corresponding component style file ID;
[0020] Get the original style entry of the page style file according to the page style file path;
[0021] If the original style entry ID is the same as the component style file ID, the modified style entry replaces the original style entry;
[0022] Add the modified style entry to the entry list of the page style file.
[0023] According to a second aspect of the present disclosure, there is provided a webpage generation method, comprising:
[0024] Get the web page layout and add components according to the layout;
[0025] Create a page template file according to the component template file of each component, and create a corresponding page style file according to the component style file of each component;
[0026] Add a data source and use a template engine to render the page template file and page style file to generate a web page.
[0027] In an exemplary embodiment of the present disclosure, creating a corresponding page style file according to the component style file of each component includes:
[0028] Concatenate the component style file path of the corresponding component style file according to the component ID;
[0029] Reading the style items in the component style file according to the component style file path, and generating a style item ID for each style item; wherein the style item ID includes a prefix identifier and a random identifier;
[0030] The current page style file path is read and a page style entry node is created, and the style entry containing the random identifier is saved to a page style entry interface to obtain the page style file.
[0031] In an exemplary embodiment of the present disclosure, when generating a style entry ID for a style entry, the method further includes:
[0032] A component style file ID is generated for the component style file corresponding to the style entry; wherein the component style file ID includes a prefix identifier and a random identifier.
[0033] In an exemplary embodiment of the present disclosure, adding a data source and using a template engine to render the page template file and the page style file to obtain a web page includes:
[0034] Re-read the style entry of the page style file;
[0035] Traverse the style entries and concatenate CSS strings;
[0036] Insert said CSS string into the Head of the page.
[0037] In an exemplary embodiment of the present disclosure, the method further includes:
[0038] Get the ID of the component to be modified;
[0039] Obtaining, in the page style file, a style entry corresponding to the component to be modified according to the component ID to be modified;
[0040] Add the style entry to the component style entry list of the component to be modified;
[0041] The component style item list of the component to be modified is returned to the browser side for display on the browser side.
[0042] In an exemplary embodiment of the present disclosure, the method further includes:
[0043] Get the modified style entry and the corresponding component style file ID;
[0044] Get the original style entry of the page style file according to the page style file path;
[0045] If the original style entry ID is the same as the component ID, the modified style entry replaces the original style entry;
[0046] The modified style entry is added to the page style entry list.
[0047] According to a fourth aspect of the present disclosure, there is provided a web page style generating device, comprising:
[0048] The component style file acquisition module is used to obtain the component style files of each component in the page;
[0049] The page style file creation module is used to create a page style file of the page according to each component style file; wherein the page style file includes a plurality of style items, and the style item ID of the style item includes a random identifier.
[0050] According to a fourth aspect of the present disclosure, there is provided a webpage generating device, comprising:
[0051] The page layout module is used to obtain the web page layout and add components according to the layout;
[0052] The page creation module is used to create a page template file according to the component template file of each component, and to create a corresponding page style file according to the component style file of each component;
[0053] The web page generation module is used to add a data source and use a template engine to render the page template file and the page style file to generate a web page.
[0054] According to a fifth aspect of the present disclosure, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned web page style generating method and / or web page generating method is implemented.
[0055] According to a fourth aspect of the present disclosure, there is provided an electronic terminal, comprising:
[0056] Processor; and
[0057] A memory, configured to store executable instructions of the processor;
[0058] The processor is configured to execute the above-mentioned web page style generating method and / or web page generating method by executing the executable instructions.
[0059] In a web page style generation method and a web page generation method provided by an embodiment of the present disclosure, a page style file is created according to the component style files of each component in the web page, so that each component style file is added separately to the page style file. In addition, by configuring a unique random identifier for each style entry, it is convenient to read and edit the component style and style entry, thereby effectively avoiding the component style conflict caused by editing or modifying a certain component style file separately when the same component is used multiple times in the same page or the same component is used in multiple pages.
[0060] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0062] Figure 1 A schematic diagram of a method of a template management system in the prior art is schematically shown;
[0063] Figure 2 A schematic diagram of a method of a page decoration system in the prior art is schematically shown;
[0064] Figure 3 A schematic diagram of a web page style generation method in an exemplary embodiment of the present disclosure is schematically shown;
[0065] Figure 4 A flowchart of a component style file loading method in an exemplary embodiment of the present disclosure is schematically shown;
[0066] Figure 5 A flowchart of a method for saving an edited specified component style file in an exemplary embodiment of the present disclosure is schematically shown;
[0067] Figure 6 A schematic diagram schematically illustrates a method for generating a web page in an exemplary embodiment of the present disclosure;
[0068] Figure 7 A schematic diagram schematically illustrates a flow chart of a webpage generation method in an exemplary embodiment of the present disclosure;
[0069] Figure 8 A schematic diagram of a web page layout in an exemplary embodiment of the present disclosure is schematically shown;
[0070] Fig. 9 A component style loading flow chart for editing a specified component style in an exemplary embodiment of the present disclosure is schematically shown;
[0071] Fig.10 A schematic diagram schematically illustrates a web page style generating device in an exemplary embodiment of the present disclosure;
[0072] Fig.11 A schematic diagram schematically illustrates a webpage generating device in an exemplary embodiment of the present disclosure;
[0073] Fig.12 A schematic diagram schematically illustrates an electronic device in an exemplary embodiment of the present disclosure;
[0074] Fig.13 A schematic diagram schematically shows a storage device in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0075] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0076] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0077] There are many page editing systems in the prior art, such as template management systems, page decoration systems, etc. Figure 1 As shown in the figure, the technical principle of the template management system generally includes: using page template files to implement data display logic, operating background to achieve data acquisition, and finally using template engine technology to render data into page template files to generate HTML web pages. Figure 2As shown, the implementation principle of the page decoration system generally includes: the layout and components selected by the user form a page template, and when configuring component data, the data of the corresponding components of the current page template is recorded. When generating an HTML page, the program reads the corresponding data and page template file, and uses the template engine to render it into an HTML page. At the same time, the selected component style path (CSS link) is inserted into the HTML Head to complete the generation of the HTML page.
[0078] Although the existing page editing system can better meet the needs of page modification, it still has certain defects and shortcomings, such as conflicts in the use of the same component on multiple pages, and conflicts in the use of the same component multiple times on the same page. Specifically, when the same component is used on multiple pages, if the user needs to edit the component style of a certain page, the component style file cannot be directly modified because the modification will affect the style of other pages using the component. For example, create page A and page B, both pages use the goods list component goods_list_model; if the style of the component on page B is modified and saved, since page A and page B use the same component style file, the style of the component on page A will also be modified.
[0079] Or when the same component is used multiple times on the same page, if two goods list components goods_list_model are added to a page, when the browser renders the page, the IDs of both components are goods_list_model, and the corresponding style node identifiers are also goods_list_model. When modifying the style of a component, since the style nodes of the two components are saved in the template style file with the same identifier, when modifying the style of one component, the style of the other component will also be modified, resulting in component style conflicts.
[0080] This example implementation first provides a web page style generation method, which can be applied to the editing of web page style files. Figure 3 As shown in , the above web page style generation method may include the following steps:
[0081] S101, obtaining component style files of each component in the page;
[0082] S102, creating a page style file of the page according to each component style file; wherein the page style file includes a plurality of style items, and a style item ID of the style item includes a random identifier.
[0083] In the web page style generation method provided in this example implementation, by creating a page style file based on the component style files of each component in the web page, each component style file is added to the page style file separately, which facilitates the reading and editing of the component style. In addition, by configuring a unique random identifier for each style entry, it is effectively avoided that when the same component is used multiple times in the same page or the same component is used in multiple pages, a component style conflict is caused by editing or modifying a certain component style file or style entry separately.
[0084] The following will describe in more detail the steps of the web page style generation method in this example implementation with reference to the accompanying drawings and embodiments.
[0085] Step S101, obtaining the component style file of each component in the page.
[0086] In this example implementation, for a web page, developers generally lay out the page according to actual needs and add components according to the layout. For each component in the page, each component can correspond to a component template file and a component style file. Among them, the component template file consists of HTML (Hyper Text Markup Language) and Freemarker tags, which mainly implements how to render component data and the HTML structure of data presentation.
[0087] For example, the above components can be a product list component, a product category component, or a carousel component. The name of each component can be a unique prefix identifier consisting of one or more of numbers, uppercase and lowercase letters, and underscores, and corresponds to the corresponding component style name one by one. For example, if the name of the product component is "goods_list_model", the name of its component template file can be "goods_list_model.tpl".
[0088] Each component also corresponds to a component style file, which can be used to define the CSS style (Cascading Style Sheets) of the component's page rendering. The storage format can be XML (eXtensible Markup Language), JSON (JavaScript Object Notation) or other formats. Each style can be composed of a prefix qualified name corresponding to the component name and a style selector, and is composed of an XML node or a JSON object. For example, the name of the component style file of the product component can be "goods_list_model.xml".
[0089] By setting the component style file to use the XML format or JSON format CSS style, since XML or JSON is structured data, there are many parsing tools that can effectively solve the problem of program reading and writing styles, thus making it easy to edit the style.
[0090] S102: Create a page style file of the page according to each component style file.
[0091] In this example implementation, when creating a new web page, a page template file may be created for the new page; at the same time, a new page style file may also be created based on the component style files of the components laid out in the page. Specifically, the above step S102 may include:
[0092] S1021, concatenating the component style file path of the corresponding component style file according to the component ID;
[0093] S1022, reading a style entry in the component style file according to the component style file path, and generating a style entry ID for each style entry; wherein the style entry ID includes a prefix identifier and a random identifier;
[0094] S1023, reading the page style file path and creating a page style entry node, saving the style entry containing the random identifier to the page style entry node to obtain the page style file.
[0095] refer to Figure 4 As shown, after adding components according to the page layout, the developer can upload the selected component ID to the server through the front-end JavaScript script, and the server can splice the component style file path according to the component ID. After reading each style entry of the component style file node, a random identifier can be generated. At this time, the style entries of the component can be traversed, and the random identifier can be added after the prefix identifier of each style entry to generate a style entry ID containing a random identifier for each style entry. In addition, an underscore can be added between the prefix identifier and the random identifier to distinguish the two parts of the identifier. At this time, due to different random identifiers, style entries in different components have different file names. Then read the page style file path, create a style entry node, and save the style entries with random identifiers in the page style file in sequence.
[0096] For example, the random identifier may be a random string of a certain length, or a random string of a random length. The random string may be a simple number, a simple letter, or a combination of numbers and letters. Of course, in other examples of the present disclosure, the above-mentioned random string may also contain special characters such as operation symbols, and the present disclosure does not specifically limit the composition form of the random string.
[0097] Specifically, the name of the style entry can be composed of a component unique prefix identifier plus a random string identifier. For example, a style file stored in XML format can be:
[0098] <css id=”goods_list_model_s8f3xj1uq1”>
[0099] <cssname> #goods_list_model_s8f3xj1uq1.title< / cssname>
[0100] <csscontent> {width:300px; height:30px;}< / csscontent>
[0101]
[0102] By adding different random strings to style entries in different components, each component and its corresponding component style entry has a different name, which can effectively distinguish the same component and its corresponding style entry used multiple times in the same page. When modifying or editing page style files, you can also distinguish them based on the random string, thereby effectively avoiding component style conflicts in the same page.
[0103] For example, a page contains two goods list components goods_list_model. When creating a page style file, the first goods component list is named goods_list_model_98suw3j9 after adding a random string, and the identifier of its corresponding style entry is also goods_list_model_98suw3j9. The second goods component list is named goods_list_model_56eg39jd after adding a random string, and the identifier of its corresponding style entry is also goods_list_model_56eg39jd; thereby achieving the distinction between the two goods list components. When a certain goods component list needs to be edited, it can be distinguished based on the random string after the prefix identifier. This effectively avoids the situation where another component is also edited when one goods list component is edited, thereby avoiding style conflicts caused by multiple uses of the same component on the same page.
[0104] Based on the above, in other exemplary embodiments of the present disclosure, when a style entry ID is generated for a style entry, a component style file ID may also be generated for the component style file corresponding to the style entry; wherein the component style file ID includes a prefix identifier and a random identifier. That is, the component style file of each component and the style entry corresponding to the component style file may have the same random identifier. Alternatively, different style entries within a component may also have different random identifiers, which can also be used to distinguish between multiple identical components on the same page.
[0105] In addition, in an exemplary embodiment, the webpage style generation method may further include:
[0106] Step S111, obtaining the modified style entry and the corresponding component style file ID;
[0107] Step S112, obtaining the original style entry of the page style file according to the page style file path;
[0108] Step S113, if the original style entry ID is the same as the component style file ID, then the modified style entry replaces the original style entry;
[0109] Step S114, adding the modified style entry to the entry list of the page style file.
[0110] In this example implementation, reference Figure 5 As shown, when developers edit a specified component style, after modifying the style entry, they can use the front-end JavaScript script to upload the modified style entry and the edited component ID to the server. After reading the style entry of the current page style file, the server traverses the style entry, uses the prefix identifier and random identifier to obtain the original style entry corresponding to the component ID identifier, and deletes these original style entries. The uploaded modified component style entry is then constructed into a style entry in XML format or JSON format, appended to the list of all style entries, and saved to the page style file. The modified style entry replaces the original style entry to implement the editing of the page style. Then, all style entries can be traversed again and spliced into a CSS string with a CSS syntax structure. When the template engine renders the page, it is inserted into the Head of the HTML page to complete the loading of the page style.
[0111] Furthermore, this example embodiment also provides a method for generating a web page, referring to Figure 6 As shown, the web page generation method shown includes:
[0112] S201, obtaining the web page layout and adding components according to the layout;
[0113] S202, creating a page template file according to the component template file of each component, and creating a corresponding page style file according to the component style file of each component;
[0114] S203, adding a data source and using a template engine to render the page template file and the page style file to generate a web page.
[0115] The following will describe in more detail the steps of the webpage generation method in this example implementation with reference to the accompanying drawings and embodiments.
[0116] Step S201, obtaining the web page layout and adding components according to the layout.
[0117] In this example implementation, the developer can first create a page, and then lay out the page according to the requirements of the web page and the content of the web page, and determine the page layout according to the layout. Figure 8 As shown, the developer can divide the page into blocks and define the functions that each block needs to implement, such as defining the functions of the block as a product list, an advertisement carousel, or a category navigation bar, etc. The present disclosure does not specifically limit the specific content of the web page layout.
[0118] After determining the page layout, you can add corresponding components according to the functions of each block in the page layout.
[0119] Step S202: creating a page template file according to the component template file of each component, and creating a corresponding page style file according to the component style file of each component.
[0120] In this example implementation, specifically, as described above, each component may correspond to a component template file and a component style file. The component template file may be composed of HTML (Hyper Text Markup Language) and Freemarker tags, and is mainly used to implement the HTML structure of rendering component data and data presentation. In addition, each component may also correspond to a component style file, which may be used to define the CSS style (Cascading Style Sheets) of the page rendering of the component.
[0121] refer to Figure 7 As shown, when a page is created, a page template file will be created. The page template file can be composed of the layout HTML structure and the component file path code included in the Freemarker include tag. For example: <#include " / xxxx / model / goods_list_model.tpl" / >; when the web page is accessed on the browser side, the template engine renders it into an HTML page and displays it on the browser interface.
[0122] At the same time, a page style file will also be created, which can be composed of style content corresponding to the selected component.
[0123] Specifically, creating a corresponding page style file based on the component style file may include:
[0124] Step 201, concatenate the component style file path of the corresponding component style file according to the component ID;
[0125] Step 202, reading the style items in the component style file according to the component style file path, and generating a style item ID for each style item; wherein the style item ID includes a prefix identifier and a random identifier;
[0126] Step 203, read the current page style file path and create a page style entry node, save the style entry containing the random identifier to the page style entry interface to obtain the page style file.
[0127] refer to Figure 6 As shown, after adding components according to the page layout, the developer can upload the selected component ID to the server through the front-end JavaScript script, and the server will splice the component style file path according to the component ID. After reading each style entry of the component style file node, a random identifier can be generated. At this time, the style entries of the component can be traversed, and a random identifier can be added after the prefix identifier of each style entry to generate a style entry ID. In addition, an underscore can be added between the prefix identifier and the random identifier to distinguish the two parts of the identifier. At this time, due to different random identifiers, the style entries in different components have different file names. Then read the current template style file path, create a style entry node, and save the style entries with random identifiers to the page style file in sequence.
[0128] For example, the random identifier may be a random string of a certain length, or a random string of a random length. The random string may be a simple number, a simple letter, or a combination of numbers and letters. Of course, in other examples of the present disclosure, the above-mentioned random string may also contain special characters such as operation symbols, and the present disclosure does not specifically limit the composition form of the random string.
[0129] For example, each style block consists of a unique component prefix identifier plus a random string identifier. By adding different random strings to style items in different components, you can effectively distinguish the same components and corresponding style items used multiple times in the same page. When modifying or editing page style files, you can distinguish them based on the random string, thereby effectively avoiding component style conflicts in the same page.
[0130] For example, a page contains two goods list components goods_list_model. When creating a page style file, the first goods component list is named goods_list_model_98suw3j9 after adding a random string, and the identifier of its corresponding style entry is also goods_list_model_98suw3j9. The second goods component list is named goods_list_model_56eg39jd after adding a random string, and the identifier of its corresponding style entry is also goods_list_model_56eg39jd; thereby achieving the distinction between the two goods list components. When a certain goods component list needs to be edited, it can be distinguished based on the random string after the prefix identifier. This effectively avoids the situation where another component is also edited when one goods list component is edited, thereby avoiding style conflicts caused by multiple uses of the same component on the same page.
[0131] Based on the above, in other exemplary embodiments of the present disclosure, when a style entry ID is generated for a style entry, a component style file ID may also be generated for the component style file corresponding to the style entry; wherein the component style file ID includes a prefix identifier and a random identifier. That is, the component style file and the corresponding style entry may have the same random identifier. Alternatively, different style entries within a component may also have different random identifiers, which may also achieve the distinction between multiple identical components in the same page.
[0132] Step S203, adding a data source and using a template engine to render the page template file and the page style file to generate a web page.
[0133] In this example implementation, reference Figure 7 As shown, after creating a complete page template file 411 according to the page layout 401 and each component template file 402, and creating a page style file 412 according to the component style file 403 and configuring the data source 413, the template engine 420 can be used for rendering to generate an HTML page 40. For example, the Fast Template template engine, the Heyes Template Class template engine, etc. are used.
[0134] For page style files, refer to Figure 4 As shown, after the style entry containing the random identifier in the style entry ID is saved to the page style file, the style entry of the page style file can be re-read; then each style entry is traversed and spliced into a CSS string with a CSS syntax structure; when the template engine renders the page, the CSS string is inserted into the Head of the page to complete the loading of the page style.
[0135] By creating a page style file separately when creating a page, and adding component styles to the page style file, and each style block consists of a component unique prefix identifier and a random identifier, a component style file is added separately to each page style file. This is equivalent to the page style file only storing a "copy" of the component style, so that when modifying the page style, only the "copy" of the current page is modified without affecting the style file of the component itself, thereby effectively avoiding page conflicts caused by the same component being used on multiple pages at the same time.
[0136] In addition, in other exemplary embodiments of the present disclosure, the webpage generation method may further include:
[0137] S211, obtaining the ID of the component to be modified;
[0138] S212, obtaining, in the page style file, a style entry corresponding to the component to be modified according to the component ID to be modified;
[0139] S213, adding the style entry to the component style entry list of the component to be modified;
[0140] S214: Return the component style item list of the component to be modified to the browser side for display on the browser side.
[0141] refer to Fig. 9 As shown, when modifying or editing a component in a page and a corresponding specified component style entry, the style entry ID can be sent to the server backend according to the trigger operation of the user on the browser side. After receiving the style entry ID to be modified, the server side can read the page style file of the web page and traverse the style entries, add the component style entry corresponding to the component ID to be modified to the list of component style entries to be modified, and then return to the browser, which is parsed by the front-end JavaScript and displayed in the user's browser interface, so that the user can modify and edit the component style on the browser side.
[0142] After editing the above components to be modified, refer to Figure 5As shown, the front-end JavaScript script can be used to upload the modified style entries and edited component IDs to the server. After reading the style entries of the current page style file, the server traverses the style entries, uses the prefix identifier and the random identifier to obtain the original style entries corresponding to the component ID identifier, and deletes these original style entries. The uploaded modified component style entries are then constructed into style entries in XML format or JSON format, appended to the list of all style entries, and saved to the page style file. The modified style entries replace the original style entries to edit the page style. Then, all style entries can be traversed again and spliced into a CSS string with a CSS syntax structure. When the template engine renders the page, it is inserted into the Head of the HTML page to complete the loading of the page style.
[0143] The webpage generation method provided by the present disclosure uses component style files to generate page style files separately, and uses XML format or JSON format to separately store component styles and page style files, thereby realizing the function of being able to modify or edit each component in the page component style separately, thereby effectively solving the problem of style conflicts caused by the same component when used on multiple pages. In addition, by limiting the component style by using a unique prefix identifier plus a random identifier, the problem of style conflicts that occur when the same component in the same page is configured with different styles can be effectively solved.
[0144] It should be noted that the above figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0145] For further reference, Fig.10 As shown, in the embodiment of this example, a web page style generating device 20 is also provided, including: a component style file obtaining module 201 and a page style file creating module 202. Among them:
[0146] The component style file acquisition module 201 can be used to acquire the component style file of each component in the page.
[0147] The page style file creation module 202 can be used to create a page style file of the page according to each component style file; wherein the page style file includes a plurality of style items, and the style item ID of the style item includes a random identifier.
[0148] The specific details of each module in the above-mentioned web page style generating device have been described in detail in the corresponding web page style generating method, so they will not be repeated here.
[0149] For further reference, Fig.11 As shown, in the implementation of this example, a webpage generation device 21 is also provided, including: a page layout module 211, a page creation module 212 and a webpage generation module 213. Among them:
[0150] The layout module 211 may be used to obtain a web page layout and add components according to the layout.
[0151] The page creation module 212 can be used to create a page template file according to the component template file of each component, and to create a corresponding page style file according to the component style file of each component.
[0152] The web page generation module 213 can be used to add a data source and use a template engine to render the page template file and the page style file to generate a web page.
[0153] The specific details of each module in the above-mentioned web page generating device have been described in detail in the corresponding web page generating method, so they will not be repeated here.
[0154] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0155] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0156] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".
[0157] Refer to the following Fig.12 The electronic device 600 according to this embodiment of the present invention is described. Fig. 9 The electronic device 600 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0158] like Fig.12As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610).
[0159] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 610 can perform the following steps: Figure 3 Step S101 shown in FIG. 101: obtaining component style files of each component in the page; Step S102: creating a page style file of the page according to each component style file; wherein the page style file includes a plurality of style entries, and the style entry ID of the style entry includes a random identifier. Alternatively, the processing unit 610 may execute as follows Figure 6 Step S211 shown in: obtaining the web page layout and adding components according to the layout; step S212, creating a page template file according to the component template file of each component, and creating a corresponding page style file according to the component style file of each component; step S213, adding a data source and using a template engine to render the page template file and page style file to generate a web page.
[0160] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0161] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0162] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0163] The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 660. As shown, the network adapter 660 communicates with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0164] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0165] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.
[0166] refer to Fig.13 As shown, a program product 800 for implementing the above method according to an embodiment of the present invention is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0167] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0168] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0169] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0170] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0171] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0172] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0173] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A web page style generation method, characterized in that: include: Get the component style file of the component in the page; Creating a page style file of the page according to the component style file; wherein the page style file includes a plurality of style items, and the style item ID of the style item includes a random identifier; The step of creating the page style file of the page according to the component style file includes: Concatenate the component style file path of the corresponding component style file according to the component ID; Reading the style entries in the component style file according to the component style file path, and generating a style entry ID for each style entry; wherein the style entry ID includes a prefix identifier and a random identifier, and the random identifier includes a random character string; Reading a page style file path and creating a page style entry node, saving a style entry containing the random identifier to the page style entry node to obtain the page style file; The method further comprises: Get the modified style entry and the corresponding component style file ID; Get the original style entry of the page style file according to the page style file path; If the original style entry ID is the same as the component style file ID, the modified style entry replaces the original style entry; Add the modified style entry to the entry list of the page style file.
2. The web page style generation method according to claim 1, characterized in that: When generating a style item ID for each style item, the method further includes: A component style file ID is generated for the component style file corresponding to the style entry; wherein the component style file ID includes a prefix identifier and a random identifier.
3. The web page style generation method according to claim 1, characterized in that: The component style file includes a plurality of style entries, and the random identifiers of the style entries are the same.
4. A web page generation method, characterized in that: include: Get the web page layout and add components according to the layout; Create a page template file according to the component template file of each component, and create a corresponding page style file according to the component style file of each component; Add a data source and use a template engine to render the page template file and the page style file to generate a web page; The step of creating a corresponding page style file according to the component style file of each component includes: Concatenate the component style file path of the corresponding component style file according to the component ID; Reading a style entry in the component style file according to the component style file path, and generating a style entry ID for each style entry; wherein the style entry ID includes a prefix identifier and a random identifier, and the random identifier includes a random character string; Reading the page style file path and creating a page style entry node, saving the style entry containing the random identifier to the page style entry interface to obtain the page style file; The method further comprises: Get the modified style entry and the corresponding component style file ID; Get the original style entry of the page style file according to the page style file path; If the original style entry ID is the same as the component ID, the modified style entry replaces the original style entry; The modified style entry is added to the page style entry list.
5. The webpage generation method according to claim 4, characterized in that: When generating a style item ID for each style item, the method further includes: A component style file ID is generated for the component style file corresponding to the style entry; wherein the component style file ID includes a prefix identifier and a random identifier.
6. The webpage generation method according to claim 4, characterized in that: The adding of the data source and using the template engine to render the page template file and the page style file to obtain a web page includes: Re-read the style entry of the page style file; Traverse the style entries and concatenate CSS strings; Insert said CSS string into the Head of the page.
7. The webpage generation method according to claim 4, characterized in that: The method further comprises: Get the ID of the component to be modified; Obtaining, in the page style file, a style entry corresponding to the component to be modified according to the component ID to be modified; Add the style entry to the component style entry list of the component to be modified; The component style item list of the component to be modified is returned to the browser side for display on the browser side.
8. A web page style generating device, characterized in that: include: The component style file acquisition module is used to obtain the component style files of the components in the page; A page style file creation module, used to create a page style file of the page according to the component style file; wherein the page style file includes a plurality of style items, and the style item ID of the style item includes a random identifier; The step of creating the page style file of the page according to the component style file includes: splicing the component style file path of the corresponding component style file according to the component ID; reading the style entry in the component style file according to the component style file path, and generating a style entry ID for each style entry; wherein the style entry ID includes a prefix identifier and a random identifier, and the random identifier includes a random character string; reading the page style file path and creating a page style entry node, and saving the style entry including the random identifier to the page style entry node to obtain the page style file; The device is also used to obtain the modified style entry and the corresponding component style file ID; The original style entry of the page style file is obtained according to the page style file path; if the original style entry ID is the same as the component style file ID, the modified style entry replaces the original style entry; and the modified style entry is added to the entry list of the page style file.
9. A web page generating device, characterized in that: include: The page layout module is used to obtain the web page layout and add components according to the layout; A page creation module, used to create a page template file according to the component template file of each component, and to create a corresponding page style file according to the component style file of each component; A web page generation module, used to add a data source and use a template engine to render the page template file and the page style file to generate a web page; The step of creating a corresponding page style file according to the component style file of each component includes: concatenating the component style file path of the corresponding component style file according to the component ID; reading the style entry in the component style file according to the component style file path, and generating a style entry ID for each style entry; wherein the style entry ID includes a prefix identifier and a random identifier, and the random identifier includes a random character string; reading the page style file path and creating a page style entry node, and saving the style entry including the random identifier to the page style entry interface to obtain the page style file; The device is also used to obtain the modified style entry and the corresponding component style file ID; The original style entry of the page style file is obtained according to the page style file path; if the original style entry ID is the same as the component ID, the modified style entry replaces the original style entry; and the modified style entry is added to the page style entry list.
10. A storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method for generating a web page style according to any one of claims 1 to 3 and / or the method for generating a web page according to any one of claims 4 to 7 is implemented.
11. An electronic terminal, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the web page style generating method according to any one of claims 1 to 3, or the web page generating method according to any one of claims 4 to 7 by executing the executable instructions.
Citation Information
Patent Citations
Component implementation technology for automatically generating dynamic web page on line in real time
CN101526942A
Method and system for page generation
CN106682120A
Page generation method and device
CN106980508A
Conditionally controlled styling
CN107408105A
Loading method and device of page component, medium and terminal device
CN107665134A
