"Original" blog Garden third party client-I blog Park app Open source
Please specify the source of the article reproduced-- polobymulberry-Blog Park
1. Preface
At present I blog Park app has been updated to 2.0.0 version, using the latest Blog Park Web API. Many new features have been added as compared to the first version, and many features have been modified. Overall, the change is relatively large, the code is also more chaotic. So take advantage of Qingming holiday, the code well tidied up a. At present, the basic architecture has been formed (of course, the latter need to be continuously optimized), but the basic function of the app has a lot to add, the latter will focus on the application of the perfect function.
The above is a brief introduction to the current situation of the app, back to the open source topic. Open source This app source code is actually my vision from the beginning, but the code is very chaotic, so drag and drop, there are many laboratory things, but I have never given up the idea of open source. Open source is more beneficial to me than harm:
- Although I am not a big bull, open source code is not a very big project. But I think it's always a process to be Daniel, and I hope I can write a blog or open source code to record the process. Many cattle, such as Guo Yanyuan (Yykit), and other projects mature and then released together. But my concept is not the same, I think open source code is also a product, if from the thinking of making products, very important point is the iterative development, when I finished the basic functions of the product, I should go online, and users to communicate, and then continue to iterate to develop the next version of the product. At the moment I feel like the overall architecture of my code is almost there, so I think I can put it on GitHub.
- The purpose of open source code is mainly to want more people to participate in, the essence is to urge themselves to learn. At present, the app function is not perfect, the personal power is limited, hope to have more people to join in, crowds.
- In addition to expose their own code, let everyone criticize correct, but also to enhance their own technology effective way. If the lucky can get the big God guidance, then rapid, haha (dream you)! In fact, I feel that I have been blindfolded to do their own things, do not communicate with the outside world, so bad, easy to become a frog.
- The last one is also more important-to meet my vanity (don't be stingy, give me more small stars.) Haha, that's how I don't want to face! No face! Needs bark Face! )
2. New version I blog Park app effect
Previous version of the I blog Park, please step to "blog Park third-party client-I blog Park officially released the app Store." Because of the new Web API, many new features have been added, such as libraries, logins, and so on.
Blog |
News |
Library |
|
|
|
Me-Login |
I-Non-login |
|
|
|
|
3. I blog Park Code structure introduction 3.1 Code overall structure
The overall code is divided by function modules, and each function module is based on MVC (described below). Here I am divided into 7 modules:1. Blog 2. News 3. Library (Knowledge Base library) 4. Flash (temporarily not implemented, Flash) 5. I (Me) 6. Boot page (Guide) 7. Primary (Main)
3.2 Module Introduction 3.2.1 Blog
The content of the blog mainly consists of two parts, one is the homepage , the other is selected .
The home section uses a simple tableview, and the type of each cell is the Icbloghometableviewcell that is placed in the Bloghometableviewcell directory. Which dynamically calculates the cell height is the use of the Uitableview+fdtemplatelayoutcell library. The featured section uses custom Collectionviewlayout, called Icblogpickedcollectionviewlayout. In addition, these two parts are placed in a ScrollView (Icblogscrollview).
As for the content of each blog, I use the Kinwebbrowser library, rather than using JSON data obtained from the server side, because JSON parsing is poor, rather than just using a Web browser to display good looks. When using Kinwebbrowser, you can simply double-click the page to zoom in to the best reading mode and use UIWebView to do this.
3.2.2 News
The content of the news mainly consists of three parts: latest (Icnewsnewesttableview), recommended (Icnewsrecommendtableview), popular ( Icnewshottableview).
All three use TableView, placed in a ScrollView (Icnewsscrollview). Each Tableviewcell is a Icnewstableviewcell type. Individuals prefer simple style.
However, the content of the news shows that I am parsing JSON data for typesetting. A Contenthtmltemplatewithargs macro function was customized to build the HTML data.
3.2.3 Library
Basically with the news, but Tableviewcell is using Iclibrarytableviewcell.
3.2.4 Flash (temporarily not implemented)
This one will focus on the following, because this is a part of the user's communication is relatively heavy.
3.2.5. I
This piece is done for a long time, the UI is relatively complex, and the knowledge of OAuth is also involved. The OAuth section recommends Dudu's OAuth series blog.
Me this piece is actually composed of two two parts, one is the login part , one is the Personal Center part .
* * Login Section * *
1. Get the user name and password
2. Use OpenSSL for RSA encryption with user name and password
3. Use Grant_type to log in to Password's OAuth authentication mode.
* * Personal Center * *
My blog and my collection are simple, simple tableview, even the cell is not customized.
Set some features to be more miscellaneous:
① clears the cache using Sdwebimage, asynchronous cleanup, the code is as follows:
Iclog (@ " size count:%ld " ,[[sdimagecache Sharedimagecache] getsize]);d Ispatch_async (dispatch_get_ Global_queue (Dispatch_queue_priority_default, {[[Sdimagecache Sharedimagecache] cleardiskoncompletion: ^{Iclog ( Span style= "color: #800000;" >@ " clear success " @ " size count:%ld " ,[[sdimagecache Sharedimagecache] getsize]); Cell.textLabel.text = [self getcachesize]; }];});
② about the part is the use of cnppopupcontroller, the reason why this simple function also uses a third-party library, is because I have not yet thought how to do this window after the background blur effect, later will be replaced by their own library.
③ evaluation is very simple, do not repeat.
④ exit account is actually deleted the local stored account information file.
3.2.6 Guide Page
Please refer to my previous blog "blog Park third-party client-I blog Park officially released the app Store", here will not repeat.
3.2.7 Primary (Main)
This part of the content is many, so I separate, as to what is the difference between helper and tool, please disregard, I have shallow experience, still can not answer.
3.2.7.1 vender
The RSA encryption algorithm for OpenSSL is stored. Refer to the blog "RSA Encryption" for details.
3.2.7.2 Category
It's a lot more stuff to store. I always agree with Tian Wei-yu that category is a typical method of combining inheritance. And here I try not to put strong business in category, I think category should put some weak business things.
3.2.7.3 Helper
Separate the datasource from the Viewcontroller to achieve light View Controller. Refer to the article "Lighter View Controllers".
3.2.7.4 Tool
**iccontrollertool**
Mainly to solve the first installation, or update the app, you should start the boot interface problem.
**icnetworktool**
I put a layer on top of the afnetworking, but I don't think the design is very good here. For the time being, try the discrete API call later.
**icoauthtool/icclientcredentialsoauthtool**
Because the network request will use a variety of access_token, such as Grant_type for the client credentials and Grant_type for the password/refresh_token of access token is not the same.
So I defined the two tool to manage the relative request. The corresponding model is Icoauth and Icclientcredentialsoauth.
3.2.7.5 Controller
**icleftmenuviewcontroller/icleftsidemenu**
Because of the use of Residemenu, so Icleftsidemenu is actually Residemenu subclass, And Icleftmenuviewcontroller is actually Residemenu's leftmenuviewcontroller.
3.2.7.6 Other
Put Appdelegate and Main.
3.2.7.7 View
Icleftmenuheaderview is actually the icleftsidemenu on this:
4. Issues related to open source 4.1 Open Source Address
Github:https://github.com/polobymulberry/icnblogs
4.2 Post-Open source work
- Flash Parts
- Currently other parts can only be viewed, not yet commented, deleted
- Search section
- Share Features
- Refresh token does not work
- There's a lot more, and when I think about it, I add it to the GitHub page ...
4.3 Open Source Considerations
Because there are some places that involve privacy, I will de-allergenic the code (ClientID and Clientsecret). You will not be able to run directly after downloading. If you are interested, you can go to the blog Park to apply for a clientid and Clientsecret.
5. Thanks
Thanks to the administrator of the blog Park for help and guidance.
"Original" blog Garden third party client-I blog Park app Open source