Disclosure of Invention
In view of the above, the embodiment of the invention provides a method and a device for generating a page, which can divide the page into a plurality of page components, select corresponding page components to generate page templates according to different service requirements, automatically acquire the page templates and the corresponding page components to generate page texts and render the generated page when receiving a request for generating a service page, wherein the page components can be provided by a third party, therefore, the page components can be provided by a plurality of third parties according to a plurality of service configurations, each page template is provided with a plurality of independent page components, the modularization degree and the configurability of the page are improved, the flexibility and the expansibility of the generated page are improved, and the problem of low development efficiency caused by high page coupling is solved.
In order to achieve the above object, according to one aspect of an embodiment of the present invention, there is provided a method for generating a page, which is characterized by comprising receiving a request for generating a page, the request including at least a service identifier, acquiring a page template corresponding to the service identifier and a storage address of a page component included in the page template according to the service identifier, the page component including a common component and a service component, generating a page text according to the page template and the storage address of the page component by using a template engine, and transmitting the page text to a client, wherein the client renders the page according to the page text.
Optionally, the method for generating the page is characterized in that before acquiring the page template corresponding to the service identifier and the storage address of the page component contained in the page template according to the service identifier:
And selecting a corresponding page component from a set page component set according to the page layout corresponding to the service identifier, generating the page template corresponding to the service identifier, and determining the storage address of the page component contained in the page template.
Optionally, the method for generating the page is characterized in that the page component comprises a public component and a service component, and further comprises the steps that the public component belongs to one or more services and is arranged in the page template corresponding to the service identification of the one or more services, and the service component belongs to the page template corresponding to the service identification.
Optionally, the method for generating the page is characterized in that the page component comprises a public component and a business component, and further comprises the business component provided by the business component for a third party.
Optionally, the method for generating the page is characterized in that the page component is a JavaScript file.
Optionally, the method for generating the page is characterized in that a template engine is utilized to generate page text according to the page template and the storage addresses of the page components, and the method comprises the steps of acquiring the storage addresses of one or more page components associated with the page template, and writing the storage addresses into a set label range of the page template by utilizing the template engine to generate the page text.
In order to achieve the above object, according to a second aspect of the embodiment of the present invention, there is provided an apparatus for generating a page, which is characterized by comprising a request receiving module, a template obtaining module, and a page generating module, wherein,
The receiving request module is used for receiving a request for generating a page, and the request at least comprises a service identifier;
The acquisition template module is used for acquiring a page template corresponding to the service identifier and a storage address of a page component contained in the page template according to the service identifier, wherein the page component contains a public component and a service component.
The page generation module is used for generating page texts according to the page templates and the storage addresses of the page components by using a template engine, and sending the page texts to a client so that the client renders pages according to the page texts.
Optionally, the device for generating the page is further characterized by comprising a template acquisition module, configured to, before acquiring the page template corresponding to the service identifier and the storage address of the page component included in the page template according to the service identifier, select, according to the page layout corresponding to the service identifier, a corresponding page component from a set page component set to generate the page template corresponding to the service identifier, and determine the storage address of the page component included in the page template.
In order to achieve the above object, according to a third aspect of the embodiments of the present invention, there is provided an electronic device for generating a page, which is characterized by comprising one or more processors, and storage means for storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement the method as in any one of the methods for generating a page described above.
To achieve the above object, according to a fourth aspect of the embodiments of the present invention, there is provided a computer-readable medium having stored thereon a computer program, characterized in that the program, when executed by a processor, implements a method as described in any one of the above methods of generating pages.
The embodiment of the invention has the advantages that the page can be divided into a plurality of page components, the corresponding page components are selected to generate the page templates according to different service demands, when a request for generating the service page is received, the page templates and the corresponding page components are automatically acquired, the page text is generated, and the page is further rendered and generated, wherein the page components can be provided by a third party, therefore, the page components correspond to the plurality of page templates according to the plurality of service configurations, each page template is provided with a plurality of independent page components, the modularization degree and the configurability of the page are improved, the flexibility and the expansibility of the generated page are improved, and the problem of lower development efficiency caused by concentrated development is solved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
As shown in fig. 1, an embodiment of the present invention provides a method for generating a page, which may include the following steps:
Step S101, receiving a request for generating a page, wherein the request at least comprises a service identifier.
Specifically, the service identifier indicates different services, wherein the services show related information through a page and interact with a user, for example, in a page of an electronic mall application, a selling service, a leasing service, a purchasing service, a second-hand service and the like are provided for the same article, the service identifier of the selling service (for example, service_hole_111), the service identifier of the leasing service (for example, service_release_123), the service identifier of the purchasing service (for example, service_share_666) and the service identifier of the second-hand service (for example, service_used_999) are respectively set, and the specific form and content of the service identifier are not limited. Further, a request to generate a page is received, such as generating an item sales page based on a sales service identifier included in the received request, generating an item rental page based on a rental service identifier included in the received request, generating a purchase page based on a purchase service identifier included in the received request, and generating an item second-hand sales page based on a second-hand service identifier included in the received request.
The invention does not limit the specific form and content of the service identifier, further, the request for generating the page can also contain the item identifier or the user identifier displayed by the page, and the invention does not limit the specific form and the specific content of the request for generating the page.
Step S102, according to the service identification, a page template corresponding to the service identification and a storage address of a page component contained in the page template are obtained, wherein the page component contains a public component and a service component.
Before a page template corresponding to a service identifier and a storage address of a page component contained in the page template are acquired according to the service identifier, selecting a corresponding page component from a set page component set according to a page layout corresponding to the service identifier to generate the page template corresponding to the service identifier, and determining the storage address of the page component contained in the page template. The set page component set comprises page components related to pages, wherein the page components are pages of one article in electronic mall application, the related page components can comprise an article title component, an article picture component, an article detail component, an article logistics component, an article lease service component, an article purchase component and the like, further, corresponding components are selected according to service identifications, for example, the article title component, the article picture component, the article detail component, the article logistics component, the article purchase service component and the like can be selected on the assumption that the service identifications indicate the purchase service, and an independent data and service module can be formed according to the page layout of the purchase service, for example, the article title component, the article picture component, the article detail component, the article lease service component can be selected according to the page layout of the purchase service, the page template can be in an HTML (hypertext markup language, hyperText Markup Language, HTML) format, namely, the page template can be in an HTML format, the page is a page (including an HTML format of a page tag of < tag "< 10 </item > < 60 > < tag" > < 10 </item > < 60 </item > < tag ">, and a page tag" > < 60 </item > < tag "> < 10 > < tag" >, and a page tag "> < tag" >. The specific content contained in the page template is not limited by the invention.
Further, the page component includes a control required by the page and data source information corresponding to the control, and packages according to the control and the corresponding data source to generate a file, and preferably, the generated JavaScript file is uploaded to a CDN server (CDN, content Delivery Network, i.e., a content delivery network), that is, the page component is a JavaScript file, where one JavaScript file may be generated by one page component, or one JavaScript file may be generated by a plurality of page components (e.g., multiple common components are packaged to generate one JavaScript file).
Further, the generated JavaScript file path (i.e. the storage address of the JavaScript file) is stored, that is, the page template corresponding to the service identifier and the storage address of the page component contained in the page template are obtained according to the service identifier, wherein the storage address is, for example, "// cdn-shop.abcd.com/test/couponPaid.js", and the storage address is further represented in the page template in the format of HTML, as shown in the following example:
<scriptsrc=“//cdn-shop.abcd.com/test/couponPaid.js”></script>
Further, the page component includes a common component and a business component. The common component can become a part of page templates of a plurality of businesses, for example, the article title component and the article picture component can be contained in the page templates of the article purchase business or the page templates of the article lease business. It is understood that the common components are preferably different services of the same class of objects or different specifications of the same object, the same part is extracted from the multiple page design layouts and divided into the components, and the granularity of the components is preferably controlled, and it is understood that the smaller the granularity of the components is, the more flexible the components are in forming the page. That is, the common component belongs to one or more services and is set in the page template corresponding to the service identifier of the one or more services. Further, each component can be developed based on Vue (Vue is a set of progressive JavaScript frames used for constructing a user interface), and a data source corresponding to each component is a database of data required by a stored page component.
The business components are different parts in each page template, for example, an article purchase business component and an article lease business component of the same article are examples of business components, the article purchase business component belongs to a purchase business page template, the article lease business component belongs to a lease business page template, namely, the business components belong to the page templates corresponding to the business identifications. Further, the business component can be developed and provided by a third party, for example, a company B develops a business component C according to a page component development specification formulated by the company A and provides a JavaScript file (for example, c.js) of the page component to the company A, the company A uploads the c.js to a CDN, and the company B is a third party of the company A, wherein the third party obtains a specification text of the page component, for example, the specification comprises a page interface specification, a development framework specification, an interface parameter specification and the like, the page component developed by the third party is operated by associating a data object related to the page (for example, a value and assignment operation) with a local component by utilizing a bidirectional binding and message mechanism of a Vue framework, and it can be understood that the process of uploading to the CDN is the same for a public component and the business component, the business component can be developed by an internal development team of the enterprise by dividing the page into the business component, and the page development and the flexibility and the development efficiency of the page development can be improved by the third party.
Further, the method for selecting the corresponding page component to generate the page template corresponding to the service identifier from the set page component sets can use a visual configuration page template tool, wherein the tool comprises a list of page component sets, the page template corresponding to the service identifier is generated by selecting the page component related to the service from the list, when a newly added page component is added to the page component sets or deleted from the page component sets, the visual configuration page template tool can be used for operation, so that the complexity of increasing or decreasing page components from the page templates is reduced, and it can be understood that when the page components contained in the page templates are changed (increased or decreased), the data corresponding to the page templates are correspondingly updated in a database to ensure that the generated page is an updated page when the page is rendered according to the data of the page templates, and the data of each page component contained in the page templates is stored.
Step S103, generating a page text by using a template engine according to the page template and the storage address of the page component, sending the page text to a client, and rendering a page by the client according to the page text.
Specifically, the template engine can adopt a speed, the speed is generated by separating the user interface from the business data content, the template engine can generate text in a specific format, for example, the template engine can generate text in an HTML format, further, a page text is generated by acquiring a page template and storage addresses stored in JavaScript files of all page components contained in the page template, wherein the page text is the text in the HTML format, further, the page text is sent to a client, and the client renders the page according to the HTML text by utilizing a browser to display the page to a user.
Further, the storage addresses of one or more page components associated with the page template are obtained, and the storage addresses are written into the set label range of the page template by using a template engine to generate the page text. For example, the storage address of the page component (JavaScript file) is written into a set tag range of a page template (HTML format), for example, the set tag is < head > </head >, < head > is a start identifier of the tag range, and < head > is an end identifier of the tag range, that is, the set tag range is used for being acquired by a browser executing rendering pages. Preferably, the generated page text is stored in a server, and when a request for generating a page is received, a page template corresponding to a service identifier contained in the request is sent so that the client can render the page into a page through a browser of the client and display the page to a user.
As shown in fig. 2, an embodiment of the present invention provides a method for generating a page, which may include the following steps:
Step S201, selecting a corresponding page component from a set page component set according to a page layout corresponding to a service identifier, generating a page template corresponding to the service identifier, and determining a storage address of the page component contained in the page template.
Specifically, the description of generating the page template according to the page component is consistent with the description of step S102, and will not be described herein again, i.e., the page component includes a common component and a service component. The public components belong to one or more businesses and are arranged in the page templates corresponding to the business identifications of the one or more businesses, and the business components belong to the page templates corresponding to the business identifications. The service component is a service component provided by a third party. The page component is a JavaScript file.
Step S202, acquiring a page template corresponding to a service identifier and a storage address of a page component contained in the page template according to the service identifier, wherein the page component contains a public component and a service component, generating a page text according to the page template and the storage address of the page component by using a template engine, transmitting the page text to a client, and rendering the page according to the page text by the client.
Specifically, the specific description of acquiring the page template and the storage address of the page component corresponding to the service identifier is consistent with the description of step S102, which is not described herein.
The specific description of generating the page text by using the template engine is consistent with the description of the step S103, which is not repeated herein, that is, the storage addresses of one or more page components associated with the page template are acquired, and the storage addresses are written into the set label range of the page template by using the template engine to generate the page text.
As shown in fig. 3, an embodiment of the present invention provides an apparatus 300 for generating a page, including a receiving request module 301, an obtaining template module 302, and a generating page module 303, where,
The receiving request module 301 is configured to receive a request for generating a page, where the request at least includes a service identifier;
The obtaining template module 302 is configured to obtain, according to the service identifier, a page template corresponding to the service identifier, and a storage address of a page component included in the page template, where the page component includes a public component and a service component.
The page generating module 303 is configured to generate a page text according to the page template and the storage address of the page component by using a template engine, and render a page according to the page text.
Optionally, the obtaining template module 302 is further configured to, before obtaining, according to the service identifier, a page template corresponding to the service identifier and a storage address of a page component included in the page template, select, according to a page layout corresponding to the service identifier, a corresponding page component from a set of page components to generate the page template corresponding to the service identifier, and determine a storage address of a page component included in the page template.
The embodiment of the invention also provides electronic equipment for generating the page, which comprises one or more processors and a storage device, wherein the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method provided by any embodiment.
The embodiment of the invention also provides a computer readable medium, on which a computer program is stored, which when executed by a processor implements the method provided by any of the above embodiments.
FIG. 4 illustrates an exemplary system architecture 400 of a method of generating pages or an apparatus for generating pages to which embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 is used as a medium to provide communication links between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 405 via the network 404 using the terminal devices 401, 402, 403 to receive or send messages or the like. Various client applications, such as e-mall client applications, web browser applications, search class applications, etc., may be installed on the terminal devices 401, 402, 403.
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting various client applications including, but not limited to, smartphones, tablets, laptop and desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server providing support for client applications used by the user with the terminal devices 401, 402, 403. The background management server can process the received page generation request and feed back the page generation page to the terminal equipment.
It should be noted that, the method for generating a page provided in the embodiment of the present invention is generally executed by the server 405, and accordingly, the device for generating a page is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, there is illustrated a schematic diagram of a computer system 500 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Connected to the I/O interface 505 are an input section 506 including a keyboard, a mouse, and the like, an output section 507 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like, a storage section 508 including a hard disk, and the like, and a communication section 509 including a network interface card such as a LAN card, a modem, and the like. The communication section 509 performs communication processing via a network such as the internet. The drive 510 is also connected to the I/O interface 505 as needed. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as needed so that a computer program read therefrom is mounted into the storage section 508 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 509, and/or installed from the removable media 511. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 501.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of a computer-readable storage medium may include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules and/or units involved in the embodiments of the present invention may be implemented in software, or may be implemented in hardware. The described modules and/or units may also be provided in a processor, which may be described as, for example, a processor comprising a request receiving module, a template retrieving module, and a page generating module. The names of these modules do not limit the module itself in some cases, for example, the module for acquiring a template may also be described as "a module for acquiring a service page template corresponding to a service identifier according to the service identifier".
As a further aspect, the invention also provides a computer readable medium which may be comprised in the device described in the above embodiments or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to include receiving a request to generate a page, the request including at least a service identification, obtaining a page template corresponding to the service identification and a storage address of a page component included in the page template according to the service identification, the page component including a common component and a service component, generating a page text according to the page template and the storage address of the page component using a template engine, and transmitting the page text to a client to cause the client to render a page according to the page text.
Therefore, the embodiment of the invention can divide the page into a plurality of page components, select the corresponding page components to generate the page template according to different business requirements, automatically acquire the page template and the corresponding page components to generate the page text and render the generated page when receiving the request for generating the business page, wherein the page components can be provided by a third party, and therefore, each page template is configured with a plurality of independent page components according to a plurality of business configurations, thereby improving the modularization degree and the configurability of the page, improving the flexibility and the expansibility of the generated page and overcoming the problem of lower development efficiency caused by concentrated development.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.