Table of Contents
快速上手:
Home php教程 php手册 【开源专访】iNews创始人赵戈戈:36小时开发的PHP版HackerNews

【开源专访】iNews创始人赵戈戈:36小时开发的PHP版HackerNews

Jun 06, 2016 pm 07:58 PM
Exclusive interview Founder develop Open source

iNews是一套开源的极简社区程序,其目标是让开发者轻松获得一个与Hacker News一般,并且更漂亮、又能跨终端(Responsive 适配)运行的分享网站。 快速上手: 安装 :在自己的服务器上运行 iNews 程序 配置 :网站信息、管理员(审批权限)、邮件发送与邮件服

iNews是一套开源的极简社区程序,其目标是让开发者轻松获得一个与Hacker News一般,并且更漂亮、又能跨终端(Responsive 适配)运行的分享网站。 

快速上手:

  • 安装:在自己的服务器上运行 iNews 程序
  • 配置:网站信息、管理员(审批权限)、邮件发送与邮件服务器设置等

相关资料:

主页: http://inews.io/

托管地址: https://github.com/Trimidea/inews

CSDN记者采访了iNews开发团队负责人赵戈戈(微博:@hfcorriez),跟大家分享为什么要开发iNews以及开发所用到的技术与难点。

【开源专访】iNews创始人赵戈戈:36小时开发的PHP版HackerNews

赵戈戈

CSDN:Hacker News本身也是开源的,为什么还要做iNews?初衷是什么?

赵戈戈:Hacker News从功能和内容本身上来说是个很好的应用,我们最初也是想从开源入手 —— 直接使用,不过HN是甚于Arch实现的,我们对Arch 并不熟悉,所以决定自己写,以便功能扩展。

关于初衷。从产品上讲,要从我和搭档 @sofish说起。我们都是苹果的忠实用户,经常会互相分享一些应用,久而久之也就萌发了这个念头:做一个分享苹果新闻和应用的社区,对于苹果在中国这几年设备数据大增,应该有很多人跟我们有同样的需求,于是就开始做了;从技术上讲,它的结构类似于Hacker News,而外观应该更漂亮,并且要适合移动应用阅读。最终我们动手实现了它,并上线了 http://inews.io。虽然现在还没有完全做到期望值,但最起码迈出了第一步;从程序本身来讲,上线了一段时间后,很多朋友看到都希望在自己站点上使用,后来越来越多的人寻求使用并提供建议,基于我们对开源的开放态度,最终决定放出来给大家使用。

CSDN:iNews 在技术上是如何实现的?

赵戈戈:iNews基于PHP,使用Mysql存储,phpmig进行数据库版本管理。框架上,后端采用了我自己写的Restful框架 Pagon来开发,前端使用了@sofish的 typo.css, validator.js等开源库。第一版本上线前我们希望从最基本的功能开始,上线 > 快速迭代。整个开发过程非常快,只用了一天半的时间就实现了。后续做了些优化和修复就上线了。在服务上我们也采用一些不错的第三方服务:用SendGrid发送邮件,用NewRelic做应用监控,用Dropbox做数据库备份等等。

这里再补充一点:从技术选型上,技术适应产品才是最重要的,不要强迫自己使用的是PHP 、Node或者Ruby等。选择基于PHP的Pagon这个框架,让我们可以更快速实现iNews.io的功能。

CSDN:总共有几名开发人员?这种UGC项目的技术难点和重点是什么?你们是如何解决的?

赵戈戈:只有我和搭档@sofish两个人。开源之后应该会陆续会有一些同学加入,实际上目前已经有一些同学在一起开发。对于iNews来说,技术上基本没太多难点,主要有几个点需要关注:安全性、性能、易用、适配(Responsive)、社会化接入等。

安全性主要是XSS和数据库过滤。Pagon框架已实现自动XSS处理的,只要开启了safe_query 的选项,在模板渲染的过程中会自动做XSS过滤。数据库方面使用的一个paris库,它本身使用PDO来处理SQL,PDO本身会对数据进行转义处理再存入。

性能其实是个很泛的话题,iNews.io数据样本太少,还不好看出性能到底如何,就目前的平均输出时间来看只有30ms左右,前端方面使用Google Pagespeed测试是:移动,85/100;桌面 95/100;这比很多网站分数都要高。高性能跟逻辑简单和实现方法都有关系,如果需要很好的性能需要考虑到方方面面,我这里先简单说PHP的基本观点:代码越简单越好,不要使用太多魔术方法,尽量使用PHP 内置的方法,使用最新的稳定版5.4,服务器安装APC扩展,使用Nginx + FPM模式运行PHP。其次Pagon框架本身开发过程也对性能有很高的要求,所以在代码质量和性能上也下了不少功夫,这也是应用性能的基础。在数据库方面只做了索引优化来达到更好的查询性能。性能还涉及到很多,做为一个刚初出茅庐的应用来说还没有足够完善也不需要把性能放到第一位,在这里就先不说还没有做到的。

而在前端,跨终端适配应该是现代应用最应该做的支持。@sofish 在这一块有很多的研究,所以我们的 iNews 是可以在移动设备上很好的访问的。

社会化接入这块其实也并不是什么难点,只需要有很好的封装就可以解决问题,重新开发代价稍大。我觉得 PHP 第三方认证的库都做的很一般,但还是有个opauth的第三方认证库,封装有点凌乱,但凑合着能用。如果是Node的话,这一块有很多很不错的库,比如everyauth和passport,如果PHP社区可以像Node社区一样活跃那问题就可以更好解决了。

CSDN:iNews在内容推荐上采用了什么样的机制或算法?

赵戈戈:iNews最初是参照Hacker News的算法来做的,后期将评论也加入了权重。因为觉得对于这种社区来说,评论是很重要的一块,评论代表着交流,有交流就证明内容的价值有可能存在,如果只有“顶”才算权重,那激烈的讨论可能会显得不太公平。但若是每个评论的权重和每个“顶”的权重一样,又显得不太合理,“顶”是认可的意思,评论是交流的意思,所以评论应该稍低于“顶”的权重,这样做才比较合理。最终是这么来做的。

CSDN:iNews 有哪些创新性的东西?

赵戈戈:如果说创新的话,我想提一个设计模式:MOVE。应该有不少人看到过过这个设计模式,摒弃了MVC传统老套的做法。采用了Model、Operator、View 和 Event 来梳理编码流程。其中 Operator可能是大家最不解的一个地方,其实也是最具创新意义的地方,Opeartor从字面意思来理解就是:操作器。Opeartor的出现摈弃了控制器重用性和代码混杂的局面,将每个操作都拆分成一个独立的操作器,组织成一个树形的流程来封装使用,对于编码流程来说是一个梳理。iNews里面有一些对操作器的浅显理解和实现,但并没有完全使用操作器来做,还是主要使用MVC作为基础,这种尝试会慢慢变得成熟,并可能逐步完全采用这种模式来开发。

【开源专访】系列文章致力于对国内外优秀开源项目作者、团队的专访,挖掘项目背后的故事和更多技术细节,以及对项目的宣传、推广。同时,我们也希望广大开源开发者和爱好者自荐或推荐更多优秀的开源项目。欢迎留言或@CSDN研发频道。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

15 recommended open source free image annotation tools 15 recommended open source free image annotation tools Mar 28, 2024 pm 01:21 PM

Image annotation is the process of associating labels or descriptive information with images to give deeper meaning and explanation to the image content. This process is critical to machine learning, which helps train vision models to more accurately identify individual elements in images. By adding annotations to images, the computer can understand the semantics and context behind the images, thereby improving the ability to understand and analyze the image content. Image annotation has a wide range of applications, covering many fields, such as computer vision, natural language processing, and graph vision models. It has a wide range of applications, such as assisting vehicles in identifying obstacles on the road, and helping in the detection and diagnosis of diseases through medical image recognition. . This article mainly recommends some better open source and free image annotation tools. 1.Makesens

Ten recommended open source free text annotation tools Ten recommended open source free text annotation tools Mar 26, 2024 pm 08:20 PM

Text annotation is the work of corresponding labels or tags to specific content in text. Its main purpose is to provide additional information to the text for deeper analysis and processing, especially in the field of artificial intelligence. Text annotation is crucial for supervised machine learning tasks in artificial intelligence applications. It is used to train AI models to help more accurately understand natural language text information and improve the performance of tasks such as text classification, sentiment analysis, and language translation. Through text annotation, we can teach AI models to recognize entities in text, understand context, and make accurate predictions when new similar data appears. This article mainly recommends some better open source text annotation tools. 1.LabelStudiohttps://github.com/Hu

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

Recommended: Excellent JS open source face detection and recognition project Recommended: Excellent JS open source face detection and recognition project Apr 03, 2024 am 11:55 AM

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages ​​and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

Alibaba 7B multi-modal document understanding large model wins new SOTA Alibaba 7B multi-modal document understanding large model wins new SOTA Apr 02, 2024 am 11:31 AM

New SOTA for multimodal document understanding capabilities! Alibaba's mPLUG team released the latest open source work mPLUG-DocOwl1.5, which proposed a series of solutions to address the four major challenges of high-resolution image text recognition, general document structure understanding, instruction following, and introduction of external knowledge. Without further ado, let’s look at the effects first. One-click recognition and conversion of charts with complex structures into Markdown format: Charts of different styles are available: More detailed text recognition and positioning can also be easily handled: Detailed explanations of document understanding can also be given: You know, "Document Understanding" is currently An important scenario for the implementation of large language models. There are many products on the market to assist document reading. Some of them mainly use OCR systems for text recognition and cooperate with LLM for text processing.

Just released! An open source model for generating anime-style images with one click Just released! An open source model for generating anime-style images with one click Apr 08, 2024 pm 06:01 PM

Let me introduce to you the latest AIGC open source project-AnimagineXL3.1. This project is the latest iteration of the anime-themed text-to-image model, aiming to provide users with a more optimized and powerful anime image generation experience. In AnimagineXL3.1, the development team focused on optimizing several key aspects to ensure that the model reaches new heights in performance and functionality. First, they expanded the training data to include not only game character data from previous versions, but also data from many other well-known anime series into the training set. This move enriches the model's knowledge base, allowing it to more fully understand various anime styles and characters. AnimagineXL3.1 introduces a new set of special tags and aesthetics

Learn how to develop mobile applications using Go language Learn how to develop mobile applications using Go language Mar 28, 2024 pm 10:00 PM

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

See all articles